The Pinball Game
Ian Parberry's "Introduction to Game Physics"
Public Member Functions | Private Attributes | List of all members
CFlipper Class Reference

A flipper. More...

#include <Parts.h>

Inheritance diagram for CFlipper:
CCommon

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 Protected Attributes inherited from CCommon
static CRendererm_pRenderer = nullptr
 Pointer to the renderer.
 
static CObjectManagerm_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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CFlipper()

CFlipper::CFlipper ( CCompoundShape *  p,
bool  bCCW 
)

Flippers are compound shapes made up of 2 circles and 2 line segments.

Parameters
pPointer to compound shape for flipper.
bCCWtrue if counterclockwise is up.

Member Function Documentation

◆ EnforceBounds()

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.

◆ Flip()

void CFlipper::Flip ( bool  bUp)

If flipper isn't moving up, set its rotational velocity to ROTSPEED (with the correct sign indicating direction),.

Parameters
bUptrue for up flip, false for down flip.