Top-down Shooter With Sprite Sheets
A Top-Down Shooter With Sprite Sheets and Sprite Animation
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CAnt Class Reference

The ant object. More...

#include <Ant.h>

Inheritance diagram for CAnt:
CObject CCommon

Public Member Functions

 CAnt (const Vector2 &)
 Constructor. More...
 
 ~CAnt ()
 Destructor.
 
virtual void move ()
 Move ant. More...
 
- Public Member Functions inherited from CObject
 CObject (eSprite, const Vector2 &)
 Constructor. More...
 
virtual ~CObject ()
 Destructor.
 
void move ()
 Move object. More...
 
void draw ()
 Draw object. More...
 
const bool isBullet () const
 Is a bullet. More...
 

Protected Member Functions

virtual void CollisionResponse (const Vector2 &, float, CObject *=nullptr)
 Collision response. More...
 
void StrayFromPath ()
 Stray randomly from path. More...
 
void UpdateFramenumber ()
 Update frame number. More...
 
- Protected Member Functions inherited from CObject
virtual void DeathFX ()
 Death special effects. More...
 
const Vector2 GetViewVector () const
 Compute view vector. More...
 

Protected Attributes

LEventTimer * m_pFrameEvent = nullptr
 Frame event timer.
 
LEventTimer * m_pStrayEvent = nullptr
 Stray event timer.
 
bool m_bStrayParity = true
 Stray from path left or right.
 
bool m_bPreferPosRot = true
 Prefer positive rotation.
 
- Protected Attributes inherited from CObject
float m_fRadius = 0
 Bounding circle radius.
 
float m_fSpeed = 0
 Speed.
 
float m_fRotSpeed = 0
 Rotational speed.
 
Vector2 m_vVelocity
 Velocity.
 
bool m_bStatic = true
 Is static (does not move).
 
bool m_bIsTarget = true
 Is a target.
 
bool m_bIsBullet = false
 Is a bullet.
 
LEventTimer * m_pGunFireEvent = nullptr
 Gun fire event.
 

Friends

class CObjectManager
 Object manager is a friend.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static LSpriteRenderer * m_pRenderer = nullptr
 Pointer to renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to object manager.
 
static LParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static Vector2 m_vWorldSize = Vector2::Zero
 World height and width.
 
static CPlayerm_pPlayer = nullptr
 Pointer to player character.
 

Detailed Description

CAnt is the abstract representation of an ant object.

Constructor & Destructor Documentation

◆ CAnt()

CAnt::CAnt ( const Vector2 &  pos)

Create and initialize an ant object given its initial position.

Parameters
posInitial position of ant.

Member Function Documentation

◆ CollisionResponse()

void CAnt::CollisionResponse ( const Vector2 &  norm,
float  d,
CObject pObj = nullptr 
)
protectedvirtual

Response to collision. If the ant is facing the object that is colliding with, then it rotates in its preferred direction and then calls CObject::CollisionResponse. Note that the only reason that colliding ants won't be facing each other is in the case of multiple ants colliding and pushing one of them in some direction other than the one in which it is facing. Howerver, faster objects such as the player objact can collide from behind.

Parameters
normCollision normal.
dOverlap distance.
pObjPointer to object being collided with (defaults to nullptr, which means collision with a wall).

Reimplemented from CObject.

◆ move()

void CAnt::move ( )
virtual

Move and advance current frame number. Also stray randomly from current path.

◆ StrayFromPath()

void CAnt::StrayFromPath ( )
protected

Adjust direction randomly at random intervals.

◆ UpdateFramenumber()

void CAnt::UpdateFramenumber ( )
protected

Update the frame number in the animation sequence.