- if( !on_ground ){
- return FORCE_MOVE;
- }
- Player* player = dynamic_cast<Player*> (&other);
- if ( player ) {
- 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;
+ if(on_ground) {
+ Player* player = dynamic_cast<Player*> (&other);
+ //Trampoline works for player
+ if(player) {
+ 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;
+ }
+ }
+ WalkingBadguy* walking_badguy = dynamic_cast<WalkingBadguy*> (&other);
+ //Trampoline also works for WalkingBadguy
+ if(walking_badguy) {
+ 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;