HTML and CSS Reference
In-Depth Information
Code
Explanation
function Ball(sx,sy,rad,stylestring) {
this.sx = sx;
this.sy = sy;
this.rad = rad;
this.draw = drawball;
this.moveit = moveball;
this.fillstyle = stylestring;
}
function drawball() {
ctx.fillStyle=this.fillstyle;
ctx.beginPath();
//ctx.fillStyle= rgb(0,0,0);
ctx.arc(this.sx,this.sy,this.rad,
0,Math.PI*2,true);
ctx.fill();
}
function moveball(dx,dy) {
this.sx +=dx;
this.sy +=dy;
}
var cball = new Ball(cannonx+cannonlength,
cannony+cannonht*.5,ballrad,"rgb(250,0,0)");
Search WWH ::




Custom Search