function Start() { /* System variables */
var frameDelay = 15;
var screen = document.getElementById('screen'); // Set up animation screen
var ctx = screen.getContext('2d'); // Set up animation screen
var out = document.getElementById('out'); // Set up information screen
var writeTo = out.getContext('2d'); // Set up information screen
var WIDTH = document.getElementById('screen').width;
var HEIGHT = document.getElementById('screen').height;
var WWIDTH = document.getElementById('out').width;
var WHEIGHT = document.getElementById('out').height; /* END */
/* Coordinate variables */
var X = 20;
var Y = 20; /* end */
/* Colour related variables */
var R = 0;
var G = 0;
var B = 0; /* end */
/* Object variables */
var xspeed = 1;
var yspeed = 1;
var radius = 10;
var lap = 0; /* end */
var pady = 0;
var paddlew = 10;
var paddleh = 50;
var space = 5;
var pts = 0;
var mousemoved = false;
function bounce() {
X += xspeed;
if (X <= 0 + radius) {
xspeed *= -1;
} else {
xspeed *= 1;
}
Y += yspeed;
if (Y >= (HEIGHT - radius) || Y <= 0 + radius) {
yspeed *= -1;
} else {
yspeed *= 1;
}
if(Y >= pady && Y < pady+paddleh && X >=(WIDTH-paddlew-space-radius) && X <= (WIDTH - space-radius)){
xspeed *= -1;
}
if(X >= WIDTH){
pts += 1;
X = 20;
Y = 20;
}
}
function paddle(){
ctx.beginPath();
ctx.fillStyle = 'blue';
if(pady === undefined){ pady = 0; } else if(pady+paddleh >= HEIGHT){pady = HEIGHT-paddleh; }
ctx.fillRect(WIDTH-space-paddlew,pady,paddlew,paddleh);
}
function write(what, whereX, whereY, colour, size) {
writeTo.textBaseline = 'top';
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.