Top-down Shooter With Sprite Sheets
A Top-Down Shooter With Sprite Sheets and Sprite Animation
Public Member Functions | Private Member Functions | List of all members
CObjectManager Class Reference

The object manager. More...

#include <ObjectManager.h>

Inheritance diagram for CObjectManager:
CCommon

Public Member Functions

CObjectcreate (eSprite, const Vector2 &)
 Create new object. More...
 
void FireGun (CObject *, eSprite)
 Fire object's gun. More...
 
void FindClosest (const Vector2 &, CObject *&, float &)
 Find close objects. More...
 

Private Member Functions

void BroadPhase ()
 Broad phase collision detection and response. More...
 
void NarrowPhase (CObject *, CObject *)
 Narrow phase collision detection and response. More...
 
bool AtWorldEdge (CObject *, Vector2 &, float &) const
 Test whether at the edge of the world. More...
 

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

A collection of all of the game objects.

Member Function Documentation

◆ AtWorldEdge()

bool CObjectManager::AtWorldEdge ( CObject p,
Vector2 &  norm,
float &  d 
) const
private

Test whether an object's left, right, top or bottom edge has crossed the left, right, top, bottom edge of the world, respectively. If so, then the object's position is corrected. This function assumes that the bottom left corner of the world is at the origin.

Parameters
pPointer to an object.
norm[out] Collision normal.
d[out] Overlap distance.
Returns
true if the object overlaps the edge of the world.

◆ BroadPhase()

void CObjectManager::BroadPhase ( )
private

Perform collision detection and response for each object with the world edges and for all objects with another object, making sure that each pair of objects is processed only once.

◆ create()

CObject * CObjectManager::create ( eSprite  t,
const Vector2 &  pos 
)

Create an object and put a pointer to it at the back of the object list m_stdObjectList, which it inherits from LBaseObjectManager.

Parameters
tSprite type.
posInitial position.
Returns
Pointer to the object created.

◆ FindClosest()

void CObjectManager::FindClosest ( const Vector2 &  pos,
CObject *&  pObj,
float &  dsq 
)

Find target closest to a position.

Parameters
pos[in] Position.
pObj[out] Pointer to closest target, NULL if not found.
dsqDistance to closest object squared.

◆ FireGun()

void CObjectManager::FireGun ( CObject pObj,
eSprite  bullet 
)

Create a bullet object and a flash particle effect. It is assumed that the object is round and that the bullet appears at the edge of the object in the direction that it is facing and continues moving in that direction.

Parameters
pObjPointer to an object.
bulletSprite type of bullet.

◆ NarrowPhase()

void CObjectManager::NarrowPhase ( CObject p0,
CObject p1 
)
private

Perform collision detection and response for a pair of objects. Makes use of the helper function Identify() because this function may be called with the objects in an arbitrary order.

Parameters
p0Pointer to the first object.
p1Pointer to the second object.