From ed41a50b47dc0a96e0c58dda40a2cc9d00d197fb Mon Sep 17 00:00:00 2001 From: mathnerd314 Date: Sat, 27 Feb 2010 13:21:53 +0000 Subject: [PATCH] Snowman turns into snowball when stomped. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6418 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/badguy/snowman.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/badguy/snowman.cpp b/src/badguy/snowman.cpp index ba22e0b90..17783de4e 100644 --- a/src/badguy/snowman.cpp +++ b/src/badguy/snowman.cpp @@ -16,6 +16,10 @@ #include "badguy/snowman.hpp" +#include "badguy/snowball.hpp" +#include "object/player.hpp" +#include "supertux/sector.hpp" + Snowman::Snowman(const Reader& reader) : WalkingBadguy(reader, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right") { @@ -31,8 +35,23 @@ Snowman::Snowman(const Vector& pos, Direction d) : bool Snowman::collision_squished(GameObject& object) { + // replace with Snowball + Vector snowball_pos = get_pos(); + // Hard-coded values from sprites + snowball_pos.x += 2; + snowball_pos.y += 40; + + SnowBall* snowball = new SnowBall(snowball_pos, dir); + remove_me(); + Sector::current()->add_object(snowball); + + // bounce + Player* player = dynamic_cast(&object); + if (player) player->bounce(*this); +/* sprite->set_action(dir == LEFT ? "squished-left" : "squished-right"); kill_squished(object); +*/ return true; } -- 2.11.0