X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy%2Fmrbomb.cpp;h=a5290489857d1824e09cd0ad7e756b46f68f2d98;hb=8d1566374788e2c612b35d6b95463398a555b54a;hp=76222d28fa27aaeae2b81b1bae0e6352641c4c70;hpb=ef57479f613b900b73eba8e8f4d026aae0de25cc;p=supertux.git diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index 76222d28f..a52904898 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.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 "mrbomb.h" @@ -29,8 +49,8 @@ MrBomb::write(lisp::Writer& writer) { writer.start_list("mrbomb"); - writer.write_float("x", get_pos().x); - writer.write_float("y", get_pos().y); + writer.write_float("x", start_position.x); + writer.write_float("y", start_position.y); writer.end_list("mrbomb"); } @@ -48,7 +68,7 @@ MrBomb::collision_squished(Player& player) { remove_me(); Sector::current()->add_object(new Bomb(get_pos(), dir)); - player.bounce(*this); + kill_squished(player); return true; } @@ -66,3 +86,25 @@ MrBomb::collision_solid(GameObject& , const CollisionHit& hit) return CONTINUE; } +HitResponse +MrBomb::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left or right + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + return CONTINUE; +} + +void +MrBomb::kill_fall() +{ + remove_me(); + Bomb* bomb = new Bomb(get_pos(), dir); + Sector::current()->add_object(bomb); + bomb->explode(); +} + +IMPLEMENT_FACTORY(MrBomb, "mrbomb")