Made invincibility sparkle a particle effect
authorChristoph Sommer <mail@christoph-sommer.de>
Mon, 3 Jul 2006 23:50:33 +0000 (23:50 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Mon, 3 Jul 2006 23:50:33 +0000 (23:50 +0000)
SVN-Revision: 3864

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

diff --git a/data/images/objects/particles/sparkle-0.png b/data/images/objects/particles/sparkle-0.png
new file mode 100644 (file)
index 0000000..d4bfed4
Binary files /dev/null and b/data/images/objects/particles/sparkle-0.png differ
diff --git a/data/images/objects/particles/sparkle-1.png b/data/images/objects/particles/sparkle-1.png
new file mode 100644 (file)
index 0000000..d6e3b33
Binary files /dev/null and b/data/images/objects/particles/sparkle-1.png differ
diff --git a/data/images/objects/particles/sparkle.sprite b/data/images/objects/particles/sparkle.sprite
new file mode 100644 (file)
index 0000000..701a3a9
--- /dev/null
@@ -0,0 +1,20 @@
+(supertux-sprite
+  (action
+    (name "small")
+    (images 
+      "sparkle-0.png"
+      "sparkle-1.png"
+      "sparkle-0.png"
+    )
+  )
+  (action
+    (name "medium")
+    (images 
+      "sparkle-0.png"
+      "sparkle-1.png"
+      "sparkle-0.png"
+      "sparkle-1.png"
+      "sparkle-0.png"
+    )
+  )
+)
index 3c23106..6e04514 100644 (file)
@@ -312,6 +312,23 @@ 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 (systemRandom.rand(0, 2) == 0) {
+      float px = systemRandom.randf(bbox.p1.x+0, bbox.p2.x-0);
+      float py = systemRandom.randf(bbox.p1.y+0, bbox.p2.y-0);
+      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));
+    }
+  } 
+
 }
 
 bool
@@ -858,17 +875,6 @@ Player::draw(DrawingContext& context)
   else
     tux_body->draw(context, get_pos(), layer);
 
-  // Draw blinking star overlay
-  if (invincible_timer.started() &&
-     (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING
-      || size_t(game_time*20)%2)
-     && !dying)
-  {
-    if (!is_big() || duck)
-      smalltux_star->draw(context, get_pos(), layer + 5);
-    else
-      bigtux_star->draw(context, get_pos(), layer + 5);
-  } 
 }
 
 void