Box2D Binary Counter
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Private Attributes | List of all members
CObject Class Reference

The game object. More...

#include <Object.h>

Inheritance diagram for CObject:
CCommon

Public Member Functions

 CObject (eSprite, b2Body *)
 Constructor. More...
 
 ~CObject ()
 Destructor. More...
 
void draw ()
 Draw object in Render World. More...
 
eSprite GetSpriteType ()
 Get sprite type. More...
 
Vector2 GetPos ()
 Get position in Render World coordinates. More...
 
float GetSpeed ()
 Get speed in Render World units. More...
 

Private Attributes

eSprite m_eSprite = eSprite::Size
 Sprite type.
 
b2Body * m_pBody = nullptr
 Physics World body.
 

Additional Inherited Members

- Static Protected Attributes inherited from CCommon
static b2World * m_pPhysicsWorld = nullptr
 Pointer to Box2D Physics World.
 
static CRendererm_pRenderer = nullptr
 Pointer to the Renderer.
 
static CObjectManagerm_pObjectManager = nullptr
 Pointer to the Object Manager.
 
static LParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static eGameState m_eGameState = eGameState::Start
 Current game state.
 
static CCounterm_pCounter = nullptr
 Pointer to a counter.
 
static UINT m_nCurNum = 0
 Current number.
 

Detailed Description

The game object.

Game objects are responsible for remembering information about themselves, in particular, their representations in Render World and Physics World.

Constructor & Destructor Documentation

◆ CObject()

CObject::CObject ( eSprite  t,
b2Body *  b 
)

Constructor.

This constructor assumes that a Physics World body has already been created for this object. It then has responsibility for deleting it in its destructor.

Parameters
tSprite type.
bPointer to Physics World body.

◆ ~CObject()

CObject::~CObject ( )

Destructor.

This destructor assumes that Box2D hasn't been shut down yet.

Member Function Documentation

◆ draw()

void CObject::draw ( )

Draw object in Render World.

Position and orientation must be gotten from Physics World.

◆ GetPos()

Vector2 CObject::GetPos ( )

Get position in Render World coordinates.

Reader function for position in Render World.

Returns
Position in Render World coordinates.

◆ GetSpeed()

float CObject::GetSpeed ( )

Get speed in Render World units.

Reader function for speed in Render World.

Returns
Speed in Render World units.

◆ GetSpriteType()

eSprite CObject::GetSpriteType ( )

Get sprite type.

Reader function for sprite type.

Returns
Sprite type.