The Essential Guide to HTML5

(Greg DeLong) #1

THE MEMORY (AKA CONCENTRATION) GAME


i = Math.floor(Math.random()*dl);


k = Math.floor(Math.random()*dl);


holderinfo = deck[i].info; Save the info


holderimg = deck[i].img; Save the img^


deck[i].info = deck[k].info; Put k's info into i


deck[i].img = deck[k].img; Put k's img into i


deck[k].info = holderinfo; Set to the original
info


deck[k].img = holderimg; Set to the original
img


}


}


function drawback() {


ctx.fillStyle = backcolor;


ctx.fillRect(this.sx,this.sy,this.swidth,this.sheight);


}


function choose(ev) {


var out;


var mx;


var my;


var pick1;


var pick2;


if ( ev.layerX || ev.layerX == 0) { Reminder: This is
the code for
handling
differences among
the three browsers

Free download pdf