HTML and CSS Reference
In-Depth Information
Code
Explanation
ctx.lineTo(this.s2x,this.s2y);
Set up to draw to
s2x,s2y
ctx.lineTo(this.s3x,this.s3y);
Draw to
s3x,s3y
ctx.stroke();
Now draw the path
}
Close function
function movesling(dx,dy) {
Header for
movesling
this.bx +=dx;
Add
dx
to
bx
this.by +=dy;
Add
dy
to
by
this.s1x +=dx;
Add
dx
to
slx
this.s1y +=dy;
Add
dy
to
s1y
this.s2x +=dx;
Add
dx
to
s2x
this.s2y +=dy;
Add
dy
to
s2y
this.s3x +=dx;
Add
dx
to
s3x
this.s3y +=dy;
Add
dy
to
s3y
}
Close function
var mysling= new
Sling(startrockx,startrocky,
startrockx+80,startrocky-10,startrockx+80,
startrocky+10,startrockx+70,
startrocky+180,"rgb(120,20,10)");
Build new
Sling
and assign it to the
mysling
variable
function Ball(sx,sy,rad,stylestring) {
this.sx = sx;
this.sy = sy;
this.rad = rad;
this.draw = drawball;