summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-04-28 17:14:19 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-04-28 17:14:19 +0200
commit259bee291e74f5f3aeaf3aec8b87c65151ac5aa5 (patch)
tree9ae5579ebad77a3581536c9afd4015db680771b1
parent6ac77370aca0cb98b09d62c55317a99e3228fba5 (diff)
downloadstalag-master.tar.gz
Better player camera FOVHEADmaster
-rw-r--r--config.h1
-rw-r--r--game.c2
-rw-r--r--player.c5
3 files changed, 6 insertions, 2 deletions
diff --git a/config.h b/config.h
index b92b308..7013074 100644
--- a/config.h
+++ b/config.h
@@ -16,6 +16,7 @@
#define PLAYER_HEIGHT 64.0f
#define PLAYER_RADIUS 16.0f
#define PLAYER_EYE_HEIGHT 56.0f
+#define PLAYER_FOV 65.0f
#define PLAYER_LEAN_ANGLE 25.0f
#define PLAYER_LEAN_SPEED 8.0f
diff --git a/game.c b/game.c
index ad932a8..168cae4 100644
--- a/game.c
+++ b/game.c
@@ -95,7 +95,7 @@ bool LoadMap(const char *filename) {
game.camera.position = (Vector3){ 0, 10, 0 };
game.camera.target = (Vector3){ 1, 10, 0 };
game.camera.up = (Vector3){ 0, 1, 0 };
- game.camera.fovy = 75.0f;
+ game.camera.fovy = PLAYER_FOV;
game.camera.projection = CAMERA_PERSPECTIVE;
int total_brushes = 0;
diff --git a/player.c b/player.c
index a8c039f..01c56ca 100644
--- a/player.c
+++ b/player.c
@@ -266,11 +266,14 @@ void UpdatePlayer(void) {
-sinf(game.pitch),
cosf(game.pitch) * cosf(game.yaw)
};
+
+ // Use a stable world-up vector and apply lean roll
Vector3 up = { 0, 1, 0 };
up = Vector3RotateByAxisAngle(up, forward, leanAngle);
game.camera.up = up;
- game.camera.target = Vector3Add(game.camera.position, forward);
+ // Use a longer target distance for better precision in the projection matrix
+ game.camera.target = Vector3Add(game.camera.position, Vector3Scale(forward, 20.0f));
// Calculate horizontal speed for UI
if (dt > 0) {