(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"))
)
(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"))
)
+++ /dev/null
-(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")
- )
-)
#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"*/ )
}
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();
}
}
void
Bomb::kill_fall()
{
- if (state != STATE_EXPLODING) // we don't want it exploding again
- explode();
+ explode();
}
private:
enum State {
- STATE_TICKING,
- STATE_EXPLODING
+ STATE_TICKING
};
State state;
#include <config.h>
#include "mrrocket.hpp"
+#include "object/explosion.hpp"
static const float SPEED = 200;
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()) {
#include "badguy.hpp"
#include "timer.hpp"
-#include "rocketexplosion.hpp"
class MrRocket : public BadGuy
{
+++ /dev/null
-// $Id$
-//
-// SuperTux
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// 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 <config.h>
-
-#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()
-{
-}
+++ /dev/null
-// $Id$
-//
-// SuperTux
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// 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
#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");
}