From: Tobias Gläßer Date: Sun, 14 Mar 2004 15:39:54 +0000 (+0000) Subject: bad_guy vs. player collision fixes. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9c42b027236d7d66871181a1668a25205db8e881;p=supertux.git bad_guy vs. player collision fixes. SVN-Revision: 215 --- diff --git a/src/badguy.c b/src/badguy.c index ad763e76a..c6b47727b 100644 --- a/src/badguy.c +++ b/src/badguy.c @@ -569,7 +569,9 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object) case CO_BADGUY: pbad_c = (bad_guy_type*) p_c_object; if (pbad->mode == NORMAL) - pbad->dir = !pbad->dir; + { + /* do nothing */ + } else { /* We're in kick mode, kill the other guy: */ @@ -592,6 +594,7 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object) timer_start(&pbad->timer,4000); physic_set_state(&pplayer_c->vphysic,PH_VT); physic_set_start_vy(&pplayer_c->vphysic,2.); + pplayer_c->base.y = pbad->base.y - pplayer_c->base.height; add_score(pbad->base.x - scroll_x, pbad->base.y, 50 * score_multiplier); @@ -613,6 +616,7 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object) physic_set_state(&pplayer_c->vphysic,PH_VT); physic_set_start_vy(&pplayer_c->vphysic,2.); + pplayer_c->base.y = pbad->base.y - pplayer_c->base.height; } else if (pbad->mode == FLAT) { @@ -632,7 +636,8 @@ void badguy_collision(bad_guy_type* pbad, void *p_c_object, int c_object) physic_set_state(&pplayer_c->vphysic,PH_VT); physic_set_start_vy(&pplayer_c->vphysic,2.); - + pplayer_c->base.y = pbad->base.y - pplayer_c->base.height; + add_score(pbad->base.x - scroll_x, pbad->base.y, 25 * score_multiplier); diff --git a/src/collision.c b/src/collision.c index e3c044999..a616f84c3 100644 --- a/src/collision.c +++ b/src/collision.c @@ -259,6 +259,8 @@ void collision_handler() } } + + /* CO_BADGUY & CO_PLAYER check */ for(i = 0; i < num_bad_guys; ++i) { @@ -267,7 +269,9 @@ void collision_handler() if(bad_guys[i].dying == NO && rectcollision_offset(&bad_guys[i].base,&tux.base,0,0) == YES ) { /* We have detected a collision and now call the collision functions of the collided objects. */ - if (tux.base.y + tux.base.height < bad_guys[i].base.y + 8 > 0 && bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD) + 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) { badguy_collision(&bad_guys[i], &tux, CO_PLAYER); } diff --git a/src/gameloop.c b/src/gameloop.c index b41f7a404..3eddc5ea7 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -710,7 +710,7 @@ int gameloop(char * subset, int levelnb, int mode) } if(debug_mode && debug_fps == YES) - SDL_Delay(160); + SDL_Delay(50); /*Draw the current scene to the screen */ /*If the machine running the game is too slow diff --git a/src/player.c b/src/player.c index bd01d323f..ea629eb78 100644 --- a/src/player.c +++ b/src/player.c @@ -141,6 +141,8 @@ void player_action(player_type* pplayer) player_input(pplayer); /* Move tux: */ + + pplayer->previous_base = pplayer->base; pplayer->base.x += pplayer->base.xm * frame_ratio; pplayer->base.y += pplayer->base.ym * frame_ratio; diff --git a/src/player.h b/src/player.h index 80fc73711..36b678ecc 100644 --- a/src/player.h +++ b/src/player.h @@ -77,6 +77,7 @@ typedef struct player_type int lives; base_type base; base_type old_base; + base_type previous_base; timer_type invincible_timer; timer_type skidding_timer; timer_type safe_timer;