Graphics Reference
In-Depth Information
Source File.
Model.h file
class CModel {
in
the Model
folder
of
the
D3D _ SimulateGravity
project.
A: Similar to CModel from Tutorial 5.2
void CreateHeroBall(x, y);
// Create the Ball/Circle at (x,y)
void ResizeHeroBall(x, y);
// Resize the Ball such that (x,y) passes through circumference
void MoveHeroBallTo(x, y);
// Move the center of the Ball to (x,y)
void DrawModel();
// Draw the Ball (circle)
B: Methods to support behaviors of the free-falling ball.
void SetWorldSize( float width, float height);
void SetHeroBallAnimation( bool on);
C: Simulate the free falling ball.
void UpdateSimulation();
D: Internal representations.
CBall m _ Ball;
// the ball
bool m _ bAnimatingBall;
// should the ball free fall?
float m _ WorldWidth, m _ WorldHeight;
// bounds of the window
clock _ tm _ previous _ update _ time;
// how much time has passed between UpdateSimulation calls
};
Listing 5.17. The CModel class (Tutorial 5.3).
In this case, the CModel has the following.
• (A) Familiar functionality to support the creation and editing of the circle
(or HeroBall ).
• (B) Proper support for simulation: the model must know when to begin sim-
ulation (after the mouse button releases) and the bounds for the simulation
(size of the application window).
Search WWH ::




Custom Search