The Box2D Blank Game
A Blank 2D Game with Box2D and a Contact Listener for Sounds
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 Update ()
 Update from Physics Engine.
 
const eSprite GetSpriteType () const
 Get sprite type. More...
 
const Vector2 GetPos () const
 Get position in renderer coordinates. More...
 
const float GetSpeed () const
 Get speed in renderer units. More...
 

Private Attributes

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.
 

Detailed Description

Game objects are responsible for remembering information about themselves, in particular, their representations in the Renderer 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

◆ GetPos()

const Vector2 CObject::GetPos ( ) const

Reader function for position in Render World.

Returns
Position in Render World coordinates.

◆ GetSpeed()

const float CObject::GetSpeed ( ) const

Reader function for speed in Render World.

Returns
Speed in Render World units.

◆ GetSpriteType()

const eSprite CObject::GetSpriteType ( ) const

Reader function for sprite type.

Returns
Sprite type.