From: Wolfgang Becker Date: Thu, 6 Jul 2006 00:22:56 +0000 (+0000) Subject: Mr. Bomb now supports custom sprites. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=fdba1d4b1561c55309aee67d6e9a5b778cf21299;p=supertux.git Mr. Bomb now supports custom sprites. SVN-Revision: 3911 --- diff --git a/data/images/creatures/mr_bomb/mr_bomb.sprite b/data/images/creatures/mr_bomb/mr_bomb.sprite index 4ae2fb5c6..84c55874d 100644 --- a/data/images/creatures/mr_bomb/mr_bomb.sprite +++ b/data/images/creatures/mr_bomb/mr_bomb.sprite @@ -23,5 +23,24 @@ (name "iced-right") (hitbox 7 12 31.8 31.8) (mirror-action "iced-left")) -) + (action + (name "ticking-left") + (fps 2.0) + (hitbox 3 8 31.8 31.8) + (images "exploding-left-0.png" + "exploding-left-1.png")) + + (action + (name "ticking-right") + (fps 2.0) + (hitbox 10 8 31.8 31.8) + (mirror-action "ticking-left")) + + (action + (name "explosion") + (fps 15.0) + (hitbox 32 32 31.8 31.8) + (images "explosion-0.png" + "explosion-1.png")) +) diff --git a/data/images/creatures/mr_cherry/mr_cherry.sprite b/data/images/creatures/mr_cherry/mr_cherry.sprite index b5ed16b3a..d1e54818d 100644 --- a/data/images/creatures/mr_cherry/mr_cherry.sprite +++ b/data/images/creatures/mr_cherry/mr_cherry.sprite @@ -17,4 +17,32 @@ (hitbox 7 21 30 34) (mirror-action "left")) + (action + (name "ticking-left") + (fps 4.0) + (hitbox 3 21 30 34) + (images cherrybomb_hit_1.png +cherrybomb_hit_2.png +cherrybomb_hit_3.png +cherrybomb_hit_4.png +cherrybomb_hit_5.png +)) + + (action + (name "ticking-right") + (fps 4.0) + (hitbox 7 21 30 34) + (mirror-action "ticking-left")) + + (action + (name "explosion") + (fps 5.0) + (hitbox 13 12 44 48) + (images sparkle-1.png +sparkle-2.png +sparkle-3.png +sparkle-4.png +sparkle-5.png +)) ) + diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index 41351590d..045953196 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -23,8 +23,8 @@ #include "random_generator.hpp" #include "object/sprite_particle.hpp" -Bomb::Bomb(const Vector& pos, Direction dir) - : BadGuy(pos, dir, "images/creatures/mr_cherry/cherry.sprite") +Bomb::Bomb(const Vector& pos, Direction dir, std::string custom_sprite /*= "images/creatures/mr_cherry/cherry.sprite"*/ ) + : BadGuy( pos, dir, custom_sprite ) { state = STATE_TICKING; set_action(dir == LEFT ? "ticking-left" : "ticking-right", 1); diff --git a/src/badguy/bomb.hpp b/src/badguy/bomb.hpp index 1bc4cb0d2..94d7159ef 100644 --- a/src/badguy/bomb.hpp +++ b/src/badguy/bomb.hpp @@ -25,7 +25,7 @@ class Bomb : public BadGuy { public: - Bomb(const Vector& pos, Direction dir); + Bomb(const Vector& pos, Direction dir, std::string custom_sprite = "images/creatures/mr_cherry/cherry.sprite" ); Bomb(const Bomb& bomb); void write(lisp::Writer& writer); diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index 80d4c5447..6c7c6f9d6 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -21,14 +21,27 @@ #include "mrbomb.hpp" #include "bomb.hpp" +#include "sprite/sprite_manager.hpp" static const float WALKSPEED = 80; MrBomb::MrBomb(const lisp::Lisp& reader) : BadGuy(reader, "images/creatures/mr_cherry/mr_cherry.sprite") { + //Check if we need another sprite + if( !reader.get( "sprite", sprite_name ) ){ + return; + } + if( sprite_name == "" ){ + sprite_name = "images/creatures/mr_cherry/mr_cherry.sprite"; + return; + } + //Replace sprite + sprite = sprite_manager->create( sprite_name ); + bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); } +/* MrBomb created by a despencer always gets default sprite atm.*/ MrBomb::MrBomb(const Vector& pos, Direction d) : BadGuy(pos, d, "images/creatures/mr_cherry/mr_cherry.sprite") { @@ -69,7 +82,7 @@ bool MrBomb::collision_squished(Player& player) { remove_me(); - Sector::current()->add_object(new Bomb(get_pos(), dir)); + Sector::current()->add_object(new Bomb(get_pos(), dir, sprite_name )); kill_squished(player); return true; } @@ -104,7 +117,7 @@ void MrBomb::kill_fall() { remove_me(); - Bomb* bomb = new Bomb(get_pos(), dir); + Bomb* bomb = new Bomb(get_pos(), dir, sprite_name ); Sector::current()->add_object(bomb); bomb->explode(); }