Graphics Reference
In-Depth Information
class CApplicationModel {
private : Application's private state.
Source file. Pseudocode; no
corresponding source file.
Array<CBall * > AllBalls
// World balls, initially empty
CBAll HeroBall
// The Hero Ball
bool
DefiningNewHero
// If LMB drag is true
public : 1. Application state inquires.
bool IsDefinningHeroBall()
// If in the middle of defining a new hero ball
CBall * SelectedBall()
// Current hero ball is not null
int
NumBallsOnScreen()
// Number of balls currently on screen
2. Application state change from user events.
void
CreateHeroBall(mousePosition)
// center=mousePosition; radius=0; velocity=0
void
ResizeHeroBall(mousePosition)
// compute new radius and velocity
void
MoveSelectedBallTo(mousePosition)
// move hero to mousePosition, if no current hero NO-Op
void
AddHeroBallToWorld()
// done with current hero, insert into world balls
void
SelectBallAt(mousePosition)
// hero=ball at mousePosition, if none hero=NULL
3. Applicaiton state changes from application events.
void
UpdateSimulation()
// Move balls by their velocities,
// update velocity by gravity and remove off-screen ones
4. Application state visualization.
void
DrawModel( )
// Draw all the freefalling balls (including the HeroBall)
}
Listing 5.1. The model of the ball-shooting program.
Search WWH ::




Custom Search