MoleRock Class Reference

Badguy "MoleRock" - Rock thrown by "Mole" Badguy. More...

#include <mole_rock.hpp>

Inherits BadGuy.

List of all members.

Public Member Functions

 MoleRock (const Reader &reader)
 MoleRock (const Vector &pos, const Vector &velocity, const BadGuy *parent)
 ~MoleRock ()
void initialize ()
 called immediately before the first call to initialize
void deactivate ()
 called when the badguy has been deactivated
void active_update (float elapsed_time)
 called each frame when the badguy is activated.
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.
HitResponse collision_player (Player &player, const CollisionHit &hit)
 Called when the badguy collided with a player.
virtual bool updatePointers (const GameObject *from_object, GameObject *to_object)

Protected Attributes

const BadGuyparent
 collisions with this BadGuy will be ignored
const Vector initial_velocity
 velocity at time of creation

Private Member Functions

 MoleRock (const MoleRock &)
MoleRockoperator= (const MoleRock &)


Detailed Description

Badguy "MoleRock" - Rock thrown by "Mole" Badguy.

Definition at line 25 of file mole_rock.hpp.


Constructor & Destructor Documentation

MoleRock::MoleRock ( const Reader reader  ) 

Definition at line 23 of file mole_rock.cpp.

References BadGuy::countMe, Physic::enable_gravity(), BadGuy::physic, SoundManager::preload(), and sound_manager.

00024   : BadGuy(reader, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), parent(0), initial_velocity(Vector(0, -400))
00025 {
00026   physic.enable_gravity(true);
00027   countMe = false;
00028   sound_manager->preload("sounds/darthit.wav");
00029   sound_manager->preload("sounds/stomp.wav");
00030 }

MoleRock::MoleRock ( const Vector pos,
const Vector velocity,
const BadGuy parent 
)

Definition at line 32 of file mole_rock.cpp.

References BadGuy::countMe, Physic::enable_gravity(), BadGuy::physic, SoundManager::preload(), and sound_manager.

00032                                                                                       :
00033   BadGuy(pos, LEFT, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), 
00034   parent(parent), 
00035   initial_velocity(velocity)
00036 {
00037   physic.enable_gravity(true);
00038   countMe = false;
00039   sound_manager->preload("sounds/darthit.wav");
00040   sound_manager->preload("sounds/stomp.wav");
00041 }

MoleRock::~MoleRock (  ) 

Definition at line 43 of file mole_rock.cpp.

00044 {
00045 }

MoleRock::MoleRock ( const MoleRock  )  [private]


Member Function Documentation

void MoleRock::initialize (  )  [virtual]

called immediately before the first call to initialize

Reimplemented from BadGuy.

Definition at line 58 of file mole_rock.cpp.

References initial_velocity, BadGuy::physic, Physic::set_velocity(), and MovingSprite::sprite.

00059 {
00060   physic.set_velocity(initial_velocity);
00061   sprite->set_action("default");
00062 }

void MoleRock::deactivate (  )  [virtual]

called when the badguy has been deactivated

Reimplemented from BadGuy.

Definition at line 65 of file mole_rock.cpp.

References GameObject::remove_me().

00066 {
00067   remove_me();
00068 }

void MoleRock::active_update ( float  elapsed_time  )  [virtual]

called each frame when the badguy is activated.

Reimplemented from BadGuy.

Definition at line 71 of file mole_rock.cpp.

References BadGuy::active_update().

00072 {
00073   BadGuy::active_update(elapsed_time);
00074 }

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

Called when the badguy collided with solid ground.

Reimplemented from BadGuy.

Definition at line 77 of file mole_rock.cpp.

References MovingObject::get_pos(), SoundManager::play(), GameObject::remove_me(), and sound_manager.

00078 {
00079   sound_manager->play("sounds/darthit.wav", get_pos());
00080   remove_me();
00081 }

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

Called when the badguy collided with another badguy.

Reimplemented from BadGuy.

Definition at line 84 of file mole_rock.cpp.

References ABORT_MOVE, FORCE_MOVE, MovingObject::get_pos(), BadGuy::kill_fall(), parent, SoundManager::play(), GameObject::remove_me(), and sound_manager.

00085 {
00086   // ignore collisions with parent
00087   if (&badguy == parent) {
00088     return FORCE_MOVE;
00089   }
00090   sound_manager->play("sounds/stomp.wav", get_pos());
00091   remove_me();
00092   badguy.kill_fall();
00093   return ABORT_MOVE;
00094 }

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

Called when the badguy collided with a player.

Reimplemented from BadGuy.

Definition at line 97 of file mole_rock.cpp.

References BadGuy::collision_player(), MovingObject::get_pos(), SoundManager::play(), GameObject::remove_me(), and sound_manager.

00098 {
00099   sound_manager->play("sounds/stomp.wav", get_pos());
00100   remove_me();
00101   return BadGuy::collision_player(player, hit);
00102 }

bool MoleRock::updatePointers ( const GameObject from_object,
GameObject to_object 
) [virtual]

Definition at line 48 of file mole_rock.cpp.

References parent.

00049 {
00050   if (from_object == parent) {
00051     parent = dynamic_cast<MoleRock*>(to_object);
00052     return true;
00053   }
00054   return false;
00055 }

MoleRock& MoleRock::operator= ( const MoleRock  )  [private]


Member Data Documentation

const BadGuy* MoleRock::parent [protected]

collisions with this BadGuy will be ignored

Definition at line 44 of file mole_rock.hpp.

Referenced by collision_badguy(), and updatePointers().

const Vector MoleRock::initial_velocity [protected]

velocity at time of creation

Definition at line 45 of file mole_rock.hpp.

Referenced by initialize().


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