00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "badguy/snowman.hpp"
00018
00019 #include "badguy/snowball.hpp"
00020 #include "object/player.hpp"
00021 #include "supertux/sector.hpp"
00022
00023 Snowman::Snowman(const Reader& reader) :
00024 WalkingBadguy(reader, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
00025 {
00026 walk_speed = 40;
00027 }
00028
00029 Snowman::Snowman(const Vector& pos, Direction d) :
00030 WalkingBadguy(pos, d, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
00031 {
00032 walk_speed = 40;
00033 }
00034
00035 bool
00036 Snowman::collision_squished(GameObject& object)
00037 {
00038
00039 Vector snowball_pos = get_pos();
00040
00041 snowball_pos.x += 5;
00042 snowball_pos.y += 1;
00043
00044
00045 Player* player = dynamic_cast<Player*>(&object);
00046 if (player)
00047 player->bounce(*this);
00048
00049
00050 set_action (dir == LEFT ? "headless-left" : "headless-right", -1);
00051 set_pos (get_pos () + Vector (-4.0, 19.0));
00052 physic.set_velocity_y(0);
00053 physic.set_acceleration_y(0);
00054 physic.enable_gravity(true);
00055 set_state (STATE_FALLING);
00056
00057
00058
00059 SnowBall* snowball = new SnowBall(snowball_pos, dir);
00060 Sector::current()->add_object(snowball);
00061
00062 return true;
00063 }
00064
00065