aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-06-24 20:52:13 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-06-24 20:52:13 +0000
commitd59df6ab625af566cf7efb44f374c95c48c809a5 (patch)
tree2ca8944f6dd816eb24483847abe787daf3a8d1de
parent3fee94ac188612f989e106fbe19e37ddd5701ded (diff)
Stop horizontal motion when landed
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@109 84d2e878-0bd5-11dd-ad15-13eda11d74c5
-rw-r--r--src/physics.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/physics.c b/src/physics.c
index a29616e..799359d 100644
--- a/src/physics.c
+++ b/src/physics.c
@@ -315,10 +315,12 @@ static void physics_process(ModelInstance *obj, Uint32 dt, Game *game) {
}
/* Take a step */
- obj->x += obj->vx * dt;
- obj->y += obj->vy * dt;
- obj->z += obj->vz * dt;
- obj->yaw += obj->yawspeed * dt;
+ if ( !obj->landed ) {
+ obj->x += obj->vx * dt;
+ obj->y += obj->vy * dt;
+ obj->z += obj->vz * dt;
+ obj->yaw += obj->yawspeed * dt;
+ }
if ( obj->yaw < -M_PI ) obj->yaw += 2*M_PI;
if ( obj->yaw > M_PI ) obj->yaw -= 2*M_PI;
@@ -339,17 +341,17 @@ void physics_step(Game *game, Uint32 t) {
game->lander->landed = 0;
}
}
- if ( game->forward ) {
+ if ( game->forward && !game->lander->landed ) {
game->lander->vx += sinf(game->lander->yaw) * FTHRUST * dt;
game->lander->vy += cosf(game->lander->yaw) * FTHRUST * dt;
- } else if ( game->reverse ) {
+ } else if ( game->reverse && !game->lander->landed ) {
game->lander->vx -= sinf(game->lander->yaw) * FTHRUST * dt;
game->lander->vy -= cosf(game->lander->yaw) * FTHRUST * dt;
}
- if ( game->turn_left ) {
+ if ( game->turn_left && !game->lander->landed ) {
game->lander->yawspeed -= YAWTHRUST * dt; /* -ve yaw is "left" */
}
- if ( game->turn_right ) {
+ if ( game->turn_right && !game->lander->landed ) {
game->lander->yawspeed += YAWTHRUST *dt; /* +ve yaw is "right" */
}