The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 5


} Close the function

</script> Close the script
element

</head> Close head element

<body onLoad="init();"> Body tag, set up init

<canvas id="canvas" width="900" height="400"> Canvas start tag

Your browser doesn't support the HTML5 element canvas. Warning message

</canvas> Close canvas
element

<br/> Line break before
instructions

Click on two cards to see if you have a match. Instructions

<form name="f"> Form start tag

Number of matches: <input type="text" name="count" value="0"
size="1"/>

Label and input
element used for
output

<p> Paragraph br eak

Time taken to complete puzzle: <input type="text"
name="elapsed" value=" " size="4"/> seconds.

Label and input
element used for
output

</form> Close form

</body> Close body

</html> Close html

You can change this game by changing the font, font size, color, and background color for the form. More
ways to make the application your own are suggested later in this section.


The version of the memory game that uses pictures has much the same structure as the polygon version.
It doesnt require a separate function to draw the picture. Table 5-3 is the function listing for this version
of the game.

Free download pdf