Additional tile attribute FIRE for lava (=WATER, HURTS, FIRE).
Badguys that collide with tiles that have HURTS and one of FIRE or ICE set are ignited or frozen instead of killed
SVN-Revision: 4206
)
(water #t)
(hurts #t)
+ (fire #t)
(anim-fps 10)
)
(tile
)
(water #t)
(hurts #t)
+ (fire #t)
(anim-fps 10)
)
(tile
"tiles/lava/zone/body-1-3.png"
"tiles/lava/zone/body-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/edge-1-3.png"
"tiles/lava/zone/edge-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/rest.png"
"tiles/lava/zone/rest.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/bubble-in-1-3.png"
"tiles/lava/zone/bubble-in-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/bubble-out-1-4.png"
)
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/body-2-3.png"
"tiles/lava/zone/body-2-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/body-bottom-1-3.png"
"tiles/lava/zone/body-bottom-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/edge-right-1-3.png"
"tiles/lava/zone/edge-right-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/edge-left-1-3.png"
"tiles/lava/zone/edge-left-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/edge-right-1-2.png"
"tiles/lava/zone/edge-right-1-1.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/edge-left-1-3.png"
"tiles/lava/zone/edge-left-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/edge-flip-1-3.png"
"tiles/lava/zone/edge-flip-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/bubble-bottom-1-3.png"
"tiles/lava/zone/bubble-bottom-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/bubble-out-1-3.png"
"tiles/lava/zone/bubble-out-1-4.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/rest.png"
"tiles/lava/zone/rest.png")
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
"tiles/lava/zone/bubble-in-1-4.png"
)
(hurts #t)
+ (fire #t)
(solid #f)
(anim-fps 2)
)
void
BadGuy::collision_tile(uint32_t tile_attributes)
{
- if(tile_attributes & Tile::HURTS)
- kill_fall();
+ if(tile_attributes & Tile::HURTS) {
+ if (tile_attributes & Tile::FIRE) {
+ if (is_flammable()) ignite();
+ }
+ else if (tile_attributes & Tile::ICE) {
+ if (is_freezable()) freeze();
+ }
+ else {
+ kill_fall();
+ }
+ }
}
HitResponse
}
void
-Stalactite::collision_solid(const CollisionHit& hit)
+Stalactite::squish()
{
- if(state != STALACTITE_FALLING && state != STALACTITE_SQUISHED)
- return;
+ state = STALACTITE_SQUISHED;
+ set_group(COLGROUP_MOVING_ONLY_STATIC);
+ sprite->set_action("squished");
+ if(!timer.started())
+ timer.start(SQUISH_TIME);
+}
- if(hit.bottom) { // hit floor?
- state = STALACTITE_SQUISHED;
- set_group(COLGROUP_MOVING_ONLY_STATIC);
+void
+Stalactite::collision_solid(const CollisionHit& hit)
+{
+ if(state == STALACTITE_FALLING) {
+ if (hit.bottom) squish();
+ }
+ if(state == STALACTITE_SQUISHED) {
physic.set_velocity_y(0);
- sprite->set_action("squished");
- if(!timer.started())
- timer.start(SQUISH_TIME);
}
}
return FORCE_MOVE;
}
+HitResponse
+Stalactite::collision_badguy(BadGuy& other, const CollisionHit& hit)
+{
+ if (state == STALACTITE_SQUISHED) return FORCE_MOVE;
+ if (state != STALACTITE_FALLING) return BadGuy::collision_badguy(other, hit);
+
+ if (other.is_freezable()) {
+ other.freeze();
+ } else {
+ other.kill_fall();
+ }
+
+ remove_me();
+
+ return FORCE_MOVE;
+}
+
void
Stalactite::kill_fall()
{
void write(lisp::Writer& writer);
void collision_solid(const CollisionHit& hit);
HitResponse collision_player(Player& player);
+ HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
void kill_fall();
void draw(DrawingContext& context);
virtual Stalactite* clone() const { return new Stalactite(*this); }
+ void squish();
+
protected:
Timer timer;
attributes |= WATER;
if(reader.get("hurts", value) && value)
attributes |= HURTS;
+ if(reader.get("fire", value) && value)
+ attributes |= FIRE;
if(reader.get("fullbox", value) && value)
attributes |= FULLBOX;
if(reader.get("coin", value) && value)
WATER = 0x0200,
/** a tile that hurts the player if he touches it */
HURTS = 0x0400,
+ /** for lava: WATER, HURTS, FIRE */
+ FIRE = 0x0800
};
/// worldmap flags