The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 8


Code Explanation


} Close clause


var i; Used for indexing over the different symbols


for (i=0;i<everything.length;i++){ For header for indexing over the elements in
the everything array, namely the three
symbols


var ch = everything[i]; Get the ith element


if
((mx>ch.sx)&&(mx<ch.sx+ch
.bwidth)&&(my>ch.sy)&&(my<ch.sy+ch.bheight))
{


Check if the mx, my position is within the
bounds (the outer rectangle bounds) for this
symbol

drawall(); If so, invoke the drawall function, which will
erase everything and then draw everything in
the everything array


size = 15; Initial size of computer-move image


tid = setInterval
(flyin,100);


Set up timed event

result = beats
[compch][i];


Set the result message. See the section
below the table for the addition for audio.

newscore =
Number(document.f.score.value);


Get the current score, converted to a number

newscore +=
points[compch][i];


Add the adjustment and save to be displayed
later

break; Leave the for loop


} End the if clause


} End the for loop


} End the function


function flyin() { Header for the function handling the timed
interval event

Free download pdf