BouncingSnowball Class Reference

#include <bouncing_snowball.hpp>

Inherits BadGuy.

List of all members.

Public Member Functions

 BouncingSnowball (const Reader &reader)
 BouncingSnowball (const Vector &pos, Direction d)
void initialize ()
 called immediately before the first call to initialize
void collision_solid (const CollisionHit &hit)
 Called when the badguy collided with solid ground.
HitResponse collision_badguy (BadGuy &badguy, const CollisionHit &hit)
 Called when the badguy collided with another badguy.

Protected Member Functions

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


Detailed Description

Definition at line 22 of file bouncing_snowball.hpp.


Constructor & Destructor Documentation

BouncingSnowball::BouncingSnowball ( const Reader reader  ) 

Definition at line 25 of file bouncing_snowball.cpp.

00026   : BadGuy(reader, "images/creatures/bouncing_snowball/bouncing_snowball.sprite")
00027 {
00028 }

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

Definition at line 30 of file bouncing_snowball.cpp.

00031   : BadGuy(pos, d, "images/creatures/bouncing_snowball/bouncing_snowball.sprite")
00032 {
00033 }


Member Function Documentation

void BouncingSnowball::initialize (  )  [virtual]

called immediately before the first call to initialize

Reimplemented from BadGuy.

Definition at line 36 of file bouncing_snowball.cpp.

References BSNOWBALL_WALKSPEED, BadGuy::dir, LEFT, BadGuy::physic, Physic::set_velocity_x(), and MovingSprite::sprite.

00037 {
00038   physic.set_velocity_x(dir == LEFT ? -BSNOWBALL_WALKSPEED : BSNOWBALL_WALKSPEED);
00039   sprite->set_action(dir == LEFT ? "left" : "right");
00040 }

void BouncingSnowball::collision_solid ( const CollisionHit hit  )  [virtual]

Called when the badguy collided with solid ground.

Reimplemented from BadGuy.

Definition at line 51 of file bouncing_snowball.cpp.

References CollisionHit::bottom, BadGuy::dir, BadGuy::get_state(), Physic::get_velocity_x(), JUMPSPEED, LEFT, CollisionHit::left, BadGuy::physic, RIGHT, CollisionHit::right, Physic::set_velocity_x(), Physic::set_velocity_y(), MovingSprite::sprite, BadGuy::STATE_ACTIVE, and CollisionHit::top.

Referenced by collision_badguy().

00052 {
00053   if(hit.bottom) {
00054     if(get_state() == STATE_ACTIVE) {
00055       physic.set_velocity_y(JUMPSPEED);
00056     } else {
00057       physic.set_velocity_y(0);
00058     }
00059   } else if(hit.top) {
00060     physic.set_velocity_y(0);
00061   }
00062 
00063   if(hit.left || hit.right) { // left or right collision
00064     dir = dir == LEFT ? RIGHT : LEFT;
00065     sprite->set_action(dir == LEFT ? "left" : "right");
00066     physic.set_velocity_x(-physic.get_velocity_x());
00067   }
00068 }

HitResponse BouncingSnowball::collision_badguy ( BadGuy badguy,
const CollisionHit hit 
) [virtual]

Called when the badguy collided with another badguy.

Reimplemented from BadGuy.

Definition at line 71 of file bouncing_snowball.cpp.

References collision_solid(), and CONTINUE.

00072 {
00073   collision_solid(hit);
00074   return CONTINUE;
00075 }

bool BouncingSnowball::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 43 of file bouncing_snowball.cpp.

References BadGuy::kill_squished(), and MovingSprite::sprite.

00044 {
00045   sprite->set_action("squished");
00046   kill_squished(object);
00047   return true;
00048 }


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