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/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 //Prevent stutter when Tux jumps on Mr Bomb
39 sound_manager->preload("sounds/explosion.wav");
41 //Check if we need another sprite
42 if( !reader.get( "sprite", sprite_name ) ){
45 if( sprite_name == "" ){
46 sprite_name = "images/creatures/short_fuse/short_fuse.sprite";
50 sprite = sprite_manager->create( sprite_name );
53 /* ShortFuse created by a dispenser always gets default sprite atm.*/
54 ShortFuse::ShortFuse(const Vector& pos, Direction d) :
55 WalkingBadguy(pos, d, "images/creatures/short_fuse/short_fuse.sprite", "left", "right")
59 sound_manager->preload("sounds/explosion.wav");
63 ShortFuse::explode (void)
68 Explosion *explosion = new Explosion (get_bbox ().get_middle ());
70 explosion->hurts (false);
71 explosion->pushes (true);
72 Sector::current()->add_object (explosion);
78 ShortFuse::collision_squished(GameObject& obj)
83 Player* player = dynamic_cast<Player*>(&obj);
85 player->bounce(*this);
93 ShortFuse::collision_player (Player& player, const CollisionHit&)
95 player.bounce (*this);
101 ShortFuse::kill_fall (void)
107 /* vim: set sw=2 sts=2 et : */