Box2D Joint Toy
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...
 
const Vector2 GetPos () const
 Get position in Render World. More...
 
const eSprite GetSpriteType () const
 Get sprite type. More...
 

Private Attributes

eSprite m_eSpriteType = 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 CWindmillm_pWindmill = nullptr
 Pointer to windmill.
 
static CGearm_pGear = nullptr
 Pointer to gear system.
 
static CNautilusGearm_pNautilusGear = nullptr
 Pointer to Nautilus gear system.
 
static CRackAndPinionm_pRackAndPinion = nullptr
 Pointer to rack-and-pinion.
 
static CCarm_pCar = nullptr
 Pointer to car.
 
static CRampm_pRamp = nullptr
 Pointer to ramp.
 
static CNewtonsCradlem_pNewtonsCradle = nullptr
 Pointer to Newton's Cradle.
 
static CPulleym_pPulley = nullptr
 Pointer to pulley system.
 
static eLevel m_eCurLevel = eLevel::Windmill
 Current level.
 

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.

Draw in Render World. Position and orientation must be gotten from Physics World.

◆ GetPos()

const Vector2 CObject::GetPos ( ) const

Get position in Render World.

< Reader function for position.

Returns
Position in Render World units.

◆ GetSpriteType()

const eSprite CObject::GetSpriteType ( ) const

Get sprite type.

< Reader function for the sprite type.

Returns
The sprite type.