The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 5


pica = new Image(); Create the Image
object

pica.src = pairs[i][0]; Set to the first file

acard = new Card(cx,cy,cardwidth,cardheight,pica,i); Create Card

deck.push(acard); (^)
picb = new Image(); Create the Image
object
picb.src = pairs[i][1]; Set to second file
bcard = new
Card(cx,cy+cardheight+margin,cardwidth,cardheight,picb,i);
Create Card
deck.push(bcard);
cx = cx+cardwidth+ margin;
acard.draw();
bcard.draw();
}
}
function shuffle() {
var i;
var k;
var holderinfo; Temporary place for
the swap
var holderimg; Temporary place for
the swap
var dl = deck.length
var nt;
for (nt=0;nt<3*dl;nt++) { //do the swap 3 times
deck.length times

Free download pdf