KamikazeSnowball Class Reference

#include <kamikazesnowball.hpp>

Inherits BadGuy.

List of all members.

Public Member Functions

 KamikazeSnowball (const Reader &reader)
 KamikazeSnowball (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.

Protected Member Functions

bool collision_squished (GameObject &object)
 Called when the player hit the badguy from above.
HitResponse collision_player (Player &player, const CollisionHit &hit)
 Called when the badguy collided with a player.
void kill_collision ()


Detailed Description

Definition at line 22 of file kamikazesnowball.hpp.


Constructor & Destructor Documentation

KamikazeSnowball::KamikazeSnowball ( const Reader reader  ) 

Definition at line 32 of file kamikazesnowball.cpp.

References BadGuy::dir, LEFT, SoundManager::preload(), MovingSprite::set_action(), sound_manager, and SPLAT_SOUND.

00032                                                        :
00033   BadGuy(reader, "images/creatures/snowball/kamikaze-snowball.sprite")
00034 {
00035   sound_manager->preload(SPLAT_SOUND);
00036   set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
00037 }

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

Definition at line 39 of file kamikazesnowball.cpp.

References BadGuy::dir, LEFT, SoundManager::preload(), MovingSprite::set_action(), sound_manager, and SPLAT_SOUND.

00040   : BadGuy(pos, d, "images/creatures/snowball/kamikaze-snowball.sprite")
00041 {
00042   sound_manager->preload(SPLAT_SOUND);
00043   set_action (dir == LEFT ? "left" : "right", /* loops = */ -1);
00044 }


Member Function Documentation

void KamikazeSnowball::initialize (  )  [virtual]

called immediately before the first call to initialize

Reimplemented from BadGuy.

Definition at line 47 of file kamikazesnowball.cpp.

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

00048 {
00049   physic.set_velocity_x(dir == LEFT ? -KAMIKAZE_SPEED : KAMIKAZE_SPEED);
00050   physic.enable_gravity(false);
00051   sprite->set_action(dir == LEFT ? "left" : "right");
00052 }

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

Called when the badguy collided with solid ground.

Reimplemented from BadGuy.

Definition at line 63 of file kamikazesnowball.cpp.

References CollisionHit::bottom, kill_collision(), CollisionHit::left, BadGuy::physic, CollisionHit::right, Physic::set_velocity_y(), and CollisionHit::top.

00064 {
00065   if(hit.top || hit.bottom) {
00066     physic.set_velocity_y(0);
00067   }
00068   if(hit.left || hit.right) {
00069     kill_collision();
00070   }
00071 }

bool KamikazeSnowball::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 55 of file kamikazesnowball.cpp.

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

00056 {
00057   sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
00058   kill_squished(object);
00059   return true;
00060 }

HitResponse KamikazeSnowball::collision_player ( Player player,
const CollisionHit hit 
) [protected, virtual]

Called when the badguy collided with a player.

Reimplemented from BadGuy.

Definition at line 87 of file kamikazesnowball.cpp.

References ABORT_MOVE, BadGuy::collision_player(), FORCE_MOVE, and kill_collision().

00088 {
00089   //Hack to tell if we should die
00090   HitResponse response = BadGuy::collision_player(player, hit);
00091   if(response == FORCE_MOVE) {
00092     kill_collision();
00093   }
00094 
00095   return ABORT_MOVE;
00096 }

void KamikazeSnowball::kill_collision (  )  [protected]

Definition at line 74 of file kamikazesnowball.cpp.

References BadGuy::dir, Physic::enable_gravity(), MovingObject::get_pos(), LEFT, BadGuy::physic, SoundManager::play(), BadGuy::run_dead_script(), BadGuy::set_state(), Physic::set_velocity_x(), Physic::set_velocity_y(), sound_manager, SPLAT_SOUND, MovingSprite::sprite, and BadGuy::STATE_FALLING.

Referenced by collision_player(), and collision_solid().

00075 {
00076   sprite->set_action(dir == LEFT ? "collision-left" : "collision-right");
00077   sound_manager->play(SPLAT_SOUND, get_pos());
00078   physic.set_velocity_x(0);
00079   physic.set_velocity_y(0);
00080   physic.enable_gravity(true);
00081   set_state(STATE_FALLING);
00082 
00083   run_dead_script();
00084 }


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