The Essential Guide to HTML5

(Greg DeLong) #1

CANNONBALL AND SL INGSHOT


Code Explanation


clearInterval(tid); If so, stop motion


} Close if true clause


drawall(); Draw everything


} Close change function


Close script element
Close head element
Open body and set call to init

<canvas id="canvas" width=
"600" height="400">


Define canvas

Your browser doesn't support
the HTML5 element canvas.


Warning to users of non-compliant browsers

Close canvas


Line break


<form name="f" id="f"
onSubmit="return fire();">


Starting form tag, with name and id. This sets up call to
fire.

Set velocities and fire
cannonball.


Label and line break

Horizontal displacement <input name=
"hv" id="hv" value="10" type=
"number" min="-100" max="100" />


Label and specification of input field


Line break


Initial vertical displacement <input
name="vv" id="vv" value="-25"
type="number" min="-100" max="100"/>


Label and specification of input field

Submit input element
Close form element
Free download pdf