diff --git a/core/src/main/java/wtf/beatrice/retrorender/GameScreen.java b/core/src/main/java/wtf/beatrice/retrorender/GameScreen.java index cf61f74..9da8cd8 100644 --- a/core/src/main/java/wtf/beatrice/retrorender/GameScreen.java +++ b/core/src/main/java/wtf/beatrice/retrorender/GameScreen.java @@ -61,9 +61,8 @@ public class GameScreen implements Screen { } private void initCamera() { - camera = new PerspectiveCamera(55f, RETRO_WIDTH, RETRO_HEIGHT); settings = new GameSettings(); - settings.fov = camera.fieldOfView; + camera = new PerspectiveCamera(settings.fov, RETRO_WIDTH, RETRO_HEIGHT); cameraController = new FpsCameraController(camera, settings); } diff --git a/core/src/main/java/wtf/beatrice/retrorender/engine/FpsCameraController.java b/core/src/main/java/wtf/beatrice/retrorender/engine/FpsCameraController.java index d870600..38fbaee 100644 --- a/core/src/main/java/wtf/beatrice/retrorender/engine/FpsCameraController.java +++ b/core/src/main/java/wtf/beatrice/retrorender/engine/FpsCameraController.java @@ -110,9 +110,10 @@ public class FpsCameraController { /** Update each frame with delta time */ public void update(float delta, World3D world) { - camera.position.y -= bobOffsetY; - bobOffsetY = 0f; - + if (settings.bobbingEnabled) { + camera.position.y -= bobOffsetY; + bobOffsetY = 0f; + } if (!mouseCaptured) { return; @@ -322,22 +323,24 @@ public class FpsCameraController { // 4) VIEW BOBBING (purely visual) // ========================================================= // horizontal movement magnitude (world units per frame) - float horizLen = (float)Math.sqrt(moveX * moveX + moveZ * moveZ); + if (settings.bobbingEnabled) { + float horizLen = (float)Math.sqrt(moveX * moveX + moveZ * moveZ); - if (grounded && horizLen > 0.0001f) { - // scale bob speed by how fast you're moving - float speedFactor = horizLen / (settings.moveSpeed * delta + 1e-6f); - bobTime += delta * bobSpeed * speedFactor; + if (grounded && horizLen > 0.0001f) { + // scale bob speed by how fast you're moving + float speedFactor = horizLen / (settings.moveSpeed * delta + 1e-6f); + bobTime += delta * bobSpeed * speedFactor; - bobOffsetY = (float)Math.sin(bobTime) * bobAmount; - } else { - // not moving or in the air → relax bobbing back to zero - bobTime = 0f; - // optional: smooth return to 0 instead of snapping - bobOffsetY += (0f - bobOffsetY) * 10f * delta; + bobOffsetY = (float)Math.sin(bobTime) * bobAmount; + } else { + // not moving or in the air → relax bobbing back to zero + bobTime = 0f; + // optional: smooth return to 0 instead of snapping + bobOffsetY += (0f - bobOffsetY) * 10f * delta; + } + + camera.position.y += bobOffsetY; } - - camera.position.y += bobOffsetY; } private void updateCameraDirection() { // build direction vector from yaw/pitch diff --git a/core/src/main/java/wtf/beatrice/retrorender/engine/GameSettings.java b/core/src/main/java/wtf/beatrice/retrorender/engine/GameSettings.java index de3f8a9..29d94e7 100644 --- a/core/src/main/java/wtf/beatrice/retrorender/engine/GameSettings.java +++ b/core/src/main/java/wtf/beatrice/retrorender/engine/GameSettings.java @@ -2,10 +2,13 @@ package wtf.beatrice.retrorender.engine; public class GameSettings { - public float fov = 55f; // degrees + public float fov = 60f; // degrees public float mouseSensitivity = 0.15f; public float moveSpeed = 5f; - public float minFov = 40f; - public float maxFov = 100f; + public final float minFov = 40f; + public final float maxFov = 100f; + public final float fovStep = 2f; + + public boolean bobbingEnabled = true; } diff --git a/core/src/main/java/wtf/beatrice/retrorender/engine/GameUi.java b/core/src/main/java/wtf/beatrice/retrorender/engine/GameUi.java index 53fe3c4..d6de06e 100644 --- a/core/src/main/java/wtf/beatrice/retrorender/engine/GameUi.java +++ b/core/src/main/java/wtf/beatrice/retrorender/engine/GameUi.java @@ -17,10 +17,7 @@ public class GameUi { public GameUi(GameSettings settings) { this.settings = settings; this.pauseMenu = new PauseMenu(); - this.settingsMenu = new SettingsMenu(); - - // sync initial settings - this.settingsMenu.setFov(settings.fov); + this.settingsMenu = new SettingsMenu(settings); } public UiMode onEsc(UiMode current) { @@ -54,6 +51,7 @@ public class GameUi { boolean close = settingsMenu.handleClick(retroX, retroY); // always sync FOV to settings settings.fov = settingsMenu.getFov(); + settings.bobbingEnabled = settingsMenu.isBobbingEnabled(); if (close) { // Settings “Close” button clicked -> go back to PAUSE diff --git a/core/src/main/java/wtf/beatrice/retrorender/engine/SettingsMenu.java b/core/src/main/java/wtf/beatrice/retrorender/engine/SettingsMenu.java index a838354..cec55be 100644 --- a/core/src/main/java/wtf/beatrice/retrorender/engine/SettingsMenu.java +++ b/core/src/main/java/wtf/beatrice/retrorender/engine/SettingsMenu.java @@ -17,18 +17,18 @@ public class SettingsMenu { private final BitmapFont boldFont; private final Texture pixel; - // FOV value stored here, GameScreen syncs it to the camera - private float fov; - private final float minFov = 40f; - private final float maxFov = 100f; - private final float fovStep = 2f; + private final GameSettings settings; + + private boolean bobbingEnabled = true; // button / hit areas private float fovDecX, fovDecY, fovDecW, fovDecH; private float fovIncX, fovIncY, fovIncW, fovIncH; private float closeX, closeY, closeW, closeH; - public SettingsMenu() { + public SettingsMenu(GameSettings settings) { + this.settings = settings; + batch = new SpriteBatch(); FreeTypeFontGenerator generator = @@ -60,19 +60,27 @@ public class SettingsMenu { pm.fill(); pixel = new Texture(pm); pm.dispose(); - - // default FOV - fov = 55f; } public void setFov(float fov) { - this.fov = MathUtils.clamp(fov, minFov, maxFov); + settings.fov = MathUtils.clamp(fov, settings.minFov, settings.maxFov); } public float getFov() { - return fov; + return settings.fov; } + public boolean isBobbingEnabled() + { + return bobbingEnabled; + } + + public void setBobbingEnabled(boolean enabled){ + bobbingEnabled = enabled; + } + + + /** * @param width RETRO_WIDTH * @param height RETRO_HEIGHT @@ -136,7 +144,7 @@ public class SettingsMenu { drawButtonWithLabel(">", fovIncX, fovIncY, fovIncW, fovIncH); // numeric value centered between dec/inc - String fovText = String.format("%3.0f°", fov); + String fovText = String.format("%3.0f°", settings.fov); layout.setText(font, fovText); float valueCenter = (fovDecX + fovDecW + fovIncX) / 2f; @@ -196,14 +204,14 @@ public class SettingsMenu { // FOV - if (x >= fovDecX && x <= fovDecX + fovDecW && y >= fovDecY && y <= fovDecY + fovDecH) { - fov = MathUtils.clamp(fov - fovStep, minFov, maxFov); + settings.fov = MathUtils.clamp(settings.fov - settings.fovStep, settings.minFov, settings.maxFov); return false; } // FOV + if (x >= fovIncX && x <= fovIncX + fovIncW && y >= fovIncY && y <= fovIncY + fovIncH) { - fov = MathUtils.clamp(fov + fovStep, minFov, maxFov); + settings.fov = MathUtils.clamp(settings.fov + settings.fovStep, settings.minFov, settings.maxFov); return false; }