Rogue: Savage Rats, a retro-themed dungeon crawler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rogue-savage-rats/src/mightypork/rogue/screens/LayerFps.java

56 lines
1.2 KiB

package mightypork.rogue.screens;
import static mightypork.gamecore.gui.constraints.Constraints.*;
import static org.lwjgl.opengl.GL11.*;
import mightypork.gamecore.gui.components.painters.TextPainter;
import mightypork.gamecore.gui.constraints.RectConstraint;
import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.gui.screens.ScreenLayer;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.gamecore.render.fonts.GLFont;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.string.StringProvider;
public class LayerFps extends ScreenLayer {
TextPainter tp;
public LayerFps(Screen screen) {
super(screen);
final StringProvider text = new StringProvider() {
@Override
public String getString()
{
return getDisplay().getFps() + " fps";
}
};
final GLFont font = Res.getFont("default");
final RectConstraint constraint = _round(_move(_grow_down(_right_top(this), 32), -8, 8));
tp = new TextPainter(font, Align.RIGHT, RGB.WHITE, text);
tp.setContext(constraint);
}
@Override
public void render()
{
tp.render();
}
@Override
public int getPriority()
{
return Integer.MAX_VALUE;
}
}