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

58 lines
1.2 KiB

package mightypork.rogue.screens;
import static mightypork.utils.math.constraints.Constraints.*;
import mightypork.gamecore.gui.components.painters.TextPainter;
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.math.constraints.RectConstraint;
import mightypork.utils.math.coord.Vec;
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 = _box(_sub(_top_right(this), 8, 8), 0, 32);
tp = new TextPainter(font, Align.RIGHT, RGB.WHITE, text);
tp.setContext(constraint);
tp.setShadow(RGB.BLACK, Vec.ONE);
}
@Override
public void render()
{
tp.render();
}
@Override
public int getPriority()
{
return Integer.MAX_VALUE;
}
}