improve debug hud
This commit is contained in:
@@ -61,7 +61,7 @@ public class GameScreen implements Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCamera() {
|
private void initCamera() {
|
||||||
camera = new PerspectiveCamera(60f, RETRO_WIDTH, RETRO_HEIGHT);
|
camera = new PerspectiveCamera(55f, RETRO_WIDTH, RETRO_HEIGHT);
|
||||||
settings = new GameSettings();
|
settings = new GameSettings();
|
||||||
settings.fov = camera.fieldOfView;
|
settings.fov = camera.fieldOfView;
|
||||||
cameraController = new FpsCameraController(camera, settings);
|
cameraController = new FpsCameraController(camera, settings);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package wtf.beatrice.retrorender.engine;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.PerspectiveCamera;
|
import com.badlogic.gdx.graphics.PerspectiveCamera;
|
||||||
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
@@ -13,6 +14,7 @@ public class DebugHud {
|
|||||||
private final SpriteBatch batch;
|
private final SpriteBatch batch;
|
||||||
private final BitmapFont font;
|
private final BitmapFont font;
|
||||||
private DayNightCycle dayNightCycle;
|
private DayNightCycle dayNightCycle;
|
||||||
|
private final Texture pixel;
|
||||||
|
|
||||||
public DebugHud(DayNightCycle dayNightCycle) {
|
public DebugHud(DayNightCycle dayNightCycle) {
|
||||||
this.dayNightCycle = dayNightCycle;
|
this.dayNightCycle = dayNightCycle;
|
||||||
@@ -41,6 +43,13 @@ public class DebugHud {
|
|||||||
|
|
||||||
font = generator.generateFont(param);
|
font = generator.generateFont(param);
|
||||||
generator.dispose();
|
generator.dispose();
|
||||||
|
|
||||||
|
// 1x1 pixel
|
||||||
|
Pixmap pm = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
|
||||||
|
pm.setColor(1f, 1f, 1f, 1f);
|
||||||
|
pm.fill();
|
||||||
|
pixel = new Texture(pm);
|
||||||
|
pm.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// render HUD in virtual resolution
|
// render HUD in virtual resolution
|
||||||
@@ -52,14 +61,23 @@ public class DebugHud {
|
|||||||
|
|
||||||
batch.begin();
|
batch.begin();
|
||||||
|
|
||||||
String fpsText = Gdx.graphics.getFramesPerSecond() + " FPS";
|
|
||||||
font.draw(batch, fpsText, 5f, height - 5f);
|
|
||||||
|
|
||||||
if (camera != null) {
|
if (camera != null) {
|
||||||
float x = camera.position.x;
|
float x = camera.position.x;
|
||||||
float y = camera.position.y;
|
float y = camera.position.y;
|
||||||
float z = camera.position.z;
|
float z = camera.position.z;
|
||||||
|
|
||||||
|
float panelW = 275f;
|
||||||
|
float panelH = 45f;
|
||||||
|
float panelX = 2f;
|
||||||
|
float panelY = height - panelH - 2f;
|
||||||
|
|
||||||
|
// background
|
||||||
|
batch.setColor(0f, 0f, 0f, 0.10f);
|
||||||
|
batch.draw(pixel, panelX, panelY, panelW, panelH);
|
||||||
|
|
||||||
|
String fpsText = Gdx.graphics.getFramesPerSecond() + " FPS";
|
||||||
|
font.draw(batch, fpsText, 5f, height - 5f);
|
||||||
|
|
||||||
String posText = String.format("X: %.3f Y: %.3f Z: %.3f", x, y, z);
|
String posText = String.format("X: %.3f Y: %.3f Z: %.3f", x, y, z);
|
||||||
font.draw(batch, posText, 5f, height - 15f);
|
font.draw(batch, posText, 5f, height - 15f);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package wtf.beatrice.retrorender.engine;
|
|||||||
|
|
||||||
public class GameSettings {
|
public class GameSettings {
|
||||||
|
|
||||||
public float fov = 60f; // degrees
|
public float fov = 55f; // degrees
|
||||||
public float mouseSensitivity = 0.15f;
|
public float mouseSensitivity = 0.15f;
|
||||||
public float moveSpeed = 5f;
|
public float moveSpeed = 5f;
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class SettingsMenu {
|
|||||||
pm.dispose();
|
pm.dispose();
|
||||||
|
|
||||||
// default FOV
|
// default FOV
|
||||||
fov = 60f;
|
fov = 55f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFov(float fov) {
|
public void setFov(float fov) {
|
||||||
|
|||||||
Reference in New Issue
Block a user