Remove FPS profiler from DemoRunner
This commit is contained in:
@@ -8,7 +8,6 @@ import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.lib.gui.BorderLayout;
|
||||
import com.bartlomiejpluta.base.lib.gui.Label;
|
||||
import com.bartlomiejpluta.base.lib.gui.TextView;
|
||||
import com.bartlomiejpluta.base.util.profiler.FPSProfiler;
|
||||
import com.bartlomiejpluta.demo.entity.Player;
|
||||
import com.bartlomiejpluta.demo.event.EnemyDiedEvent;
|
||||
import com.bartlomiejpluta.demo.event.HitEvent;
|
||||
@@ -28,8 +27,6 @@ public class HUD extends BorderLayout {
|
||||
private final Runtime runtime;
|
||||
private final LimitedQueue<String> logger = new LimitedQueue<>(MAX_LOG_SIZE);
|
||||
|
||||
private final FPSProfiler fpsProfiler;
|
||||
|
||||
private float logVisibilityDuration = 0f;
|
||||
|
||||
@Ref("hp")
|
||||
@@ -44,7 +41,6 @@ public class HUD extends BorderLayout {
|
||||
public HUD(Context context, GUI gui, Map<String, Component> refs) {
|
||||
super(context, gui, refs);
|
||||
this.player = DemoRunner.instance().getPlayer();
|
||||
this.fpsProfiler = DemoRunner.instance().getFpsProfiler();
|
||||
this.runtime = Runtime.getRuntime();
|
||||
context.addEventListener(HitEvent.TYPE, this::logHitEvent);
|
||||
context.addEventListener(EnemyDiedEvent.TYPE, this::logEnemyDiedEvent);
|
||||
@@ -84,7 +80,7 @@ public class HUD extends BorderLayout {
|
||||
public void draw(Screen screen, GUI gui) {
|
||||
var coords = player.getCoordinates();
|
||||
var pos = player.getPosition();
|
||||
debugTxt.setText(String.format("FPS: %.2f\n" + "Mem: %.2f / %.2f [MB]\n" + "Coords: %d : %d\n" + "Pos: %.2f : %.2f\n" + "Entities: %d\n", fpsProfiler.getInstantFPS(), runtime.totalMemory() / 1024f / 1024f, runtime.maxMemory() / 1024f / 1024f, coords.x(), coords.y(), pos.x(), pos.y(), player.getLayer().getEntities().size() - 1));
|
||||
debugTxt.setText(String.format("Mem: %.2f / %.2f [MB]\nCoords: %d : %d\nPos: %.2f : %.2f\nEntities: %d\n", runtime.totalMemory() / 1024f / 1024f, runtime.maxMemory() / 1024f / 1024f, coords.x(), coords.y(), pos.x(), pos.y(), player.getLayer().getEntities().size()));
|
||||
|
||||
logLbl.setAlpha(Math.min(1f, logVisibilityDuration / LOG_VISIBILITY_FADING_OUT));
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.api.gui.GUI;
|
||||
import com.bartlomiejpluta.base.api.runner.GameRunner;
|
||||
import com.bartlomiejpluta.base.api.screen.Screen;
|
||||
import com.bartlomiejpluta.base.util.profiler.FPSProfiler;
|
||||
import com.bartlomiejpluta.demo.entity.Player;
|
||||
import com.bartlomiejpluta.demo.menu.GuiManager;
|
||||
import lombok.Getter;
|
||||
@@ -20,8 +19,6 @@ public class DemoRunner implements GameRunner {
|
||||
private Context context;
|
||||
private GUI hud;
|
||||
|
||||
@Getter
|
||||
private final FPSProfiler fpsProfiler = FPSProfiler.create(20);
|
||||
@Getter
|
||||
private GuiManager guiManager;
|
||||
|
||||
@@ -82,10 +79,6 @@ public class DemoRunner implements GameRunner {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float dt) {
|
||||
fpsProfiler.update(dt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</base:BorderLayout-TopLeft>
|
||||
|
||||
<base:BorderLayout-TopRight>
|
||||
<demo:FPSMonitor monitor="5|40" padding="15f" width="150" height="100f"/>
|
||||
<base:FPSMonitor monitor="5|40" padding="15f" width="150" height="100f"/>
|
||||
</base:BorderLayout-TopRight>
|
||||
|
||||
<base:BorderLayout-BottomLeft>
|
||||
|
||||
Reference in New Issue
Block a user