2 // Copyright (C) 2010 Ingo Ruhnke <grumbel@gmx.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "badguy/snowman.hpp"
19 #include "badguy/snowball.hpp"
20 #include "object/player.hpp"
21 #include "supertux/sector.hpp"
23 Snowman::Snowman(const Reader& reader) :
24 WalkingBadguy(reader, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
29 Snowman::Snowman(const Vector& pos, Direction d) :
30 WalkingBadguy(pos, d, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
36 Snowman::collision_squished(GameObject& object)
38 // replace with Snowball
39 Vector snowball_pos = get_pos();
40 // Hard-coded values from sprites
44 SnowBall* snowball = new SnowBall(snowball_pos, dir);
46 Sector::current()->add_object(snowball);
49 Player* player = dynamic_cast<Player*>(&object);
50 if (player) player->bounce(*this);
52 sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
53 kill_squished(object);