Snowman Class Reference

#include <snowman.hpp>

Inherits WalkingBadguy.

List of all members.

Public Member Functions

 Snowman (const Reader &reader)
 Snowman (const Vector &pos, Direction d)

Protected Member Functions

bool collision_squished (GameObject &object)
 Called when the player hit the badguy from above.


Detailed Description

Definition at line 25 of file snowman.hpp.


Constructor & Destructor Documentation

Snowman::Snowman ( const Reader reader  ) 

Definition at line 23 of file snowman.cpp.

References WalkingBadguy::walk_speed.

00023                                      :
00024   WalkingBadguy(reader, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
00025 {
00026   walk_speed = 40;
00027 }

Snowman::Snowman ( const Vector pos,
Direction  d 
)

Definition at line 29 of file snowman.cpp.

References WalkingBadguy::walk_speed.

00029                                                :
00030   WalkingBadguy(pos, d, "images/creatures/snowman/snowman.sprite", "walk-left", "walk-right")
00031 {
00032   walk_speed = 40;
00033 }


Member Function Documentation

bool Snowman::collision_squished ( GameObject object  )  [protected, virtual]

Called when the player hit the badguy from above.

You should return true if the badguy was squished, false if squishing wasn't possible

Reimplemented from BadGuy.

Definition at line 36 of file snowman.cpp.

References Sector::add_object(), Player::bounce(), Sector::current(), BadGuy::dir, Physic::enable_gravity(), MovingObject::get_pos(), LEFT, BadGuy::physic, Physic::set_acceleration_y(), MovingSprite::set_action(), MovingObject::set_pos(), BadGuy::set_state(), Physic::set_velocity_y(), BadGuy::STATE_FALLING, Vector::x, and Vector::y.

00037 {
00038   // replace with Snowball
00039   Vector snowball_pos = get_pos();
00040   // Hard-coded values from sprites
00041   snowball_pos.x += 5;
00042   snowball_pos.y += 1;
00043 
00044   // bounce
00045   Player* player = dynamic_cast<Player*>(&object);
00046   if (player)
00047     player->bounce(*this);
00048 
00049   /* Create death animation for the (now headless) snowman. */
00050   set_action (dir == LEFT ? "headless-left" : "headless-right", /* loops = */ -1);
00051   set_pos (get_pos () + Vector (-4.0, 19.0)); /* difference in the sprite offsets */
00052   physic.set_velocity_y(0);
00053   physic.set_acceleration_y(0);
00054   physic.enable_gravity(true);
00055   set_state (STATE_FALLING);
00056 
00057   /* Create a new snowball where the snowman's head was */
00058   /* TODO: Pass on our "dead_script" to the snowball. */
00059   SnowBall* snowball = new SnowBall(snowball_pos, dir);
00060   Sector::current()->add_object(snowball);
00061 
00062   return true;
00063 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:36 2014 for SuperTux by  doxygen 1.5.1