From: Ryan Flegel Date: Sun, 30 May 2004 23:00:00 +0000 (+0000) Subject: - butt jump now kills nearby badguys X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=04176f738ff4a45afd579dc07425e602e404ceea;p=supertux.git - butt jump now kills nearby badguys SVN-Revision: 1370 --- diff --git a/src/player.cpp b/src/player.cpp index 379257d04..df8571b11 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -467,22 +467,43 @@ Player::handle_vertical_input() /* In case the player has pressed Down while in a certain range of air, enable butt jump action */ if (input.down == DOWN && !butt_jump) - if(tiles_on_air(TILES_FOR_BUTTJUMP)) + if(tiles_on_air(TILES_FOR_BUTTJUMP) && jumping) butt_jump = true; /* When Down is not held anymore, disable butt jump */ if(butt_jump && input.down == UP) butt_jump = false; + // Do butt jump if (butt_jump && on_ground() && size == BIG) { - if(World::current()->trybreakbrick(base.x, base.y + base.height, false) - || World::current()->trybreakbrick( - base.x + base.width, base.y + base.height, false)) { - // make tux jumping a little bit again after breaking the bricks - physic.set_velocity_y(2); + butt_jump = false; + + // Break bricks beneath Tux + if(World::current()->trybreakbrick(base.x + 1, base.y + base.height, false) + || World::current()->trybreakbrick( + base.x + base.width - 1, base.y + base.height, false)) + { + physic.set_velocity_y(2); + butt_jump = true; + } + + // Kill nearby badguys + std::vector gameobjects = World::current()->gameobjects; + for (std::vector::iterator i = gameobjects.begin(); + i != gameobjects.end(); + i++) + { + BadGuy* badguy = dynamic_cast (*i); + if(badguy) + { + if (fabsf(base.x - badguy->base.x) < 300 && + fabsf(base.y - badguy->base.y) < 300 && + (issolid(badguy->base.x + 1, badguy->base.y + badguy->base.height) || + issolid(badguy->base.x + badguy->base.width - 1, badguy->base.y + badguy->base.height))) + badguy->kill_me(25); + } } -// butt_jump = false; // comment this, in case you won't to disable the continued use of buttjump } if ( (issolid(base.x + base.width / 2, base.y + base.height + 64) ||