Graphics Reference
In-Depth Information
Ball-Shooting Program
Motion trajectory
for the next second
Motion
Current
Hero Ball
Velocity
Dragged
out balls
User
Slider bar
numeric echo
Application
Status
Slider
Velocity (X) 12.48 (Pixel/Sec)
Velocity (Y) 9.12 (Pixel/Sec)
Currently there are 5 balls on screen.
Status:
QUIT
Figure I.2. The ball-shooting program.
tance to the center defined in (A). The vector from the current position
to the center is the initial velocity V (in units of pixels per second).
Once created, the ball will begin traveling with the defined initial velocity.
HeroBall (hero/active object). The user can also right-mouse-button-
click to select a ball to be the current HeroBall .The HeroBall 's velocity
can be controlled by the slider bars (discussed below) where its velocity
is displayed. A newly created ball is by default the current HeroBall .
A right-mouse-button-click on unoccupied space indicates that no current
HeroBall exists.
Velocity slider bars (GUI elements). The user can monitor and control
two slider bars ( x -and y -directions with magnitudes) to change the velocity
of the HeroBall .
When there is no HeroBall , the slider-bar values are
undefined.
The simulation.
- Ball traveling/collisions (object intrinsic behaviors). A ball knows
how to travel based on its current velocity, and one ball can potentially
collide with another. For simplicity, we will assume that all balls have
identical mass and that all collisions are perfectly elastic.
 
Search WWH ::




Custom Search