aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-08-06 16:57:20 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-08-06 16:57:20 +0000
commit51a0182adf818c30df20c95c4f5370b07fa8bcb0 (patch)
treeea338e98afdfd87eeb57df9781816524430ddcd2
parent04e158dacb2f66331b7453a7bf0ab1ce5d41bdd8 (diff)
Thrust control with mouse button
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@225 84d2e878-0bd5-11dd-ad15-13eda11d74c5
-rw-r--r--README1
-rw-r--r--src/main.c11
2 files changed, 10 insertions, 2 deletions
diff --git a/README b/README
index 18cfe84..35995f8 100644
--- a/README
+++ b/README
@@ -56,6 +56,7 @@ Controls
========
Space - thrust (upwards)
+ or: Mouse button 1 (usually the left button)
Left arrow - turn left
Right arrow - turn right
Up arrow - thrust forwards
diff --git a/src/main.c b/src/main.c
index 5a66638..2878c7f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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,