X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fplayer.cpp;h=7fb22060530cd693b38fe23db24da29335295099;hb=63934f5f4c15f059c9b60499575870ebb7c923a0;hp=4f52d343a7e371c58a8c2afb4335330a34e28c14;hpb=74ab009aba10e7bed5ad9aa7e1217b7fb1518bf3;p=supertux.git diff --git a/src/player.cpp b/src/player.cpp index 4f52d343a..7fb220605 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -183,17 +183,27 @@ Player::action(double frame_ratio) previous_base = base; physic.apply(frame_ratio, base.x, base.y); - if(dying == DYING_NOT) { + if(dying == DYING_NOT) + { + base_type target = base; + collision_swept_object_map(&old_base, &base); + + // Don't accelerate Tux if he is running against a wall + if (target.x != base.x) + { + physic.set_velocity_x(0); + } + // special exception for cases where we're stuck under tiles after // being ducked. In this case we drift out if(!duck && on_ground() && old_base.x == base.x && old_base.y == base.y - && collision_object_map(&base)) { - base.x += frame_ratio * WALK_SPEED * (dir ? 1 : -1); - previous_base = old_base = base; + && collision_object_map(&base)) { + base.x += frame_ratio * WALK_SPEED * (dir ? 1 : -1); + previous_base = old_base = base; } keep_in_bounds(); - } + } if (dying == DYING_NOT) { @@ -273,10 +283,10 @@ Player::action(double frame_ratio) if (get_current_music() == HERRING_MUSIC && !invincible_timer.check()) { /* - no, we are no more invincible - or we were not in invincible mode - but are we in hurry ? - */ + no, we are no more invincible + or we were not in invincible mode + but are we in hurry ? + */ // FIXME: Move this to gamesession if (GameSession::current()->time_left.get_left() < TIME_WARNING) @@ -284,7 +294,7 @@ Player::action(double frame_ratio) /* yes, we are in hurry stop the herring_song, prepare to play the correct fast level_song ! - */ + */ set_current_music(HURRYUP_MUSIC); } else @@ -692,18 +702,18 @@ Player::collision(void* p_c_object, int c_object) /* Hurt player if he touches a badguy */ if (!pbad_c->dying && !dying && !safe_timer.started() && - pbad_c->mode != HELD) + pbad_c->mode != BadGuy::HELD) { - if (pbad_c->mode == FLAT && input.fire == DOWN) + if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN) { - pbad_c->mode = HELD; + pbad_c->mode = BadGuy::HELD; pbad_c->base.y-=8; } - else if (pbad_c->mode == FLAT) + else if (pbad_c->mode == BadGuy::FLAT) { // Don't get hurt if we're kicking a flat badguy! } - else if (pbad_c->mode == KICK) + else if (pbad_c->mode == BadGuy::KICK) { /* Hurt if you get hit by kicked laptop: */ if (!invincible_timer.started())