From: Matthias Braun Date: Sat, 15 Jul 2006 07:53:39 +0000 (+0000) Subject: fixed trampoline animation and made behaviour a bit more mario like X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e78e022eda375506f0e269b073fafd656e55ed66;p=supertux.git fixed trampoline animation and made behaviour a bit more mario like SVN-Revision: 4017 --- diff --git a/data/images/objects/trampoline/trampoline.sprite b/data/images/objects/trampoline/trampoline.sprite index ede16f97d..b71546edb 100644 --- a/data/images/objects/trampoline/trampoline.sprite +++ b/data/images/objects/trampoline/trampoline.sprite @@ -1,11 +1,14 @@ (supertux-sprite - (action - (name "normal") - (hitbox 0 0 0 0) - (images "trampoline1-0.png" - "trampoline1-1.png" - "trampoline1-2.png" - "trampoline1-3.png" - ) - ) + (action + (name "normal") + (hitbox 0 0 0 0) + (images "trampoline1-0.png") + ) + (action + (name "swinging") + (images "trampoline1-0.png" + "trampoline1-1.png" + "trampoline1-2.png" + "trampoline1-3.png") + ) ) diff --git a/data/images/objects/trampoline/trampoline_red.sprite b/data/images/objects/trampoline/trampoline_red.sprite index 948c47d25..69c9ac9d6 100644 --- a/data/images/objects/trampoline/trampoline_red.sprite +++ b/data/images/objects/trampoline/trampoline_red.sprite @@ -1,11 +1,15 @@ (supertux-sprite - (action - (name "normal") - (hitbox 0 0 0 0) - (images "trampoline2-0.png" - "trampoline2-1.png" - "trampoline2-2.png" - "trampoline2-3.png" - ) - ) + (action + (name "normal") + (hitbox 0 0 0 0) + (images "trampoline2-0.png") + ) + (action + (name "swinging") + (images "trampoline2-0.png" + "trampoline2-1.png" + "trampoline2-2.png" + "trampoline2-3.png" + ) + ) ) diff --git a/src/object/trampoline.cpp b/src/object/trampoline.cpp index 03ac4fc87..8f742ee5a 100644 --- a/src/object/trampoline.cpp +++ b/src/object/trampoline.cpp @@ -42,7 +42,6 @@ Trampoline::Trampoline(const lisp::Lisp& lisp) physic.set_velocity_y(0); physic.enable_gravity(true); on_ground = false; - sprite->set_animation_loops( 0 ); //Check if we need another sprite if( !lisp.get( "sprite", sprite_name ) ){ @@ -54,7 +53,7 @@ Trampoline::Trampoline(const lisp::Lisp& lisp) } //Replace sprite sprite = sprite_manager->create( sprite_name ); - sprite->set_animation_loops( 0 ); + sprite->set_action("normal"); } void @@ -62,6 +61,9 @@ Trampoline::update( float elapsed_time ){ if( !on_ground ){ movement = physic.get_movement(elapsed_time); } + if(sprite->animation_done()) { + sprite->set_action("normal"); + } } HitResponse @@ -71,19 +73,19 @@ Trampoline::collision(GameObject& other, const CollisionHit& hit ) 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; - } - if( vy > VY_INITIAL ){ - vy = VY_INITIAL; + 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 ); //printf("nachher velocity y = %f\n", player->physic.get_velocity_y()); sound_manager->play( TRAMPOLINE_SOUND ); - sprite->set_animation_loops( -1 ); //TODO: 2 is not working - return SOLID; + sprite->set_action("swinging", 1); + //sprite->set_animation_loops(2); //TODO: 2 is not working + return SOLID; } }