> 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