From da2a51a138aaa81560c6541b411aa3086ad21bca Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Thu, 6 Jul 2006 14:28:39 +0000 Subject: [PATCH] Made SpriteParticle work around possible bug in Sprite::set_action. / 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 | Bin 0 -> 397 bytes data/images/objects/particles/sparkle-dark-1.png | Bin 0 -> 485 bytes data/images/objects/particles/sparkle.sprite | 8 ++++++++ src/object/player.cpp | 17 ++++++++++++----- src/object/sprite_particle.cpp | 1 + 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 data/images/objects/particles/sparkle-dark-0.png create mode 100644 data/images/objects/particles/sparkle-dark-1.png diff --git a/data/images/objects/particles/sparkle-dark-0.png b/data/images/objects/particles/sparkle-dark-0.png new file mode 100644 index 0000000000000000000000000000000000000000..badee1481894dcb019e054543f49869f7d5df98d GIT binary patch literal 397 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYYs>cdx@v7EBiHeHa;evbDxO@5ryiZZh11kLJ>EamTas2I+Lhr){0!Qnwhors|ka_pJ-ac@`&Z}ot zx7WuhOfh|JB{I?0V%C#&@9)Oyw`%{h&GDJAJ6iwR*)#fL8XeIKG-Eh#^b2khe!{q8 zV(LVnf4beK6SpbNJDGl9uMUIYjT1)S(m6$L-e>GTz*KRmj=P2-f0f$K-wC3*s=pcT zFcm*wjaW6y@458@@AC#Bu4`R=FD|nDz+=OZ-FfCozJ=qb#VbN5n5fEbV7j;U+;6{s zCawyn%9N_F?)q~=d+yU4ADPmgy_0kOwo>Q1`>~ShleQguE${QhZrT5H^$Si@_ggd0 m$!V7J2fG!%st*6d$G7rl_5^Neh6g~;GkCiCxvXWFU8GbZ8({Xk{QrNlj4iWF>9@00Bu!L_t(Y$L*B8OT<7B z#eb6z?jVZ7m7;d(Eb>nrTqhjZ`1jcef}Ln>Z>`PQSX!x&ki@ZhfgpF6#4jvvAk6OU z&c5uM*#{f@cjoSUKbaS-*qnWuhwdJ=zHr_CwE$-Jq@0iBEL{P=whJ@;9Z>O8oPY1 zcoX|FK%s)BKn>i>r-~Pv`*#4QKm}X_kMfn`1yHXla95j#tu{SZK?BiJ04J?B?GNDY zk(pI`p 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)); + } } } diff --git a/src/object/sprite_particle.cpp b/src/object/sprite_particle.cpp index 2dfee79ea..0babaf276 100644 --- a/src/object/sprite_particle.cpp +++ b/src/object/sprite_particle.cpp @@ -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); } -- 2.11.0