summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-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 );