Assignment

Create a DHTML screensaver like the one shown in Figure 13-24. The smiley face in the figure continually bounces around the screen. When it hits one of the walls, it bounces off at a random angle. To make the smiley face move diagonally, change its top and left positions in a timing loop. To get it to bounce off a wall, make it change directions when it hits one side of the screen. Remember, to make the smiley move right, you would add to its left property, and to make it move left, you would subtract from its left property.

A screensaver created with JavaScript

Figure 13-24. A screensaver created with JavaScript

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.