NOTE:
Exercise X8 is merely a warm-up exercise,
to be replaced and superseded by project 8.
You may do exrcise X8 with or without classes, but
but project 8 must use Object-Oriented classes, as described.
|
Exercise X8: Billiards (pool) table, with three bouncing balls.
A light-blue, rectangular table, occupies most of the screen.
Three colored balls (RED, GREEN, BLUE),
each with random horizontal and vertical velocities (dx and dy),
bounce off the boundaries (left, top, right, bottom)
of the rectangle.
...
[image goes here]
....
|
When the mouse is clicked INSIDE the button,
re-start all three balls
at the left side,
EACH one with a random height and random velocities (dx and dy).
Also, respond as follows when a key is pressed:
- When the '1' key is pressed, start the RED ball from the left.
- When the '2' key is pressed, start the GREEN ball from the left.
- When the '3' key is pressed, start the BLUE ball from the left.
Display a (rectangular) button.
The first time this button is clicked, change the table to another color;
if it is clicked again, change table back to original color.