HTML and CSS Reference
In-Depth Information
Code
Explanation
var target = new Myrectangle(300,100,
80,200,"rgb(0,5,90)");
Build a Myrectangle object and assign to target
Build a Myrectangle object and assign to ground
var ground = new Myrectangle(0,300,
600,30,"rgb(10,250,0)");
everything.push(target);
Add target to everything
everything.push(ground);
Add ground
everything.push(cball);
Add cball (which will be drawn last, so on top of other
stuff
function init(){
Header for init function
ctx = document.getElementById
('canvas').getContext('2d');
Set up ctx in order to draw on the canvas
drawall();
Draw everything
}
Close init
function fire() {
Head for fire function
cball.sx = iballx;
Reposition cball in x
cball.sy = ibally;
Reposition cball in y
horvelocity = Number(document.
f.hv.value);
Set horizontal velocity from form. Make a number
verticalvel1 = Number(document.
f.vv.value);
Set initial vertical velocity from form
drawall();
Draw everything
tid = setInterval
(change,100);
Start timing event
return false;
Return false to prevent refresh of HTML page
}
Close function
Search WWH ::




Custom Search