HTML5 Canvas [227]
ball.nexty = (ball.y += ball.velocityy);
}
}
function testWalls() {
var ball;
var testBall;
for (var i = 0; i if (ball.nextx+ball.radius > theCanvas.width) { ball.velocityx = ball.velocityx*-1; ball.nextx = theCanvas.width - ball.radius; } else if (ball.nextx-ball.radius < 0 ) { ball.velocityx = ball.velocityx*-1; ball.nextx = ball.radius; } else if (ball.nexty+ball.radius > theCanvas.height ) { ball.velocityy = ball.velocityy*-1; ball.nexty = theCanvas.height - ball.radius; } else if(ball.nexty-ball.radius < 0) { ball.velocityy = ball.velocityy*−1; ball.nexty = ball.radius; } } } function render() { var ball; for (var i =0; i ball = balls[i]; ball.x = ball.nextx; ball.y = ball.nexty; context.fillStyle = ball.usercolor; context.beginPath(); context.arc(ball.x,ball.y,ball.radius,0,Math.PI*2,true); context.closePath(); context.fill(); } } }