Box2D Binary Counter
Game Physics with a 2D Physics Engine
Loading...
Searching...
No Matches
CObject Class Reference

The game object. More...

#include <Object.h>

Inheritance diagram for CObject:
Collaboration diagram for CObject:

Public Member Functions

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

Private Attributes

eSprite m_eSprite = eSprite(0)
 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 Sage::CParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static eGameState m_eGameState = eGameState::Loading
 Current game state.
 
static CCounterm_pCounter = nullptr
 Pointer to a counter.
 
static UINT m_nCurNum = 0
 Current number.
 
static eDrawMode m_eDrawMode = eDrawMode::Sprites
 Draw mode.
 

Detailed Description

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 )

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 ( )

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

Member Function Documentation

◆ draw()

void CObject::draw ( )

Position and orientation must be gotten from Physics World.

Here is the call graph for this function:

◆ GetPos()

Vector2 CObject::GetPos ( )

Reader function for position in Render World.

Returns
Position in Render World coordinates.
Here is the call graph for this function:

◆ GetSpeed()

float CObject::GetSpeed ( )

Reader function for speed in Render World.

Returns
Speed in Render World units.
Here is the call graph for this function:

◆ GetSpriteType()

eSprite CObject::GetSpriteType ( )

Reader function for sprite type.

Returns
Sprite type.
Here is the caller graph for this function: