- Player* player = dynamic_cast<Player*> (&other);
- if ( player ) {
- float vy = player->physic.get_velocity_y();
- //player is falling down on trampolin holding "jump"
- if( hit.top && vy > 0 && player->get_controller()->hold( Controller::JUMP )){
- vy *= VY_FACTOR;
- if( vy < VY_MIN ){
- vy = VY_MIN;
+
+ //Tramponine has to be on ground to work.
+ 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;