SAGE
A Simple Academic Game Engine
Loading...
Searching...
No Matches
Sage::CObjectManager< obj > Class Template Reference

A basic object manager. More...

#include <SageObjectManager.h>

Inheritance diagram for Sage::CObjectManager< obj >:
Collaboration diagram for Sage::CObjectManager< obj >:

Public Member Functions

 CObjectManager ()
 Constructor.
 
 ~CObjectManager ()
 Destructor.
 
virtual void Insert (obj *)
 Create object.
 
virtual void Clear ()
 Reset to empty and delete all objects.
 
virtual void Move ()
 Move all objects.
 
virtual void Draw ()
 Draw all objects.
 

Protected Member Functions

virtual void BroadPhase ()
 Broad phase.
 
virtual void NarrowPhase (obj *, obj *)
 Narrow phase.
 
virtual void DeleteMarkedObjects ()
 Cull dead objects.
 

Protected Attributes

std::list< obj * > m_stdObjectList
 The object list.
 

Additional Inherited Members

- Static Protected Attributes inherited from Sage::CComponent
static std::unique_ptr< CTimerm_pTimer = std::make_unique<CTimer>()
 Pointer to a timer.
 
static std::unique_ptr< CRandomm_pRandom = std::make_unique<CRandom>()
 Pointer to a PRNG.
 
static std::unique_ptr< CSoundm_pSound = std::make_unique<CSound>()
 Pointer to sound manager.
 
static std::unique_ptr< CKeyboardm_pKeyboard
 Pointer to a keyboard handler.
 
static std::unique_ptr< CMousem_pMouse = std::make_unique<CMouse>()
 Pointer to a mouse handler.
 
static std::unique_ptr< CControllerm_pController
 Pointer to a controller.
 
- Static Protected Attributes inherited from Sage::CSettings
static char m_szName [MAX_PATH]
 Name of this game.
 
static int m_nWinWidth = 0
 Window width in pixels.
 
static int m_nWinHeight = 0
 Window height in pixels.
 
static Vector2 m_vWinCenter = Vector2::Zero
 Window center.
 

Detailed Description

template<class obj>
class Sage::CObjectManager< obj >

A list of game objects with some basic management functions and broad phase collision detection and response. This class is templated so that it can be used to manage game objects declared in individual games. Your game should instantiate it with your game object class, which must be derived from CSage::CObject.

Template Parameters
objObject class.

Constructor & Destructor Documentation

◆ CObjectManager()

template<class obj >
Sage::CObjectManager< obj >::CObjectManager ( )

Default constructor.

Template Parameters
objObject class.

◆ ~CObjectManager()

template<class obj >
Sage::CObjectManager< obj >::~CObjectManager ( )

The destructor deletes all of the objects in the object list.

Template Parameters
objObject class.

Member Function Documentation

◆ BroadPhase()

template<class obj >
void Sage::CObjectManager< obj >::BroadPhase ( )
protectedvirtual

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

Template Parameters
objObject class.

◆ Clear()

template<class obj >
void Sage::CObjectManager< obj >::Clear ( )
virtual

Delete all of the object instances pointed to by the object list, then clear the object list of all pointers so that the object list is empty.

Template Parameters
objObject class.

◆ DeleteMarkedObjects()

template<class obj >
void Sage::CObjectManager< obj >::DeleteMarkedObjects ( )
protectedvirtual

Iterate through the objects and check whether each one is ready to delete. If so, then delete it and remove its pointer from the object list.

Template Parameters
objObject class.

◆ Draw()

template<class obj >
void Sage::CObjectManager< obj >::Draw ( )
virtual

Move all objects by iterating through all objects in the object list and calling their draw functions.

Template Parameters
objObject class.

◆ Insert()

template<class obj >
void Sage::CObjectManager< obj >::Insert ( obj * pObj)
virtual

Insert object.

Insert object into object list.

Parameters
pObjPointer to object.

◆ Move()

template<class obj >
void Sage::CObjectManager< obj >::Move ( )
virtual

Move all objects by iterating through all objects in the object list and calling their move functions. Perform broad phase collision detection and response, then delete any dead objects from the object list.

Template Parameters
objObject class.

◆ NarrowPhase()

template<class obj >
void Sage::CObjectManager< obj >::NarrowPhase ( obj * p0,
obj * p1 )
protectedvirtual

Perform collision detection and response for a pair of objects. This function is a stub.

Template Parameters
objObject class.
Parameters
p0Pointer to the first object.
p1Pointer to the second object.