Made SpriteParticle work around possible bug in Sprite::set_action. /
authorChristoph Sommer <mail@christoph-sommer.de>
Thu, 6 Jul 2006 14:28:39 +0000 (14:28 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Thu, 6 Jul 2006 14:28:39 +0000 (14:28 +0000)
Invincibility sparkle mixes short/long sparkles to make trail a bit
fuzzy. /
When Invincibility wears off, sparkles darken.

SVN-Revision: 3919

data/images/objects/particles/sparkle-dark-0.png [new file with mode: 0644]
data/images/objects/particles/sparkle-dark-1.png [new file with mode: 0644]
data/images/objects/particles/sparkle.sprite
src/object/player.cpp
src/object/sprite_particle.cpp

diff --git a/data/images/objects/particles/sparkle-dark-0.png b/data/images/objects/particles/sparkle-dark-0.png
new file mode 100644 (file)
index 0000000..badee14
Binary files /dev/null and b/data/images/objects/particles/sparkle-dark-0.png differ
diff --git a/data/images/objects/particles/sparkle-dark-1.png b/data/images/objects/particles/sparkle-dark-1.png
new file mode 100644 (file)
index 0000000..67882e7
Binary files /dev/null and b/data/images/objects/particles/sparkle-dark-1.png differ
index 701a3a9..a240974 100644 (file)
@@ -8,6 +8,14 @@
     )
   )
   (action
+    (name "dark")
+    (images 
+      "sparkle-dark-0.png"
+      "sparkle-dark-1.png"
+      "sparkle-dark-0.png"
+    )
+  )
+  (action
     (name "medium")
     (images 
       "sparkle-0.png"
index b5d0239..23aaf33 100644 (file)
@@ -314,10 +314,7 @@ Player::update(float elapsed_time)
   on_ground_flag = false;
 
   // when invincible, spawn particles
-  if (invincible_timer.started() &&
-     (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING
-      || size_t(game_time*20)%2)
-     && !dying)
+  if (invincible_timer.started() && !dying)
   {
     if (systemRandom.rand(0, 2) == 0) {
       float px = systemRandom.randf(bbox.p1.x+0, bbox.p2.x-0);
@@ -325,7 +322,17 @@ Player::update(float elapsed_time)
       Vector ppos = Vector(px, py);
       Vector pspeed = Vector(0, 0);
       Vector paccel = Vector(0, 0);
-      Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "small", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
+      // draw bright sparkle when there is lots of time left, dark sparkle when invincibility is about to end
+      if (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING) {
+       // make every other a longer sparkle to make trail a bit fuzzy
+       if (size_t(game_time*20)%2) {
+         Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "small", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
+       } else {
+         Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "medium", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
+       }
+      } else {
+        Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "dark", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
+      }
     }
   } 
 
index 2dfee79..0babaf2 100644 (file)
@@ -31,6 +31,7 @@ SpriteParticle::SpriteParticle(std::string sprite_name, std::string action, Vect
   sprite = sprite_manager->create(sprite_name);
   if (!sprite) throw std::runtime_error("Could not load sprite "+sprite_name);
   sprite->set_action(action, 1);
+  sprite->set_animation_loops(1); //TODO: this is necessary because set_action will not set "loops" when "action" is the default action
 
   this->position -= get_anchor_pos(sprite->get_current_hitbox(), anchor);
 }