2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 // Copyright (C) 2010 Florian Forster <supertux at octo.it>
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "badguy/bomb.hpp"
19 #include "badguy/short_fuse.hpp"
20 #include "object/bullet.hpp"
21 #include "object/explosion.hpp"
22 #include "object/player.hpp"
23 #include "sprite/sprite.hpp"
24 #include "sprite/sprite_manager.hpp"
25 #include "supertux/object_factory.hpp"
26 #include "supertux/sector.hpp"
27 #include "util/reader.hpp"
28 #include "util/log.hpp"
30 #define EXPLOSION_FORCE 1000.0f
32 ShortFuse::ShortFuse(const Reader& reader) :
33 WalkingBadguy(reader, "images/creatures/short_fuse/short_fuse.sprite", "left", "right")
38 //Check if we need another sprite
39 if( !reader.get( "sprite", sprite_name ) ){
42 if( sprite_name == "" ){
43 sprite_name = "images/creatures/short_fuse/short_fuse.sprite";
47 sprite = SpriteManager::current()->create( sprite_name );
51 ShortFuse::explode (void)
56 Explosion *explosion = new Explosion (get_bbox ().get_middle ());
58 explosion->hurts (false);
59 explosion->pushes (true);
60 Sector::current()->add_object (explosion);
67 ShortFuse::collision_squished(GameObject& obj)
72 Player* player = dynamic_cast<Player*>(&obj);
74 player->bounce(*this);
82 ShortFuse::collision_player (Player& player, const CollisionHit&)
84 player.bounce (*this);
90 ShortFuse::collision_bullet (Bullet& bullet, const CollisionHit& )
92 // All bullets cause the unstable short fuse to explode
99 ShortFuse::kill_fall (void)
104 /* vim: set sw=2 sts=2 et : */