THE MEMORY (AKA CONCENTRATION) GAME
firstcard = i; ...Set firstcard to
reference the card in
the deck
firstpick = false; Set firstpick to
false
pick1 = new
Polycard(card.sx+cardwidth.5,card.sy+cardheight.5,cardrad,car
d.info);
Create polygon with
its coordinates at the
center
pick1.draw(); Draw polygon
} Close if first pick
else { Else...
secondcard = i; ...Set secondcard to
reference the card in
the deck
pick2 = new
Polycard(card.sx+cardwidth.5,card.sy+cardheight.5,cardrad,car
d.info);
Create polygon with
its coordinates at the
center
pick2.draw(); Draw polygon
if (deck[i].info==deck[firstcard].info) { Check for a match
matched = true; Set matched to true
var nm =
1+Number(document.f.count.value);
Increment the number
of matches
document.f.count.value = String(nm); Display the new count
if (nm>= .5*deck.length) { Check if the game is
over
var now = new Date(); Get new Date info
var nt = Number(now.getTime()); Extract and convert
the time
var seconds = Math.floor(.5+(nt-
starttime)/1000);
Compute the seconds
elapsed