20. Ball Driving

Move the ball around the screen with a little control panel. Win when you get inside the target.

  • 1. Intro
  • You move a little ball around the screen by positioning your mouse inside the control center in the upper right corner of the screen. The position of the mouse relative to the “origin” of the axes in the control center detemines which way the ball will move (and how far). Motion is caused by mouse-events, so the ball does not move unless you are moving or clicking the mouse. When the ball is entirely inside the target circle, the game is over and you win.

  • 2. Starter Code
  • Starter code so everyone begins from the same spot.

  • 3. Controls
  • The basics of the control grid in the upper right.

  • 4. Motion
  • Actually moving the point according to the mouse position in the control grid.

  • 5. End Game
  • The game ends when the ball is completely inside the target.

  • 6. Animation
  • The functions to use with big-bang: draw handler, mouse handler.


1. Intro

2. Starter Code

Starter code so everyone begins from the same spot.

3. Controls

The basics of the control grid in the upper right.

4. Motion

Actually moving the point according to the mouse position in the control grid.

5. End Game

The game ends when the ball is completely inside the target.

6. Animation

The functions to use with big-bang: draw handler, mouse handler.