#include <math.h>
Explosion::Explosion(const Vector& pos)
- : MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING)
+ : MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_MOVING), state(STATE_WAITING)
{
sound_manager->preload("sounds/explosion.wav");
set_pos(get_pos() - (get_bbox().get_middle() - get_pos()));
}
Explosion::Explosion(const Reader& reader)
- : MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING)
+ : MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_MOVING), state(STATE_WAITING)
{
sound_manager->preload("sounds/explosion.wav");
}
#include "object/unstable_tile.hpp"
+#include "object/explosion.hpp"
#include "object/player.hpp"
#include "sprite/sprite.hpp"
#include "supertux/constants.hpp"
Player* player = dynamic_cast<Player*> (&other);
if(player != NULL &&
player->get_bbox().get_bottom() < get_bbox().get_top() + SHIFT_DELTA) {
- state = STATE_CRUMBLING;
- sprite->set_action("crumbling", 1);
+ startCrumbling();
+ }
+
+ if (dynamic_cast<Explosion*> (&other)) {
+ startCrumbling();
}
}
return FORCE_MOVE;
}
void
+UnstableTile::startCrumbling()
+{
+ if (state != STATE_NORMAL) return;
+ state = STATE_CRUMBLING;
+ sprite->set_action("crumbling", 1);
+}
+
+void
UnstableTile::update(float elapsed_time)
{
switch (state) {
STATE_DISINTEGRATING /**< disintegrating, no longer solid */
};
+ void startCrumbling();
+
private:
Physic physic;
State state;
#include "object/weak_block.hpp"
#include "object/bullet.hpp"
+#include "object/explosion.hpp"
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
case STATE_NORMAL:
if (dynamic_cast<Bullet*>(&other)) {
startBurning();
- return FORCE_MOVE;
}
- return FORCE_MOVE;
+ if (dynamic_cast<Explosion*> (&other)) {
+ startBurning();
+ }
break;
case STATE_BURNING:
- return FORCE_MOVE;
- break;
-
case STATE_DISINTEGRATING:
- return FORCE_MOVE;
break;
+ default:
+ log_debug << "unhandled state" << std::endl;
+ break;
}
- log_debug << "unhandled state" << std::endl;
return FORCE_MOVE;
}