The Essential Guide to HTML5

(Greg DeLong) #1

THE MEMORY (AKA CONCENTRATION) GAME


var tablecolor = "rgb(255,255,255)"; Set the color value for
the board (table)


var cardrad = 30; Set the radius for the
polygons


var deck = []; Declare the deck,
initially an empty array


var firstsx = 30; Set the position in x of
the first card


var firstsy = 50; Set the position in y of
the first card


var margin = 30; Set the spacing
between cards


var cardwidth = 4*cardrad; Set the card width to
four times the radius
of the polygons


var cardheight = 4*cardrad; Set the card height to
four times the radius
of the polygons


var matched; This variable is set in
choose and used in
flipback


var starttime; This variable is set in
init and used to
calculate elapsed time


function Card(sx,sy,swidth,sheight,info) { Header for the Card
function, setting up
card objects


this.sx = sx; Set the horizontal
coordinate


this.sy = sy; ... vertical coordinate


this.swidth = swidth; ... width

Free download pdf