> Home > Graphics > Bouncing Ball

Bouncing Ball

In a Nutshell: This simple Javascript demonstrates how a ball (or other object) can be set to bounce around the screen - changing direction when it hits the edge. Rather mesmerizing to look at, this resembles some of the screensaver effects that used to be popular back in the day.

 

Use it Yourself: Copy the code from below and paste it within the <head> section of your HTML code (or in your CSS file). This is the portion that determines the appearance of the object being moved - in this case a red circle.

Next, the following Javascript component must be placed within the <body> section of your HTML code. The div element creates the ball object, and the Javascript snippet controls the starting position, speed of travel, collision detection and change of direction.

This Script Created By: Joshua Smith + OpenAI

HOME   |   Newest   |   Most Popular   |   Tutorials   |   Submit a Script   |   Email Us


Copyright © 1999-2025 Curiosity Cave Pty Ltd. All rights by all media reserved. All elements on this site, including page design, contents and graphics (with the obvious exception of the free Javascripts) may not be reproduced, broadcast, rewritten or redistributed in whole or in part without the expressed written permission of Curiosity Cave Pty Ltd.