Student Project |
|||
|
|
|||
| Bouncing Ball | |||
| Ability Level: | Intermediate | ||
| Estimated Time: | 3-4 hours | ||
| Objectives: |
|
||
| Materials and Resources: |
|
||
| Overview: | Create a colored ball which bounces inside of a box.
It should pong off of the sides, top, or bottom. Add a button to start and stop
the ball. |
||
| Instructions: |
| ||
| Hints: |
One possible method is to create 2 global integer variables x and y that contain the amount that the ball moves horizontally and vertically each timer call. To move the ball, add these variables to the ball's Top and Left attributes. Look at the ball's Top, Left, Height and Width along with the lines' X1 and Y1 attributes to see if the ball has hit a line. If the ball hits a horizontal line, it's vertical movement variable should change sign from positive to negative (ball changes direction) and if the ball hits a vertical line, it's horizontal movement should change sign. PROJECT EXTRAS
| ||