X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy%2Fbomb.cpp;h=614bb18d7a1988a2eb32ea60d208c6684c322935;hb=864c93e01ec366f730b3ebad08d5c52d6a9363b6;hp=c7445a2783dd7d5ff689a9c8fbca6cab556ec913;hpb=3510a03c0e807c7a0ddde3cdf07ba91bda9393c4;p=supertux.git diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index c7445a278..614bb18d7 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -1,3 +1,23 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. + #include #include "bomb.h" @@ -44,7 +64,8 @@ Bomb::collision_player(Player& player, const CollisionHit& ) HitResponse Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& ) { - badguy.kill_fall(); + if(state == 1) + badguy.kill_fall(); return ABORT_MOVE; } @@ -54,9 +75,7 @@ Bomb::active_action(float ) switch(state) { case 0: if(timer.check()) { - state = 1; - sprite->set_action("explosion"); - timer.start(EXPLOSIONTIME); + explode(); } break; case 1: @@ -68,6 +87,18 @@ Bomb::active_action(float ) } void +Bomb::explode() +{ + state = 1; + sprite->set_action("explosion"); + sound_manager->play_sound("explosion", get_pos(), + Sector::current()->player->get_pos()); + timer.start(EXPLOSIONTIME); +} + +void Bomb::kill_fall() { + explode(); } +