Box2D Binary Counter
Game Physics with a 2D Physics Engine
Loading...
Searching...
No Matches
CBitCounter Class Reference

Single-bit counter. More...

#include <BitCounter.h>

Inheritance diagram for CBitCounter:
Collaboration diagram for CBitCounter:

Public Member Functions

 CBitCounter (float, float, bool=false)
 Constructor.
 
Vector2 GetPos ()
 Get position.
 

Private Member Functions

b2Body * CreateBlock (eSprite, float x, float, bool=true)
 Create a block.
 
b2Body * CreateRamp (float, float)
 Create a triangular ramp.
 

Private Attributes

b2Body * m_pArm = nullptr
 Pointer to the body of the swing arm in Physics World.
 

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 Sage::CParticleEngine2D * m_pParticleEngine = nullptr
 Pointer to particle engine.
 
static eGameState m_eGameState = eGameState::Loading
 Current game state.
 
static CCounterm_pCounter = nullptr
 Pointer to a counter.
 
static UINT m_nCurNum = 0
 Current number.
 
static eDrawMode m_eDrawMode = eDrawMode::Sprites
 Draw mode.
 

Detailed Description

A single-bit counter in Physics World, consisting of two blocks, a triangular ramp, a swing-arm, and two legs.

Constructor & Destructor Documentation

◆ CBitCounter()

CBitCounter::CBitCounter ( float x,
float y,
bool bIsLast = false )

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 the main block.

Parameters
xX-coordinate in Render World.
yY-coordinate in Render World.
bIsLastTrue if this is the last bit-counter.
Here is the call graph for this function:

Member Function Documentation

◆ CreateBlock()

b2Body * CBitCounter::CreateBlock ( eSprite t,
float x,
float y,
bool stat = true )
private

Create a rectangular block in Physics World, given its Render World coordinates. Note that this are world coordinates not local coordinates relative to the location of the bit-counter.

Parameters
tSprite type.
xX-coordinate in Render World.
yY-coordinate in Render World.
stattrue for a static block, false for a dynamic one.
Returns
Pointer to the Box2D body created.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateRamp()

b2Body * CBitCounter::CreateRamp ( float x,
float y )
private

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.

Parameters
xX-coordinate in Render World.
yY-coordinate in Render World.
Returns
Pointer to the Box2D body created.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPos()

Vector2 CBitCounter::GetPos ( )

Reader function for the position of the arm in Render World coordinates.

Returns
Position of the arm in Render World coordinates.
Here is the call graph for this function:
Here is the caller graph for this function: