Box2D Cannon Game with Stars
Chapter 8 of Ian Parberry's "Introduction to Game Physics with Box2D"
 All Classes Files Functions Variables Enumerations Friends Pages
Public Member Functions | Public Attributes | Friends | List of all members
CObjectWorld Class Reference

The object world. More...

#include <objectworld.h>

Public Member Functions

CParticlecreate (GameObjectType t, int lifespan)
 
CGameObjectcreate (GameObjectType t)
 Create new object.
 
CGameObjectCreateHudObject (GameObjectType t)
 Create new object.
 
void SetWorldSize (float width, float height)
 Set the Object World width and depth.
 
void GetWorldSize (float &width, float &height)
 Get the Object World width and depth.
 
BOOL PlayerHasWon (float level)
 Detect whether the player has won.
 
void clear ()
 Clear objects and particles.
 
void move ()
 Move objects and particles.
 
void draw ()
 

Public Attributes

CCannon m_cCannon
 The cannon.
 

Friends

BOOL KeyboardHandler (WPARAM k)
 

Detailed Description

The object world.

Member Function Documentation

CParticle * CObjectWorld::create ( GameObjectType  t,
int  lifespan 
)

Create a particle in the Object World.

Parameters
tObject type.
lifespanAmount of time that particle is to live from creation.
Returns
Pointer to the particle created.
CGameObject * CObjectWorld::create ( GameObjectType  t)

Create new object.

Create an object in the Object World.

Parameters
tObject type.
Returns
Pointer to the object created.
CGameObject * CObjectWorld::CreateHudObject ( GameObjectType  t)

Create new object.

Create a HUD object in the Object World.

Parameters
tObject type.
Returns
Pointer to the object created.
void CObjectWorld::draw ( )

Draw everything in the Object World. Draw the game objects, then the particles, then the HUD in that order using Painter's Algorithm.

void CObjectWorld::GetWorldSize ( float &  width,
float &  height 
)

Get the Object World width and depth.

Get the Object World's width and height.

Parameters
widthCalling parameter will be set to Object World width.
heightCalling parameter will be set to Object World height.
BOOL CObjectWorld::PlayerHasWon ( float  level)

Detect whether the player has won.

Determine whether player has won.

Parameters
levelProportion of Object World height that the blocks must be below to win.
Returns
TRUE if player has won.
void CObjectWorld::SetWorldSize ( float  width,
float  height 
)

Set the Object World width and depth.

Set the Object World's width and height.

Parameters
widthObject World width.
heightObject World height.

Friends And Related Function Documentation

BOOL KeyboardHandler ( WPARAM  k)
friend

Keyboard handler. Take the appropriate action when the user mashes a key on the keyboard.

Parameters
kVirtual key code for the key pressed
Returns
TRUE if the game is to exit