From: LMH Date: Mon, 2 Sep 2013 19:15:09 +0000 (-1000) Subject: Made short_fuse explode when hit with bullets of all types X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a413968f497b7c28a58f722b08f3ee48e586d8a1;p=supertux.git Made short_fuse explode when hit with bullets of all types --- diff --git a/src/badguy/short_fuse.cpp b/src/badguy/short_fuse.cpp index d36c54da1..127691fe2 100644 --- a/src/badguy/short_fuse.cpp +++ b/src/badguy/short_fuse.cpp @@ -18,6 +18,7 @@ #include "audio/sound_manager.hpp" #include "badguy/bomb.hpp" #include "badguy/short_fuse.hpp" +#include "object/bullet.hpp" #include "object/explosion.hpp" #include "object/player.hpp" #include "sprite/sprite.hpp" @@ -50,15 +51,6 @@ ShortFuse::ShortFuse(const Reader& reader) : sprite = sprite_manager->create( sprite_name ); } -/* ShortFuse created by a dispenser always gets default sprite atm.*/ -ShortFuse::ShortFuse(const Vector& pos, Direction d) : - WalkingBadguy(pos, d, "images/creatures/short_fuse/short_fuse.sprite", "left", "right") -{ - walk_speed = 80; - max_drop_height = 16; - sound_manager->preload("sounds/explosion.wav"); -} - void ShortFuse::explode (void) { @@ -98,6 +90,15 @@ ShortFuse::collision_player (Player& player, const CollisionHit&) return ABORT_MOVE; } +HitResponse +ShortFuse::collision_bullet (Bullet& bullet, const CollisionHit& ) +{ + // All bullets cause the unstable short fuse to explode + bullet.remove_me(); + explode(); + return ABORT_MOVE; +} + void ShortFuse::kill_fall (void) { diff --git a/src/badguy/short_fuse.hpp b/src/badguy/short_fuse.hpp index 4c90fb6b3..f14cca709 100644 --- a/src/badguy/short_fuse.hpp +++ b/src/badguy/short_fuse.hpp @@ -24,10 +24,10 @@ class ShortFuse : public WalkingBadguy { public: ShortFuse(const Reader& reader); - ShortFuse(const Vector& pos, Direction d); protected: HitResponse collision_player (Player& player, const CollisionHit& hit); + HitResponse collision_bullet (Bullet& bullet, const CollisionHit& ); bool collision_squished (GameObject& object); void kill_fall (void); void explode (void);