X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Ftrampoline.cpp;h=1f303f8c332fbd7ec698d2d4aa0cfe0e516e4c57;hb=75acd4b141f45e851a492f089aa9ad24a9552409;hp=4871cf6396f3c19b4b1ea2f75cd5a44ac93d85e0;hpb=3655d32f63f75b2af054ec68d4176e55a561ba96;p=supertux.git diff --git a/src/object/trampoline.cpp b/src/object/trampoline.cpp index 4871cf639..1f303f8c3 100644 --- a/src/object/trampoline.cpp +++ b/src/object/trampoline.cpp @@ -24,7 +24,9 @@ #include "player.hpp" #include "audio/sound_manager.hpp" #include "sprite/sprite_manager.hpp" +#include "sprite/sprite.hpp" #include "badguy/walking_badguy.hpp" +#include "control/controller.hpp" /* Trampoline will accelerate player to to VY_INITIAL, if * he jumps on it to VY_MIN. */ @@ -35,7 +37,7 @@ namespace { } Trampoline::Trampoline(const lisp::Lisp& lisp) - : Rock(lisp, "images/objects/trampoline/trampoline.sprite") + : Rock(lisp, "images/objects/trampoline/trampoline.sprite") { sound_manager->preload(TRAMPOLINE_SOUND); @@ -73,15 +75,15 @@ Trampoline::collision(GameObject& other, const CollisionHit& hit) float vy = player->physic.get_velocity_y(); //player is falling down on trampoline if(hit.top && vy >= 0) { - if(player->get_controller()->hold(Controller::JUMP)) { - vy = VY_MIN; - } else { - vy = VY_INITIAL; - } - player->physic.set_velocity_y(vy); - sound_manager->play(TRAMPOLINE_SOUND); - sprite->set_action("swinging", 1); - return FORCE_MOVE; + if(player->get_controller()->hold(Controller::JUMP)) { + vy = VY_MIN; + } else { + vy = VY_INITIAL; + } + player->physic.set_velocity_y(vy); + sound_manager->play(TRAMPOLINE_SOUND); + sprite->set_action("swinging", 1); + return FORCE_MOVE; } } WalkingBadguy* walking_badguy = dynamic_cast (&other); @@ -90,11 +92,11 @@ Trampoline::collision(GameObject& other, const CollisionHit& hit) float vy = walking_badguy->get_velocity_y(); //walking_badguy is falling down on trampoline if(hit.top && vy >= 0) { - vy = VY_INITIAL; - walking_badguy->set_velocity_y(vy); - sound_manager->play(TRAMPOLINE_SOUND); - sprite->set_action("swinging", 1); - return FORCE_MOVE; + vy = VY_INITIAL; + walking_badguy->set_velocity_y(vy); + sound_manager->play(TRAMPOLINE_SOUND); + sprite->set_action("swinging", 1); + return FORCE_MOVE; } } }