Graphic JavaScript


Back to index
Bouncing Ball

Your browser does not support the HTML5 canvas tag.

ASSIGNMENT:

Alter this example in the following ways:

  1. A single click of the mouse will freeze the ball in its current position
  2. A second click will cause the ball to resume movement
  3. Pressing the space bar will reset the values associated with the ball to their intial values
  4. Pressing the c key will cause the color of the ball to toggle between at least five different colors

The JavaScript source file is called bounce and this is the first lesson where the source has been external to the web page. By clicking on the name of the source file on the View Page Source page, you can view the source code file. Nothing too tricky here.