![]() |
The Pinball Game
Ian Parberry's "Introduction to Game Physics"
|
A flipper. More...
#include <Parts.h>
Public Member Functions | |
CFlipper (CCompoundShape *, bool) | |
Constructor. More... | |
~CFlipper () | |
Destructor. | |
void | Flip (bool) |
Flip flipper. More... | |
void | EnforceBounds () |
Enforce bounds. More... | |
Private Attributes | |
CCompoundShape * | m_pFlipper = nullptr |
Pointers to flipper compound shapes. | |
bool | m_bFlipUp = false |
Flipper state. | |
bool | m_bCCW = false |
Whether it rotates counterclockwise for up. | |
Additional Inherited Members | |
![]() | |
static CRenderer * | m_pRenderer = nullptr |
Pointer to the renderer. | |
static CObjectManager * | m_pObjectManager = nullptr |
Pointer to the object manager. | |
static UINT | m_nMIterations = 4 |
Number of motion iterations. | |
static UINT | m_nCIterations = 1 |
Number of collision iterations. | |
static float | m_fFrequency = 60.0f*m_nMIterations |
Frequency, number of physics iterations per second. | |
static eDrawMode | m_eDrawMode = eDrawMode::Background |
Draw mode. | |
static bool | m_bBallInPlay = false |
Is there a ball currently in play? | |
static UINT | m_nScore = 0 |
Current score. | |
From Wikipedia: "The flippers are one or more small mechanically or electromechanically controlled levers, roughly 3 to 7 cm in length, used for redirecting the ball up the playfield. They are the main control that the player has over the ball. Careful timing and positional control allows the player to intentionally direct the ball in a range of directions with various levels of velocity. With the flippers, the player attempts to move the ball to hit various types of scoring targets, and to keep the ball from disappearing off the bottom of the playfield." CFlipper
implements one of those. It's made up of a couple of circles and a couple of line segments that are tangents to both of them.
CFlipper::CFlipper | ( | CCompoundShape * | p, |
bool | bCCW | ||
) |
Flippers are compound shapes made up of 2 circles and 2 line segments.
p | Pointer to compound shape for flipper. |
bCCW | true if counterclockwise is up. |
void CFlipper::EnforceBounds | ( | ) |
Enforce bounds on the orientation of flipper, assuming that if it rotates counterclockwise then it is a right flipper, otherwise it is a left flipper.
void CFlipper::Flip | ( | bool | bUp | ) |
If flipper isn't moving up, set its rotational velocity to ROTSPEED (with the correct sign indicating direction),.
bUp | true for up flip, false for down flip. |