diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-06 16:57:20 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-08-06 16:57:20 +0000 |
commit | 51a0182adf818c30df20c95c4f5370b07fa8bcb0 (patch) | |
tree | ea338e98afdfd87eeb57df9781816524430ddcd2 /src | |
parent | 04e158dacb2f66331b7453a7bf0ab1ce5d41bdd8 (diff) |
Thrust control with mouse button
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@225 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -216,6 +216,8 @@ int main(int argc, char *argv[]) { while ( !finished ) { int mx, my; + Uint8 buttons; + int mouse_thrust = 0; /* Timer advances only when game is not paused */ if ( !game->paused ) { @@ -258,17 +260,22 @@ int main(int argc, char *argv[]) { break; } - SDL_GetMouseState(&mx, &my); + buttons = SDL_GetMouseState(&mx, &my); game->view_yaw = -(mx-cx)*vyaw_scale; game->view_angle = deg2rad(-20.0) + (my-cy)*vang_scale; if ( game->view_angle > deg2rad(89.0) ) game->view_angle = deg2rad(89.0); if ( game->view_angle < deg2rad(-89.0) ) game->view_angle = deg2rad(-89.0); - + if ( !game->thrusting && (buttons & SDL_BUTTON(1)) ) { + game->thrusting = 1; + mouse_thrust = 1; + } if ( !game->paused ) { physics_step(game, t); render_draw(game, t); } + if ( mouse_thrust ) game->thrusting = 0; + if ( gameopts.status_line ) { printf("%+7.4f %+7.4f %+7.4f %+5.1f deg %+7.5f %+7.5f %+7.5f %2i %2i %2i %3i fps\r", game->lander->x, game->lander->y, game->lander->z, |