From: Wolfgang Becker Date: Sat, 15 Jul 2006 15:19:10 +0000 (+0000) Subject: Portable and fixed trampoline. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ebe6082ada46c5de058e2154c7d55eef7a39cf6e;p=supertux.git Portable and fixed trampoline. SVN-Revision: 4020 --- diff --git a/data/images/objects/trampoline/trampoline_fix.sprite b/data/images/objects/trampoline/trampoline_fix.sprite new file mode 100644 index 000000000..69c9ac9d6 --- /dev/null +++ b/data/images/objects/trampoline/trampoline_fix.sprite @@ -0,0 +1,15 @@ +(supertux-sprite + (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/data/images/objects/trampoline/trampoline_red.sprite b/data/images/objects/trampoline/trampoline_red.sprite deleted file mode 100644 index 69c9ac9d6..000000000 --- a/data/images/objects/trampoline/trampoline_red.sprite +++ /dev/null @@ -1,15 +0,0 @@ -(supertux-sprite - (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/data/levels/test/trampoline.stl b/data/levels/test/trampoline.stl index 23ccc543b..c49f1c098 100644 --- a/data/levels/test/trampoline.stl +++ b/data/levels/test/trampoline.stl @@ -49,22 +49,20 @@ (trampoline (x 352) (y 1056) - (sprite "") ) (trampoline (x 320) (y 1056) - (sprite "images/objects/trampoline/trampoline_red.sprite") + (portable #f) ) (trampoline (x 288) (y 1056) - (sprite "") ) (trampoline (x 256) (y 1056) - (sprite "images/objects/trampoline/trampoline_red.sprite") + (portable #f) ) ) ) diff --git a/src/object/trampoline.cpp b/src/object/trampoline.cpp index 8f742ee5a..9e1c351d9 100644 --- a/src/object/trampoline.cpp +++ b/src/object/trampoline.cpp @@ -43,17 +43,17 @@ Trampoline::Trampoline(const lisp::Lisp& lisp) physic.enable_gravity(true); on_ground = false; - //Check if we need another sprite - if( !lisp.get( "sprite", sprite_name ) ){ - return; - } - if( sprite_name == "" ){ - sprite_name = "images/objects/trampoline/trampoline.sprite"; - return; + bool portable = true; + //Check if this trampoline is not portable + if( lisp.get( "portable", portable ) ){ + if( !portable ){ + flags ^= FLAG_PORTABLE; + //we need another sprite + sprite_name = "images/objects/trampoline/trampoline_fix.sprite"; + sprite = sprite_manager->create( sprite_name ); + sprite->set_action("normal"); + } } - //Replace sprite - sprite = sprite_manager->create( sprite_name ); - sprite->set_action("normal"); } void @@ -69,6 +69,10 @@ Trampoline::update( float elapsed_time ){ HitResponse Trampoline::collision(GameObject& other, const CollisionHit& hit ) { + //Tramponine has to be on ground to work. + if( !on_ground ){ + return FORCE_MOVE; + } Player* player = dynamic_cast (&other); if ( player ) { float vy = player->physic.get_velocity_y(); @@ -81,7 +85,6 @@ Trampoline::collision(GameObject& other, const CollisionHit& hit ) } player->physic.set_velocity_y( vy ); - //printf("nachher velocity y = %f\n", player->physic.get_velocity_y()); sound_manager->play( TRAMPOLINE_SOUND ); sprite->set_action("swinging", 1); //sprite->set_animation_loops(2); //TODO: 2 is not working