From 6a6a68001b57a9ae87b5712788cfd3485316264a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Gl=C3=A4=C3=9Fer?= Date: Sun, 14 Mar 2004 22:45:36 +0000 Subject: [PATCH] the NOT falling down a wall with low frame-rate bug is fixed. (and hopefully this bug didn't introduce other bugs) SVN-Revision: 225 --- src/collision.c | 24 +++++++++++++++--------- src/player.c | 4 ++-- src/special.c | 21 ++++++++++----------- src/special.h | 1 + 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/collision.c b/src/collision.c index a616f84c3..fbde783cd 100644 --- a/src/collision.c +++ b/src/collision.c @@ -89,7 +89,7 @@ int collision_object_map(base_type* pbase) int collision_swept_object_map(base_type* old, base_type* current) { int steps; /* Used to speed up the collision tests, by stepping every 16pixels in the path. */ - int h; + int h; float i; float lpath; /* Holds the longest path, which is either in X or Y direction. */ float xd,yd; /* Hold the smallest steps in X and Y directions. */ @@ -165,7 +165,6 @@ int collision_swept_object_map(base_type* old, base_type* current) if(collision_object_map(old)) { - switch(h) { case 1: @@ -193,15 +192,22 @@ int collision_swept_object_map(base_type* old, base_type* current) current->x = xt; if(!collision_object_map(current)) break; - current->x = temp; temp = current->y; current->y = yt; if(!collision_object_map(current)) - break; - - current->y = temp; + { + break; + } + else + { + current->y = temp; + while(!collision_object_map(current)) + current->y += yd; + current->y -= yd; + break; + } break; default: @@ -260,7 +266,7 @@ void collision_handler() } - + /* CO_BADGUY & CO_PLAYER check */ for(i = 0; i < num_bad_guys; ++i) { @@ -270,8 +276,8 @@ void collision_handler() { /* We have detected a collision and now call the collision functions of the collided objects. */ if (tux.previous_base.y < tux.base.y && - tux.previous_base.y + tux.previous_base.height < bad_guys[i].base.y + bad_guys[i].base.height/2 && - bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD) + tux.previous_base.y + tux.previous_base.height < bad_guys[i].base.y + bad_guys[i].base.height/2 && + bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD) { badguy_collision(&bad_guys[i], &tux, CO_PLAYER); } diff --git a/src/player.c b/src/player.c index ea629eb78..1f876f3f5 100644 --- a/src/player.c +++ b/src/player.c @@ -141,7 +141,7 @@ void player_action(player_type* pplayer) player_input(pplayer); /* Move tux: */ - + pplayer->previous_base = pplayer->base; pplayer->base.x += pplayer->base.xm * frame_ratio; @@ -362,7 +362,7 @@ void player_handle_horizontal_input(player_type *pplayer, int dir) { if ((dir ? (pplayer->base.xm < -SKID_XM) : (pplayer->base.xm > SKID_XM)) && !timer_started(&pplayer->skidding_timer) && - pplayer->dir == !dir) + pplayer->dir == !dir && player_on_ground(pplayer)) { timer_start(&pplayer->skidding_timer, SKID_TIME); diff --git a/src/special.c b/src/special.c index ce0193acd..8121f7e62 100644 --- a/src/special.c +++ b/src/special.c @@ -48,6 +48,7 @@ void bullet_init(bullet_type* pbullet, float x, float y, float xm, int dir) pbullet->base.y = y; pbullet->base.ym = BULLET_STARTING_YM; + pbullet->old_base = pbullet->base; } void bullet_action(bullet_type* pbullet) @@ -57,24 +58,22 @@ void bullet_action(bullet_type* pbullet) pbullet->base.x = pbullet->base.x + pbullet->base.xm * frame_ratio; pbullet->base.y = pbullet->base.y + pbullet->base.ym * frame_ratio; - if (issolid(pbullet->base.x, pbullet->base.y)) + collision_swept_object_map(&pbullet->old_base,&pbullet->base); + + if (issolid(pbullet->base.x, pbullet->base.y + 4) || issolid(pbullet->base.x, pbullet->base.y)) { - if (issolid(pbullet->base.x, pbullet->base.y - pbullet->base.ym)) - pbullet->base.alive = NO; - else - { - if (pbullet->base.ym >= 0) - { - pbullet->base.y = (int)(pbullet->base.y / 32) * 32 - 8; - } pbullet->base.ym = -pbullet->base.ym; - } + pbullet->base.y = (int)(pbullet->base.y / 32) * 32; } pbullet->base.ym = pbullet->base.ym + GRAVITY; if (pbullet->base.x < scroll_x || - pbullet->base.x > scroll_x + screen->w) + pbullet->base.x > scroll_x + screen->w || + pbullet->base.y < 0 || + pbullet->base.y > screen->h || + issolid(pbullet->base.x + 4, pbullet->base.y + 2) || + issolid(pbullet->base.x, pbullet->base.y + 2)) { pbullet->base.alive = NO; } diff --git a/src/special.h b/src/special.h index 596fe1a85..379979dc2 100644 --- a/src/special.h +++ b/src/special.h @@ -42,6 +42,7 @@ upgrade_type; typedef struct bullet_type { base_type base; + base_type old_base; } bullet_type; -- 2.11.0