summaryrefslogtreecommitdiff
path: root/src/game/player.cpp
diff options
context:
space:
mode:
authorKasullian <tomkasull@gmail.com>2025-09-10 12:08:59 -0400
committerKasullian <tomkasull@gmail.com>2025-09-10 12:08:59 -0400
commitae694bc0da98e45c5def20ac1d92f9d8aad65fd5 (patch)
treefec648ec2ee3c7ab44ad555c837653ade8e7ac34 /src/game/player.cpp
parente2366afb57d69f3952bbb4d1894d82293cd1cb9d (diff)
3d view mouse control
Diffstat (limited to 'src/game/player.cpp')
-rw-r--r--src/game/player.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/game/player.cpp b/src/game/player.cpp
index 87786df..993292c 100644
--- a/src/game/player.cpp
+++ b/src/game/player.cpp
@@ -34,18 +34,32 @@ void player_input( GAME_DATA* game, PLAYER* p ) {
F32* yaw = &p->rot.y;
VEC3* pos = &p->pos;
- if( input.keys[(U8)'a'] )
- *yaw -= 360.f * TICK_INTERVAL * 0.5f;
- if( input.keys[(U8)'d'] )
- *yaw += 360.f * TICK_INTERVAL * 0.5f;
-
- if( input.keys[SDL_SCANCODE_UP] ) {
- if( p->rot.x < 89.f )
- p->rot.x += 360.f * TICK_INTERVAL * 0.5f;
+ if( input.keys[SDL_SCANCODE_F1] ) {
+ input_capture_mouse( false );
}
- if( input.keys[SDL_SCANCODE_DOWN] ) {
- if( p->rot.x > -89.f )
- p->rot.x -= 360.f * TICK_INTERVAL * 0.5f;
+
+ if( input.mouse_captured ) {
+ *yaw += input.mouse.pos_delta.x * input.mouse_sensitivity;
+ p->rot.x -= input.mouse.pos_delta.y * input.mouse_sensitivity;
+
+ if( p->rot.x > 89.f ) p->rot.x = 89.f;
+ if( p->rot.x < -89.f ) p->rot.x = -89.f;
+ }
+
+ if( !input.mouse_captured ) {
+ if( input.keys[(U8)'a'] )
+ *yaw -= 360.f * TICK_INTERVAL * 0.5f;
+ if( input.keys[(U8)'d'] )
+ *yaw += 360.f * TICK_INTERVAL * 0.5f;
+
+ if( input.keys[SDL_SCANCODE_UP] ) {
+ if( p->rot.x < 89.f )
+ p->rot.x += 360.f * TICK_INTERVAL * 0.5f;
+ }
+ if( input.keys[SDL_SCANCODE_DOWN] ) {
+ if( p->rot.x > -89.f )
+ p->rot.x -= 360.f * TICK_INTERVAL * 0.5f;
+ }
}
*yaw = remainderf( *yaw, 360.f );