![]() |
Box2D Binary Counter
Ian Parberry's "Introduction to Game Physics"
|
Single-bit counter. More...
#include <BitCounter.h>
Public Member Functions | |
CBitCounter (float, float, bool=false) | |
Constructor. More... | |
Vector2 | GetPos () |
Get position. More... | |
Private Member Functions | |
b2Body * | CreateBlock (eSprite, float x, float, bool=true) |
Create a block. More... | |
b2Body * | CreateRamp (float, float) |
Create a triangular ramp. More... | |
Private Attributes | |
b2Body * | m_pArm = nullptr |
Pointer to the body of the swing arm in Physics World. | |
Additional Inherited Members | |
![]() | |
static b2World * | m_pPhysicsWorld = nullptr |
Pointer to Box2D Physics World. | |
static CRenderer * | m_pRenderer = nullptr |
Pointer to the Renderer. | |
static CObjectManager * | m_pObjectManager = nullptr |
Pointer to the Object Manager. | |
static LParticleEngine2D * | m_pParticleEngine = nullptr |
Pointer to particle engine. | |
static eGameState | m_eGameState = eGameState::Start |
Current game state. | |
static CCounter * | m_pCounter = nullptr |
Pointer to a counter. | |
static UINT | m_nCurNum = 0 |
Current number. | |
Single-bit counter.
A single-bit counter in Physics World, consisting of two blocks, a ramp, a swing-arm, and two legs.
CBitCounter::CBitCounter | ( | float | x, |
float | y, | ||
bool | last = false |
||
) |
Constructor.
A bit-counter consists of a rempt, a ledge, a block, an arm, and two legs. All except the last one, that is. The last one is just a ledge.
x | X-coordinate in Render World. |
y | Y-coordinate in Render World. |
last | True if this is the last bit-counter. |
|
private |
Create a block.
Create a rectangular block in Physics World, given its Render World coordinates. Note that this is not relative to the location of the bit-counter.
t | Sprite type. |
x | X-coordinate in Render World. |
y | Y-coordinate in Render World. |
stat | true for a static block, false for a dynamic one. |
|
private |
Create a triangular ramp.
Create a static triangular ramp in Physics World, given its Render World coordinates. Note that this is not relative to the location of the bit-counter.
x | X-coordinate in Render World. |
y | Y-coordinate in Render World. |
Vector2 CBitCounter::GetPos | ( | ) |
Get position.
Reader function for the position of the arm in Render World coordinates.