Made SpriteParticle's action configurable
authorChristoph Sommer <mail@christoph-sommer.de>
Wed, 28 Jun 2006 23:45:55 +0000 (23:45 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Wed, 28 Jun 2006 23:45:55 +0000 (23:45 +0000)
SVN-Revision: 3802

data/images/objects/particles/firetux-helmet.sprite
data/images/objects/particles/smoke.sprite
src/badguy/flyingsnowball.cpp
src/object/candle.cpp
src/object/player.cpp
src/object/sprite_particle.cpp
src/object/sprite_particle.hpp

index 000d9df..1b79855 100644 (file)
@@ -1,8 +1,14 @@
 (supertux-sprite
  (action
+  (name "right")
   (fps 1)
   (images 
     "firetux-helmet.png"
   )
  )
+ (action
+  (name "left")
+  (fps 1)
+  (mirror-action "right")
+ )
 )
index 30fe859..fdce4b5 100644 (file)
@@ -1,5 +1,6 @@
 (supertux-sprite
  (action
+  (name "default")
   (images 
     "smoke-1.png"
     "smoke-2.png"
index 59b10f3..12dfefc 100644 (file)
@@ -121,7 +121,7 @@ FlyingSnowBall::active_update(float elapsed_time)
     Vector ppos = bbox.get_middle();
     Vector pspeed = Vector(systemRandom.randf(-10, 10), 150);
     Vector paccel = Vector(0,0);
-    Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1));
+    Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1));
     puff_timer.start(systemRandom.randf(PUFF_INTERVAL_MIN, PUFF_INTERVAL_MAX));
   }
 }
index 4ac3010..e11bcb6 100644 (file)
@@ -66,7 +66,7 @@ Candle::puff_smoke()
   Vector ppos = bbox.get_middle();
   Vector pspeed = Vector(0, -150);
   Vector paccel = Vector(0,0);
-  Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
+  Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
 }
 
 bool
index fc659bf..29390d9 100644 (file)
@@ -695,7 +695,8 @@ Player::set_bonus(BonusType type, bool animate)
       Vector ppos = Vector((bbox.p1.x + bbox.p2.x) / 2, bbox.p1.y);
       Vector pspeed = Vector(((dir==LEFT) ? +100 : -100), -300);
       Vector paccel = Vector(0, 1000);
-      Sector::current()->add_object(new SpriteParticle("images/objects/particles/firetux-helmet.sprite", ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS+1));
+      std::string action = (dir==LEFT)?"left":"right";
+      Sector::current()->add_object(new SpriteParticle("images/objects/particles/firetux-helmet.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1));
     }
     player_status->max_fire_bullets = 0;
     player_status->max_ice_bullets = 0;
index 9faab9d..2dfee79 100644 (file)
@@ -1,4 +1,4 @@
-//  $Id: rainsplash.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//  $Id$
 //
 //  SuperTux
 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 #include "main.hpp"
 #include "log.hpp"
 
-SpriteParticle::SpriteParticle(std::string sprite_name, Vector position, AnchorPoint anchor, Vector velocity, Vector acceleration, int drawing_layer) 
+SpriteParticle::SpriteParticle(std::string sprite_name, std::string action, Vector position, AnchorPoint anchor, Vector velocity, Vector acceleration, int drawing_layer) 
        : position(position), velocity(velocity), acceleration(acceleration), drawing_layer(drawing_layer)
 {
   sprite = sprite_manager->create(sprite_name);
   if (!sprite) throw std::runtime_error("Could not load sprite "+sprite_name);
-  sprite->set_animation_loops(1);
+  sprite->set_action(action, 1);
 
   this->position -= get_anchor_pos(sprite->get_current_hitbox(), anchor);
 }
index 786b4a2..a09b049 100644 (file)
@@ -1,4 +1,4 @@
-//  $Id: rainsplash.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//  $Id$
 //
 //  SuperTux
 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
@@ -33,7 +33,7 @@
 class SpriteParticle : public GameObject
 {
 public:
-  SpriteParticle(std::string sprite_name, Vector position, AnchorPoint anchor, Vector velocity, Vector acceleration, int drawing_layer = LAYER_OBJECTS-1);
+  SpriteParticle(std::string sprite_name, std::string action, Vector position, AnchorPoint anchor, Vector velocity, Vector acceleration, int drawing_layer = LAYER_OBJECTS-1);
   ~SpriteParticle();
 protected:  
   virtual void hit(Player& player);