Snowman turns into snowball when stomped.
[supertux.git] / src / badguy / snowman.cpp
1 //  SuperTux
2 //  Copyright (C) 2010 Ingo Ruhnke <grumbel@gmx.de>
3 //
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.
8 //
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.
13 //
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/>.
16
17 #include "badguy/snowman.hpp"
18
19 #include "badguy/snowball.hpp"
20 #include "object/player.hpp"
21 #include "supertux/sector.hpp"
22
23 Snowman::Snowman(const Reader& reader) :
24   WalkingBadguy(reader, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
25 {
26   walk_speed = 40;
27 }
28
29 Snowman::Snowman(const Vector& pos, Direction d) :
30   WalkingBadguy(pos, d, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
31 {
32   walk_speed = 40;
33 }
34
35 bool
36 Snowman::collision_squished(GameObject& object)
37 {
38   // replace with Snowball
39   Vector snowball_pos = get_pos();
40   // Hard-coded values from sprites
41   snowball_pos.x += 2;
42   snowball_pos.y += 40;
43
44   SnowBall* snowball = new SnowBall(snowball_pos, dir);
45   remove_me();
46   Sector::current()->add_object(snowball);
47
48   // bounce
49   Player* player = dynamic_cast<Player*>(&object);
50   if (player) player->bounce(*this);
51 /*
52   sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
53   kill_squished(object);
54 */
55   return true;
56 }
57
58 /* EOF */