Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

Character Class Reference

Damagable, non static objects. More...

#include <characters_common.h>

Inheritance diagram for Character:

Inheritance graph
[legend]
Collaboration diagram for Character:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Character (Sint16 xpos=0, Sint16 ypos=0, const ParameterMap &param=ParameterMap())
Uint8 getHealth ()
Sint16 getSpeed () const
Sint16 setSpeed (Sint16 newspeed)
Sint16 addSpeed (Sint16 dspeed)
Sint16 addHSpeed (Sint16 dspeed)
void setGravity (Sint16 setgravity)
void addGravity (Sint16 addgravity)
Uint16 addMaxSpeed (Sint16 dmax)
Uint16 setMaxSpeed (Uint16 maxs)
Hit checkMove (SDL_Rect &dest, bool tele=false, bool check=false)
 Collision detection.
const std::set< Object * > & getEnter () const
const std::set< Object * > & getTouch () const
virtual void removedObject (Object *)
 Remove the specified object from all internal accountings.
virtual void updateAnimState ()
 Updates the current animation.
virtual void resetAnimState ()
 Sets the animation back to the default one.
virtual void idle (Uint16)
virtual void fall (Uint16)
virtual void die ()
virtual Uint16 hit (Uint16 direction, Weapon &weap)
 Weapon hits.

Static Public Attributes

ParameterMap default_parameters

Protected Member Functions

Hit checkHit (const SDL_Rect &dest, Object *destobj, bool tele=false) const
 Checks the type of the impact into the destination object.
void updateRegions (std::set< Object * > &newtouch, std::set< Object * > &newenter)
 Updates the regions.
virtual void crash (Uint16 dir=DIR_DOWN)
virtual Hit move (Uint16 dt, bool check=false)
Uint8 setHealth (Uint8)
Uint8 addHealth (Sint8)
virtual void addTouch (std::set< Object * > &)
 Adds the specified set to the touch set.
virtual void addEnter (std::set< Object * > &)
 Adds the specified set to the enter set.
virtual void removeTouch (std::set< Object * > &)
 Removes the specified sets from the touch set.
virtual void removeEnter (std::set< Object * > &)
 Removes the specified sets from the enter set.

Protected Attributes

Uint8 health
Uint8 maxhealth
Uint16 maxspeedx
Uint16 maxspeedy
Sint16 hspeed
Sint16 speed
Sint16 gravity
Sint16 Dgrav
std::set< Object * > enter
std::set< Object * > touch
Uint16 dense_types
Uint16 enemy_types
Weapon weapon

Detailed Description

Damagable, non static objects.

A character can get hit, can move and fall, can die, etc...


Member Function Documentation

Hit Character::checkMove SDL_Rect &  dest,
bool  tele = false,
bool  check = false
 

Collision detection.

Checks and correspondingly updates a movement and the regions the character is in. It therefore performs a collision check for all objects in the objectspool and the map boundary on the left, right and downside. If check is false it updates the regions accordingly. The destination parameter is changed to be before any dense obstacles in the way.

Precondition:
The character didn't hit anything
Parameters:
dest Designated movement position of the object
tele True if it's not a smooth movement but an instant jump, it will then check all directions
check True if no region updates should be performed
Returns:
Hit type of the movement

virtual void Character::removedObject Object  )  [virtual]
 

Remove the specified object from all internal accountings.

Clean up the internal accountings of the specified object. Usually called when an object leaves the map (dies).

Reimplemented in Monster.

virtual void Character::updateAnimState  )  [virtual]
 

Updates the current animation.

Checks the state and changes the animation correpspondingly

Reimplemented in Monster, Olaf, and Player.

virtual void Character::idle Uint16   )  [virtual]
 

What should the object do all the time? This is run first of all.

Remarks:
This should be called downwards by all derived classes

Reimplemented from Object.

Reimplemented in Monster, Erik, Plant, Scorch, TriggeredBomb, Zombie, and Player.

virtual void Character::fall Uint16   )  [virtual]
 

Calculates the speed of the character

Todo:
clean up this mess with fall/move

Reimplemented in Monster, Fang, Olaf, Scorch, and Player.

virtual Uint16 Character::hit Uint16  direction,
Weapon weap
[virtual]
 

Weapon hits.

Called when hit by a weapon. Depending on the direction and weapon used, certain effects/events are run.

Parameters:
direction Direction from which the weapon deals damage
weap Weapon used in the attack/hit
Returns:
New health of the character

Reimplemented in Monster, Erik, Olaf, Plant, and Player.

Hit Character::checkHit const SDL_Rect &  dest,
Object destobj,
bool  tele = false
const [inline, protected]
 

Checks the type of the impact into the destination object.

Helper function (run by checkMove()) that checks the type of the collision into one specific object.

Precondition:
The character didn't hit anything
Parameters:
dest Destination rectangle of the movement
destobj Target object to check
tele If true an instant movement (no smooth movement) is assumed
Returns:
Hit type of the collision, HIT_NOTHING if no valid destobj was specified or if the destobj is the character himself.

void Character::updateRegions std::set< Object * > &  newtouch,
std::set< Object * > &  newenter
[inline, protected]
 

Updates the regions.

A helper function (run by checkMove()) that updates the touch and enter regions of the character. It adds the new regions and removes the old ones.

Parameters:
newtouch Set of all touched objects
newenter Set of all entered objects

Uint8 Character::setHealth Uint8   )  [protected]
 

Sets the health of the character to a minimum of 0

Returns:
New health

Uint8 Character::addHealth Sint8   )  [protected]
 

Adds the specified amount of life to the health of the character to a minimum of 0

Returns:
New health

virtual Hit Character::move Uint16  dt,
bool  check = false
[protected, virtual]
 

Updates the position of the character depending on it's velocity, checks for crashes

Todo:
clean up this mess with move and fall

Reimplemented in Monster, and Player.


The documentation for this class was generated from the following file:
Generated on Sun Feb 5 13:02:36 2006 for Lost Penguins by doxygen 1.3.8