From: Christoph Sommer Date: Wed, 13 Jun 2007 20:18:42 +0000 (+0000) Subject: Moved Explosion object to foreground, changed Mr. Rocket to use Explosion object... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b190b1597483fe76b98b6fcda1ba8f2d037dd8ed;p=supertux.git Moved Explosion object to foreground, changed Mr. Rocket to use Explosion object, too. Cleaned up code. SVN-Revision: 5105 --- diff --git a/data/images/creatures/mr_bomb/bomb.sprite b/data/images/creatures/mr_bomb/bomb.sprite index 7832f81fb..08d5873d7 100644 --- a/data/images/creatures/mr_bomb/bomb.sprite +++ b/data/images/creatures/mr_bomb/bomb.sprite @@ -13,11 +13,5 @@ (hitbox 10 8 31.8 31.8) (mirror-action "ticking-left")) - (action - (name "explosion") - (fps 8.0) - (hitbox 18 17 71 47) - (images "explosion-0.png" - "explosion-1.png")) ) diff --git a/data/images/creatures/mr_bomb/explosion-0.png b/data/images/creatures/mr_bomb/explosion-0.png deleted file mode 100644 index b4137ca69..000000000 Binary files a/data/images/creatures/mr_bomb/explosion-0.png and /dev/null differ diff --git a/data/images/creatures/mr_bomb/explosion-1.png b/data/images/creatures/mr_bomb/explosion-1.png deleted file mode 100644 index fef8c7779..000000000 Binary files a/data/images/creatures/mr_bomb/explosion-1.png and /dev/null differ diff --git a/data/images/creatures/mr_bomb/mr_bomb.sprite b/data/images/creatures/mr_bomb/mr_bomb.sprite index 287df502d..788833572 100644 --- a/data/images/creatures/mr_bomb/mr_bomb.sprite +++ b/data/images/creatures/mr_bomb/mr_bomb.sprite @@ -37,16 +37,4 @@ (hitbox 10 8 31.8 31.8) (mirror-action "ticking-left")) - (action - (name "explosion") - (fps 15.0) - (hitbox 18 17 71 47) - (images "explosion-0.png" - "explosion-1.png" -"explosion-0.png" - "explosion-1.png" -"explosion-0.png" - "explosion-1.png" -"explosion-0.png" - "explosion-1.png")) ) diff --git a/data/images/creatures/mr_rocket/explosion-0.png b/data/images/creatures/mr_rocket/explosion-0.png deleted file mode 100644 index 0c818331c..000000000 Binary files a/data/images/creatures/mr_rocket/explosion-0.png and /dev/null differ diff --git a/data/images/creatures/mr_rocket/explosion-1.png b/data/images/creatures/mr_rocket/explosion-1.png deleted file mode 100644 index d7f047d99..000000000 Binary files a/data/images/creatures/mr_rocket/explosion-1.png and /dev/null differ diff --git a/data/images/creatures/mr_rocket/explosion.sprite b/data/images/creatures/mr_rocket/explosion.sprite deleted file mode 100644 index 3d1a9c163..000000000 --- a/data/images/creatures/mr_rocket/explosion.sprite +++ /dev/null @@ -1,15 +0,0 @@ -(supertux-sprite - (action - (name "explosion-left") - (fps 15.0) - (hitbox 0 32 31.8 31.8) - (images "explosion-0.png" - "explosion-1.png") - ) - (action - (name "explosion-right") - (fps 15.0) - (hitbox 0 32 31.8 31.8) - (mirror-action "explosion-left") - ) -) diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index 38ec13b42..cbc96c0a0 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -21,7 +21,6 @@ #include "bomb.hpp" #include "random_generator.hpp" -#include "object/sprite_particle.hpp" #include "object/explosion.hpp" Bomb::Bomb(const Vector& pos, Direction dir, std::string custom_sprite /*= "images/creatures/mr_bomb/mr_bomb.sprite"*/ ) @@ -66,37 +65,23 @@ Bomb::collision_solid(const CollisionHit& hit) } HitResponse -Bomb::collision_player(Player& player, const CollisionHit& ) +Bomb::collision_player(Player& , const CollisionHit& ) { - if(state == STATE_EXPLODING) { - player.kill(false); - } return ABORT_MOVE; } HitResponse -Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& ) +Bomb::collision_badguy(BadGuy& , const CollisionHit& ) { - if(state == STATE_EXPLODING) - badguy.kill_fall(); return ABORT_MOVE; } void Bomb::active_update(float ) { - switch(state) { - case STATE_TICKING: - ticking->set_position(get_pos()); - if(sprite->animation_done()) { - explode(); - } - break; - case STATE_EXPLODING: - if(sprite->animation_done()) { - remove_me(); - } - break; + ticking->set_position(get_pos()); + if(sprite->animation_done()) { + explode(); } } @@ -115,6 +100,5 @@ Bomb::explode() void Bomb::kill_fall() { - if (state != STATE_EXPLODING) // we don't want it exploding again - explode(); + explode(); } diff --git a/src/badguy/bomb.hpp b/src/badguy/bomb.hpp index efce65357..e75a32f80 100644 --- a/src/badguy/bomb.hpp +++ b/src/badguy/bomb.hpp @@ -38,8 +38,7 @@ public: private: enum State { - STATE_TICKING, - STATE_EXPLODING + STATE_TICKING }; State state; diff --git a/src/badguy/mrrocket.cpp b/src/badguy/mrrocket.cpp index 410cc835f..4ac7045a0 100644 --- a/src/badguy/mrrocket.cpp +++ b/src/badguy/mrrocket.cpp @@ -20,6 +20,7 @@ #include #include "mrrocket.hpp" +#include "object/explosion.hpp" static const float SPEED = 200; @@ -56,7 +57,7 @@ void MrRocket::active_update(float elapsed_time) { if (collision_timer.check()) { - Sector::current()->add_object(new RocketExplosion(get_pos(), dir)); + Sector::current()->add_object(new Explosion(get_bbox().get_middle())); remove_me(); } else if (!collision_timer.started()) { diff --git a/src/badguy/mrrocket.hpp b/src/badguy/mrrocket.hpp index bb95805ba..628df377d 100644 --- a/src/badguy/mrrocket.hpp +++ b/src/badguy/mrrocket.hpp @@ -22,7 +22,6 @@ #include "badguy.hpp" #include "timer.hpp" -#include "rocketexplosion.hpp" class MrRocket : public BadGuy { diff --git a/src/badguy/rocketexplosion.cpp b/src/badguy/rocketexplosion.cpp deleted file mode 100644 index 2c24ccb34..000000000 --- a/src/badguy/rocketexplosion.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2006 Matthias Braun -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#include - -#include "rocketexplosion.hpp" - -static const float EXPLOSIONTIME = 1; - -RocketExplosion::RocketExplosion(const Vector& pos, Direction dir) - : BadGuy(pos, dir, "images/creatures/mr_rocket/explosion.sprite") -{ - countMe = false; - explode(); -} - -void -RocketExplosion::write(lisp::Writer& ) -{ - // rocket explosions are only temporarily so don't write them out... -} - -HitResponse -RocketExplosion::collision_player(Player& player, const CollisionHit& ) -{ - player.kill(false); - return ABORT_MOVE; -} - -HitResponse -RocketExplosion::collision_badguy(BadGuy& badguy, const CollisionHit& ) -{ - badguy.kill_fall(); - return ABORT_MOVE; -} - -void -RocketExplosion::active_update(float ) -{ - if(timer.check()) { - remove_me(); - } -} - -void -RocketExplosion::explode() -{ - sprite->set_action(dir == LEFT ? "explosion-left" : "explosion-right"); - sound_manager->play("sounds/explosion.wav", get_pos()); - timer.start(EXPLOSIONTIME, true); -} - -void -RocketExplosion::kill_fall() -{ -} diff --git a/src/badguy/rocketexplosion.hpp b/src/badguy/rocketexplosion.hpp deleted file mode 100644 index e334dc830..000000000 --- a/src/badguy/rocketexplosion.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2006 Matthias Braun -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -#ifndef __ROCKETEXPLOSION_H__ -#define __ROCKETEXPLOSION_H__ - -#include "badguy.hpp" - -class RocketExplosion : public BadGuy -{ -public: - RocketExplosion(const Vector& pos, Direction dir); - - void write(lisp::Writer& writer); - HitResponse collision_player(Player& player, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); - void active_update(float elapsed_time); - void kill_fall(); - void explode(); - - virtual RocketExplosion* clone() const { return new RocketExplosion(*this); } - -private: - Timer timer; -}; - -#endif diff --git a/src/object/explosion.cpp b/src/object/explosion.cpp index 5d64ca2a9..c172e11ed 100644 --- a/src/object/explosion.cpp +++ b/src/object/explosion.cpp @@ -22,31 +22,17 @@ #include "explosion.hpp" #include "badguy/badguy.hpp" #include "object/sprite_particle.hpp" - -#include "resources.hpp" -#include "video/drawing_context.hpp" -#include "sprite/sprite_manager.hpp" -#include "player.hpp" -#include "sector.hpp" -#include "player_status.hpp" -#include "gameobjs.hpp" -#include "statistics.hpp" -#include "object_factory.hpp" -#include "level.hpp" #include "random_generator.hpp" -#include "audio/sound_source.hpp" -#include "audio/sound_manager.hpp" -#include "timer.hpp" Explosion::Explosion(const Vector& pos) - : MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_BACKGROUNDTILES+10, COLGROUP_TOUCHABLE), state(STATE_WAITING) + : MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING) { sound_manager->preload("sounds/explosion.wav"); set_pos(get_pos() - (get_bbox().get_middle() - get_pos())); } Explosion::Explosion(const lisp::Lisp& reader) - : MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_BACKGROUNDTILES+10, COLGROUP_TOUCHABLE), state(STATE_WAITING) + : MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING) { sound_manager->preload("sounds/explosion.wav"); }