The Essential Guide to HTML5

(Greg DeLong) #1

MAZES


Code Explanation


drawall(); Draw everything (will show growing wall)


} Close if inmotion


} Close function


function finish(ev) { Function header finish


inmotion = false; Set inmotion to false


walls.push(curwall); Add curwall to walls


} Close function


function drawall() { Function header drawall


ctx.clearRect(0,0,cwidth,cheight); Erase whole canvas


var i; Index


for (i=0;i<everything.length;i++) { Loop through everything


everything[i].draw(); Draw everything


} Close loop


} Close function


function getkeyAndMove(event) { Function header getkeyAndMove


var keyCode; Hold keyCode


if(event == null) { If event null


keyCode = window.event.keyCode; Get keyCode using window.event


Window.event.preventDefault(); Stop default action


} Close clause


else { Else

Free download pdf