A car consisting of a body and two wheels, and a bridge to run on.
#include <Car.h>
|
| | CCarAndBridge () |
| | Constructor.
|
| |
|
| ~CCarAndBridge () |
| | Destructor.
|
| |
| void | Move () |
| | Reverse the car when it gets near the edges.
|
| |
| void | Action () |
| | Reverse the car.
|
| |
| | CLevel (eSprite) |
| |
| virtual | ~CLevel () |
| | Default constructor.
|
| |
| virtual void | Draw () |
| | Draw objects in level.
|
| |
|
|
b2WheelJoint * | m_pWheelJoint1 = nullptr |
| | Pointer to a wheel joint.
|
| |
|
b2WheelJoint * | m_pWheelJoint2 = nullptr |
| | Pointer to a wheel joint.
|
| |
|
CObject * | m_pCarObject = nullptr |
| | Pointer to car object.
|
| |
|
| CLineObject * | CreateLine (b2Body *, const b2Vec2 &, bool, b2Body *, const b2Vec2 &, bool) |
| | Create new line object.
|
| |
|
std::vector< CObject * > | m_stdObject |
| | Object pointers.
|
| |
|
std::vector< CLineObject * > | m_stdLine |
| | Line list.
|
| |
|
eSprite | m_eBgSprite |
| | Type of background sprite.
|
| |
|
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.
|
| |
◆ CCarAndBridge()
| CCarAndBridge::CCarAndBridge |
( |
| ) |
|
Create a car and a bridge for it to run on.
◆ Action()
| void CCarAndBridge::Action |
( |
| ) |
|
|
virtual |
Reverse the car by changing the sign of the motor speed on the wheel joints.
Reimplemented from CLevel.
◆ CreateBridge()
| void CCarAndBridge::CreateBridge |
( |
float | x, |
|
|
float | y ) |
|
private |
Create the bridge from platforms and ramps.
- Parameters
-
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |
◆ CreateCar()
| void CCarAndBridge::CreateCar |
( |
float | x, |
|
|
float | y ) |
|
private |
Create the car body and wheels and attach the wheels to the body using wheel joints.
- Parameters
-
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |
◆ CreateCarBody()
| b2Body * CCarAndBridge::CreateCarBody |
( |
float | x, |
|
|
float | y ) |
|
private |
Create the car object with its body at a given point in Physics World.
- Parameters
-
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |
- Returns
- Pointer to the car body in Physics World.
◆ CreatePlatform()
| void CCarAndBridge::CreatePlatform |
( |
float | x, |
|
|
float | y ) |
|
private |
Create a horizontal platform.
- Parameters
-
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |
◆ CreateRampDown()
| void CCarAndBridge::CreateRampDown |
( |
float | x, |
|
|
float | y ) |
|
private |
Creat a ramp going down from left to right.
- Parameters
-
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |
◆ CreateRampUp()
| void CCarAndBridge::CreateRampUp |
( |
float | x, |
|
|
float | y ) |
|
private |
Creat a ramp going up from left to right.
- Parameters
-
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |
◆ CreateWheel()
| b2Body * CCarAndBridge::CreateWheel |
( |
float | x, |
|
|
float | y ) |
|
private |
Create a car wheel at a given point in Physics World.
- Parameters
-
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |
- Returns
- Pointer to the wheel's body in Physics World.
◆ Move()
| void CCarAndBridge::Move |
( |
| ) |
|
|
virtual |
Ensure that the car reverses direction before hitting the left or right edge of the window. All other aspects of motion are, of course, handled by Box2D. This function assumes that the car wass the first object created.
Reimplemented from CLevel.