From 3e89eb527d5f3bca2cb8cd219784048764a148f5 Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Wed, 28 Jun 2006 23:45:55 +0000 Subject: [PATCH] Made SpriteParticle's action configurable SVN-Revision: 3802 --- data/images/objects/particles/firetux-helmet.sprite | 6 ++++++ data/images/objects/particles/smoke.sprite | 1 + src/badguy/flyingsnowball.cpp | 2 +- src/object/candle.cpp | 2 +- src/object/player.cpp | 3 ++- src/object/sprite_particle.cpp | 6 +++--- src/object/sprite_particle.hpp | 4 ++-- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/data/images/objects/particles/firetux-helmet.sprite b/data/images/objects/particles/firetux-helmet.sprite index 000d9df25..1b79855a1 100644 --- a/data/images/objects/particles/firetux-helmet.sprite +++ b/data/images/objects/particles/firetux-helmet.sprite @@ -1,8 +1,14 @@ (supertux-sprite (action + (name "right") (fps 1) (images "firetux-helmet.png" ) ) + (action + (name "left") + (fps 1) + (mirror-action "right") + ) ) diff --git a/data/images/objects/particles/smoke.sprite b/data/images/objects/particles/smoke.sprite index 30fe8597b..fdce4b574 100644 --- a/data/images/objects/particles/smoke.sprite +++ b/data/images/objects/particles/smoke.sprite @@ -1,5 +1,6 @@ (supertux-sprite (action + (name "default") (images "smoke-1.png" "smoke-2.png" diff --git a/src/badguy/flyingsnowball.cpp b/src/badguy/flyingsnowball.cpp index 59b10f321..12dfefc80 100644 --- a/src/badguy/flyingsnowball.cpp +++ b/src/badguy/flyingsnowball.cpp @@ -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)); } } diff --git a/src/object/candle.cpp b/src/object/candle.cpp index 4ac3010df..e11bcb61b 100644 --- a/src/object/candle.cpp +++ b/src/object/candle.cpp @@ -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 diff --git a/src/object/player.cpp b/src/object/player.cpp index fc659bf54..29390d994 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -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; diff --git a/src/object/sprite_particle.cpp b/src/object/sprite_particle.cpp index 9faab9dda..2dfee79ea 100644 --- a/src/object/sprite_particle.cpp +++ b/src/object/sprite_particle.cpp @@ -1,4 +1,4 @@ -// $Id: rainsplash.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $ +// $Id$ // // SuperTux // Copyright (C) 2006 Matthias Braun @@ -25,12 +25,12 @@ #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); } diff --git a/src/object/sprite_particle.hpp b/src/object/sprite_particle.hpp index 786b4a216..a09b04998 100644 --- a/src/object/sprite_particle.hpp +++ b/src/object/sprite_particle.hpp @@ -1,4 +1,4 @@ -// $Id: rainsplash.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $ +// $Id$ // // SuperTux // Copyright (C) 2006 Matthias Braun @@ -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); -- 2.11.0