Portable and fixed trampoline.
authorWolfgang Becker <uafr@gmx.de>
Sat, 15 Jul 2006 15:19:10 +0000 (15:19 +0000)
committerWolfgang Becker <uafr@gmx.de>
Sat, 15 Jul 2006 15:19:10 +0000 (15:19 +0000)
SVN-Revision: 4020

data/images/objects/trampoline/trampoline_fix.sprite [new file with mode: 0644]
data/images/objects/trampoline/trampoline_red.sprite [deleted file]
data/levels/test/trampoline.stl
src/object/trampoline.cpp

diff --git a/data/images/objects/trampoline/trampoline_fix.sprite b/data/images/objects/trampoline/trampoline_fix.sprite
new file mode 100644 (file)
index 0000000..69c9ac9
--- /dev/null
@@ -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 (file)
index 69c9ac9..0000000
+++ /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"
-    )
-  )
-)
index 23ccc54..c49f1c0 100644 (file)
     (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)
     )
   )
 )
index 8f742ee..9e1c351 100644 (file)
@@ -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<Player*> (&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