The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 7


Code Explanation


sw = wallstgs[i].split("+"); Split individual item


sx = Number(sw[0]); Extract 0th value and convert to number


sy = Number(sw[1]); ...1st


fx = Number(sw[2]); ...2nd


fy = Number(sw[3]); ...3rd


curwall = new
Wall(sx,sy,fx,fy,wallwidth,wallstyle);


Create new Wall using extracted and
fixed values

walls.push(curwall); Add to walls array


everything.push(curwall); Add to everything array


} Close loop


drawall(); Draw everything


} Close if not null


Else { Was null


alert("No data retrieved."); No data


} Close clause


window.addEventListener('keydown',
getkeyAndMove,false);


Set up keydown action

return false; Return false to prevent refresh


} Close function


End head element
Start body, set up call to init
Canvas tag

Your browser doesn't support the HTML5 element
canvas.


Warning for certain browser.
Free download pdf