![]() |
Box2D Joint Toy
Game Physics with a 2D Physics Engine
|
The pulley class. More...
#include <Pulley.h>


Public Member Functions | |
| CPulley () | |
| Constructor. | |
| void | Move () |
| Rotate the pulley wheels. | |
| void | Action () |
| Create or delete elephant. | |
Public Member Functions inherited from CLevel | |
| CLevel (eSprite) | |
| virtual | ~CLevel () |
| Default constructor. | |
| virtual void | Draw () |
| Draw objects in level. | |
Private Member Functions | |
| void | CreateGround () |
| Create the ground. | |
| b2Body * | CreateWheel (float, float) |
| Create a pulley wheel. | |
| b2Body * | CreateCrate (float, float) |
| Create the elephant's crate. | |
| b2Body * | CreateObject (const b2Vec2 &, float, eSprite) |
| Create an object. | |
Additional Inherited Members | |
Protected Member Functions inherited from CLevel | |
| CLineObject * | CreateLine (b2Body *, const b2Vec2 &, bool, b2Body *, const b2Vec2 &, bool) |
| Create new line object. | |
Protected Attributes inherited from CLevel | |
| std::vector< CObject * > | m_stdObject |
| Object pointers. | |
| std::vector< CLineObject * > | m_stdLine |
| Line list. | |
| eSprite | m_eBgSprite |
| Type of background sprite. | |
Static Protected Attributes inherited from CCommon | |
| static b2World * | m_pPhysicsWorld = nullptr |
| Pointer to Box2D Physics World. | |
| static CBox2DRenderer * | m_pRenderer = nullptr |
| Pointer to the renderer. | |
| static CLevel * | m_pLevel = nullptr |
| Pointer to current level. | |
| static eLevel | m_eCurLevel = eLevel::Windmill |
| Current level. | |
| static eDrawMode | m_eDrawMode = eDrawMode::Sprites |
| Draw mode. | |
A pair of objects connected by a pulley joint, with a pair of pulley wheels that are animated in code.
|
virtual |
If there is an elephant, then delete it. If there is no elephant, then create one at its spawn point offset by a small pseudo-random amount to make the crate swing about. This function assumes that the elephant is the last thing created, that is, it is the last thing in the object list.
Reimplemented from CLevel.

|
private |
The bucket is the thing on the left that the elephant falls into. It consists of a left side, a right side, and a bottom, all of which are rectangles.
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |


|
private |
Create the ground, which is an edge in Physics World at the bottom of the window.


|
private |
Create an object, used for the safe and the elephant.
| v | Position in Physics World. |
| d | Object density. |
| t | Type of object to be created. |


|
private |
The pulley wheels are going to be static objects that we rotate ourselves depending on the positions of the objects that the pulley is attached to.
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |

|
virtual |
Animate the pulley wheels by setting their orientations to reflect the amount of rope that has gone over them.
Reimplemented from CLevel.