HTML and CSS Reference
In-Depth Information
document.getElementById("speedy").value = s;
}
function setNewPoint(d) {
try{
switch (horizontal) {
case true:
if (x < (w - r) && hd == "r")
x += s;
else if(x > r && hd == "l")
x -= s;
break;
case false:
if (y < (h - r) && hd == "d")
y += s;
else if (y > r && hd == "u")
y -= s;
break;
}
if (x >= (w - r))
hd = "l";
if (x <= r)
hd = "r";
if (y >= (h - r))
hd = "u";
if (y <= r)
hd = "d";
} catch (e) {
alert(e.message);
}
}
function getDirection() {
horizontal = !horizontal;
var d = Math.ceil(Math.random() * 2);
if (horizontal) {
if (d == 1) {
hd = "r";
} else {
hd = "l";
}
} else {
if (d == 1) {
hd = "u";
} else {
hd = "d";
}
}
}
function drawBall() {
try {
var rgbFill = "rgb(0,0,0)";
var rgbStroke = "rgb(128,128,128)";
setNewPoint(d);
var ctxt = c.getContext("2d");
Search WWH ::




Custom Search