From: Christoph Sommer Date: Mon, 3 Jul 2006 23:50:33 +0000 (+0000) Subject: Made invincibility sparkle a particle effect X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e6a77f812ba40e831e9c1048f8c39a9be50eda37;p=supertux.git Made invincibility sparkle a particle effect SVN-Revision: 3864 --- diff --git a/data/images/objects/particles/sparkle-0.png b/data/images/objects/particles/sparkle-0.png new file mode 100644 index 000000000..d4bfed475 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 index 000000000..d6e3b3342 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 index 000000000..701a3a9e8 --- /dev/null +++ b/data/images/objects/particles/sparkle.sprite @@ -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" + ) + ) +) diff --git a/src/object/player.cpp b/src/object/player.cpp index 3c2310633..6e04514a3 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -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