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 "audio/sound_manager.hpp"
19 #include "badguy/bomb.hpp"
20 #include "badguy/short_fuse.hpp"
21 #include "object/bullet.hpp"
22 #include "object/explosion.hpp"
23 #include "object/player.hpp"
24 #include "sprite/sprite.hpp"
25 #include "sprite/sprite_manager.hpp"
26 #include "supertux/object_factory.hpp"
27 #include "supertux/sector.hpp"
28 #include "util/reader.hpp"
29 #include "util/log.hpp"
31 #define EXPLOSION_FORCE 1000.0f
33 ShortFuse::ShortFuse(const Reader& reader) :
34 WalkingBadguy(reader, "images/creatures/short_fuse/short_fuse.sprite", "left", "right")
39 //Prevent stutter when Tux jumps on Mr Bomb
40 sound_manager->preload("sounds/explosion.wav");
42 //Check if we need another sprite
43 if( !reader.get( "sprite", sprite_name ) ){
46 if( sprite_name == "" ){
47 sprite_name = "images/creatures/short_fuse/short_fuse.sprite";
51 sprite = sprite_manager->create( sprite_name );
55 ShortFuse::explode (void)
60 Explosion *explosion = new Explosion (get_bbox ().get_middle ());
62 explosion->hurts (false);
63 explosion->pushes (true);
64 Sector::current()->add_object (explosion);
71 ShortFuse::collision_squished(GameObject& obj)
76 Player* player = dynamic_cast<Player*>(&obj);
78 player->bounce(*this);
86 ShortFuse::collision_player (Player& player, const CollisionHit&)
88 player.bounce (*this);
94 ShortFuse::collision_bullet (Bullet& bullet, const CollisionHit& )
96 // All bullets cause the unstable short fuse to explode
103 ShortFuse::kill_fall (void)
108 /* vim: set sw=2 sts=2 et : */