From ebe6082ada46c5de058e2154c7d55eef7a39cf6e Mon Sep 17 00:00:00 2001 From: Wolfgang Becker Date: Sat, 15 Jul 2006 15:19:10 +0000 Subject: [PATCH] Portable and fixed trampoline. SVN-Revision: 4020 --- ...trampoline_red.sprite => trampoline_fix.sprite} | 0 data/levels/test/trampoline.stl | 6 ++---- src/object/trampoline.cpp | 25 ++++++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) rename data/images/objects/trampoline/{trampoline_red.sprite => trampoline_fix.sprite} (100%) diff --git a/data/images/objects/trampoline/trampoline_red.sprite b/data/images/objects/trampoline/trampoline_fix.sprite similarity index 100% rename from data/images/objects/trampoline/trampoline_red.sprite rename to data/images/objects/trampoline/trampoline_fix.sprite 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 -- 2.11.0