Package : Enemies
class CEnemy : public CPerso
Base class for all enemies
Attributes Index
public char m_damage
public uchar m_dirRnd
public uchar m_goDir
public uchar m_lifeState
public uchar m_nbrStep
public uchar m_stateMove
public uchar m_stepOffset
public uchar m_stepRnd
public uchar m_stepSpeed
public uchar m_timerExtraAni
Methods Index
AutoMove , CEnemy , CountDisable , Draw , IncLife , SetDamaged , SetEnable , SetKilled , Attributes Details
public char m_damage
Damage of the enemy
public uchar m_dirRnd
Configure the maximum of directions
Default 4
>4 for freezing moves
public uchar m_goDir
Current direction of AutoMove()
public uchar m_lifeState
State of the enemy. Can be one of this values :
LIFE_STATE_ALIVE, LIFE_STATE_DAMAGE, LIFE_STATE_KILL, LIFE_STATE_DIED
public uchar m_nbrStep
Number of step before the direction change
public uchar m_stateMove
State of automat in AutoMove()
public uchar m_stepOffset
Configure the minimum of steps for AutoMove()
public uchar m_stepRnd
Configure the maximum of steps for AutoMove()
public uchar m_stepSpeed
Number of pixels for one step
public uchar m_timerExtraAni
Timer for animation when enemy is damaged or killed
Methods Details
AutoMove
- public virtual BOOL AutoMove()
Virtual function for implementation in sub-class.
By default:
- choose number of steps
- choose one direction
- move the enemy while step
CEnemy
- public CEnemy(uchar objID, short initX, short initY , char margeBottom , char margeLeft , char margeTop , char margeRight , char damage , char life , uchar sprBottom , uchar sprLeft , uchar sprTop , uchar sprRight , char aniLen=DEFAULT_ENEMY_ANI_LEN , charCEnemy
Standard constructor
Parameters:
damage - set the damage of the enemy
life - set the life of the enemy
See also: CPerso#CPerso(),
CountDisable
- public BOOL CountDisable()
Incremente m_timerEnable
Returns:
TRUE if m_timerEnable>TIME_ENABLE
See also: CSprite,
Draw
- public void Draw()
Draw sprite for current direction
IncLife
- public virtual char IncLife(char inc)
m_life+=inc
For damage use inc<0
Returns:
m_life
SetDamaged
- public virtual void SetDamaged()
Activate damaged animation and set m_lifeState to LIFE_STATE_DAMAGE
SetEnable
- public inline void SetEnable()
Call CBaseSpr::SetEnable()
and set m_timerEnable to 0
See also: CBaseSpr#SetEnable(),
SetKilled
- public virtual void SetKilled()
Activate killed animation and set m_lifeState to LIFE_STATE_KILL
When animation is finished set m_lifeState to LIFE_STATE_DIED
Returns:
TRUE if enemy can move, else FALSE