Graphics Reference
In-Depth Information
* drag event—move the center of the selected ball to the current
mouse pointer position;
* up event—ignored.
We allow the selected ball to continue free falling during the dragging
of the right mouse button.
Figure 5.10 is a screenshot of the free-falling balls from Tutorial 5.5. Upon close
examination of the application specification, we realize that our software libraries
are fully capable of supporting all the operations defined. All the programming
of this tutorial is limited to source code files located in the D3D _ MultipleBalls
project.
Figure 5.10.
Tutorial
5.5.
Model. When comparing to Tutorial 5.4, we have a significantly more
complex model. We must extend the CModel class functionality.
Controller. With more than one ball to work with, the service routines for
the left and right mouse button events must be updated accordingly.
Implementation
Examine the implementation of the model component in Listing 5.22. From the
private representation section of the CModel class, we see the m _ pHeroBall
// not shown are functions similar to Listing 5.17 from Tutorial 5.3
class CModel {
Source file. Model.h file
in the Model folder of the
D3D _ MultipleBalls project.
.
void MoveSelectedBallTo( float x, float y);
// move the selected ball to (x,y)
void AddHeroBallToWorld();
// insert the hero ball into the worldSet
int SelectBallAt( float x, float y);
// select the ball under position (x,y)
.
private :
CBall * m _ pHeroBall; // newly created hero ball
UWB _ Array<CBall> m _ AllBalls; // the collection of all balls
int m _ selected _ index;
// index of the selected ball
.
};
Listing 5.22. CModel class (Tutorial 5.5).
 
Search WWH ::




Custom Search