aboutsummaryrefslogtreecommitdiff
path: root/src/physics.c
diff options
context:
space:
mode:
authortaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-18 00:01:41 +0000
committertaw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-18 00:01:41 +0000
commit22e44824699c214a91ae69dbf40d5ae336fa7441 (patch)
treee339c0feb408526e6dd4cbedff7fe474cdcfad42 /src/physics.c
parent4f1c5d440d76dfa13fc78f385912dcde8d5495fa (diff)
Tidy up
Only 'recharge' when landed on a platform git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@141 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src/physics.c')
-rw-r--r--src/physics.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/physics.c b/src/physics.c
index 8299704..5b9c641 100644
--- a/src/physics.c
+++ b/src/physics.c
@@ -88,7 +88,7 @@ int physics_point_is_inside_hull(double cx, double cy, double cz, double *fvert,
}
int physics_will_collide_face(double sx, double sy, double sz, double vx, double vy, double vz,
- double nx, double ny, double nz, double *fvert, int nfvert, Uint32 dt,
+ double nx, double ny, double nz, double *fvert, int nfvert, double dt,
double *ttc) {
double px, py, pz;
@@ -124,7 +124,7 @@ int physics_will_collide_face(double sx, double sy, double sz, double vx, double
}
/* Check for collision with all faces in a primitive */
-static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *other, Uint32 dt, int a,
+static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *other, double dt, int a,
double sx, double sy, double sz, CollisionSpec *coll) {
int found = 0;
@@ -167,6 +167,7 @@ static int physics_check_collide_all_faces(ModelInstance *obj, ModelInstance *ot
coll->cx = obj->x + ttc*obj->vx;
coll->cy = obj->y + ttc*obj->vy;
coll->cz = obj->z + ttc*obj->vz;
+ coll->name = other->model->name;
found = 1;
}
@@ -289,6 +290,7 @@ static void physics_process(ModelInstance *obj, Uint32 dt, Game *game) {
coll.ttc = +HUGE_VAL;
coll.nx = 0.0; coll.ny = 0.0; coll.nz = 0.0;
coll.cx = 0.0; coll.cy = 0.0; coll.cz = 0.0;
+ coll.name = NULL;
collided = physics_find_earliest_collision(obj, game, dt-sttc, &coll);
if ( collided ) {
@@ -302,18 +304,26 @@ static void physics_process(ModelInstance *obj, Uint32 dt, Game *game) {
/* Can we land here? */
if ( (coll.nx==0) && (coll.ny==0) && (coll.nz==1.0) ) {
+
/* Yes - land (already moved to this position */
obj->landed = 1;
obj->vx = 0.0;
obj->vy = 0.0;
obj->vz = 0.0;
obj->yawspeed = 0.0;
+
+ if ( strcmp(coll.name, "platform") == 0 ) {
+ obj->recharging = 1;
+ }
+
} else {
+
/* No - bounce */
audio_play(game->audio, "clang", 1.0, 0);
obj->vx = -obj->vx;
obj->vy = -obj->vy;
obj->vz = -obj->vz;
+
}
} else {
@@ -345,6 +355,7 @@ void physics_step(Game *game, Uint32 t) {
game->lander->vz += THRUST * dt;
game->fuel -= 0.0002;
game->lander->landed = 0;
+ game->lander->recharging = 0;
}
}
if ( game->forward && !game->lander->landed ) {