improve debug hud

This commit is contained in:
2025-11-14 01:15:40 +01:00
parent f5bacf68d4
commit 17c59049f3
3 changed files with 23 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package wtf.beatrice.retrorender;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.PerspectiveCamera;
@@ -41,6 +42,8 @@ public class GameScreen implements Screen {
private static final int RETRO_WIDTH = 320;
private static final int RETRO_HEIGHT = 180;
private boolean showHud = false;
public GameScreen(Main game) {
this.game = game;
}
@@ -127,6 +130,10 @@ public class GameScreen implements Screen {
cameraController.update(delta, world);
world.update(delta);
if (Gdx.input.isKeyJustPressed(Input.Keys.TAB)) {
showHud = !showHud;
}
// --- shadow pass: render depth from light's point of view
// point to center the shadow camera on;
// can be adjusted this later (e.g. follow player).
@@ -150,7 +157,13 @@ public class GameScreen implements Screen {
modelBatch.end();
// --- HUD
hud.render(RETRO_WIDTH, RETRO_HEIGHT, camera);
if (showHud)
hud.render(
RETRO_WIDTH,
RETRO_HEIGHT,
camera,
cameraController.getYaw(),
cameraController.getPitch());
frameBuffer.end();

View File

@@ -41,7 +41,9 @@ public class DebugHud {
}
// render HUD in virtual resolution
public void render(int width, int height, PerspectiveCamera camera) {
public void render(int width, int height,
PerspectiveCamera camera,
float yaw, float pitch) {
// set up orthographic projection matching target size
batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
@@ -57,6 +59,9 @@ public class DebugHud {
String posText = String.format("X: %.2f Y: %.2f Z: %.2f", x, y, z);
font.draw(batch, posText, 5f, height - 15f);
String angText = String.format("Yaw: %.1f Pitch: %.1f", yaw, pitch);
font.draw(batch, angText, 5f, height - 25f);
}
batch.end();

View File

@@ -236,6 +236,9 @@ public class FpsCameraController {
}
}
public float getYaw() { return yaw; }
public float getPitch() { return pitch; }
public void setMoveSpeed(float moveSpeed) { this.moveSpeed = moveSpeed; }
public void setMouseSensitivity(float mouseSensitivity) { this.mouseSensitivity = mouseSensitivity; }
}