3,4c3 < Canvas HTML Element Memories (Drag and Drop) Game Tutorial ... RJM Programming ... June 2015 ... thanks to http://stackoverflow.com/questions/9880279/how-do-i-add-a-simple-onclick-event-handler-to-a-canvas-element < --- > Canvas HTML Element Memories Game Tutorial ... RJM Programming ... June 2014 ... thanks to http://stackoverflow.com/questions/9880279/how-do-i-add-a-simple-onclick-event-handler-to-a-canvas-element 27,32d25 < var notfirst=false; < < var wasx=-1, wasy=-1, wascard='', wascardo=null, wascmd=['','','','','','']; < < var uwasx=-1, uwasy=-1 < 58,62c51 < if (txt.indexOf("first turn") != -1) { < document.getElementById('myh1').innerHTML = txt + " ... click/touch or drag and drop okay"; < } else { < document.getElementById('myh1').innerHTML = txt; < } --- > document.getElementById('myh1').innerHTML = txt; 72,148d60 < function drag(ev) { < //if (isiPad) document.getElementById('myh1').innerHTML=Math.floor((Math.random() * 123) + 0) + "." + ev.target.id; < wasx = ev.pageX - elemLeft; < wasy = ev.pageY - elemTop; < wascard = ''; < var xcurcard = -99, xgoodx=10, xgoody=10; < for (var iijk=0; iijk= xgoodx && wasx <= eval(xgoodx + imgsover[iijk].width)) && (wasy >= xgoody && wasy <= eval(xgoody + imgsover[iijk].height))) { < if ((wasx >= xgoodx && wasx <= eval(xgoodx + imgsover[iijk].width)) && (wasy >= xgoody && wasy <= eval(xgoody + imgsover[iijk].height))) { < xcurcard = eval(iijk); < wascard = imgs[xcurcard].src; < wascardo = imgs[xcurcard]; < wascmd[0] = 'context.drawImage(imgs[' + iijk + '],' + xgoodx + ',' + xgoody + ');'; < wascmd[1] = 'to1o = imgsover[' + iijk + '];'; < wascmd[2] = 'to1 = sdeckcards[' + iijk + '];'; < wascmd[3] = 'to1x =' + xgoodx + ';'; < wascmd[4] = 'to1y =' + xgoody + ';'; < wascmd[5] = 'to1i =' + iijk + ';'; < if (isiPad) { < ev.preventDefault(); < for (var iwas=0; iwas 1150) { < xgoodx = 10; < xgoody = xgoody + imgsover[iijk].height + 10; < } else { < xgoodx = xgoodx + imgsover[iijk].width + 10; < } < < } < } < < function allowDrop(ev) { < //if (xmoveid != 'drag0-1') alert(xcol); < //alert(ev.target.id); < //ev.preventDefault(); < } < < < function drop(ev) { < //alert(":" + ev.target.id); < } < < function omu(ev) { < uwasx = ev.pageX - elemLeft; < uwasy = ev.pageY - elemTop; < < if (isiPad) { < if (wascard != '') { < //document.getElementById('myh1').innerHTML=";" + ev.target.id + ' ' + uwasx + "," + uwasy + ' ' + wasx + "," + wasy; < //alert(";" + ev.target.id + ' ' + uwasx + "," + uwasy + ' ' + wasx + "," + wasy); < elem.click(); < } < } < } < < function omo(ev) { < < //if (isiPad) { < if (wascard != '') { < document.getElementById('myh1').innerHTML+="-"; < document.getElementById('myh1').innerHTML=document.getElementById('myh1').innerHTML.replace(/----------/g, "--"); < } < //} < } 152,158c64 < --- >

Select player names & click anywhere on card to shuffle & start the memories card game.

174c80 < --- > 265,287d170 < var wasiPad=isiPad; < var h1atend=''; < if (wasx >= 0 && wasy >= 0) { < if (!isiPad) h1atend = 'Click cards (or drag & drop) to match denomination to accumulate "tricks"... most tricks wins'; < wasx = -1; < wasy = -1; < for (var iwas=0; iwas= 0 && uwasy >= 0) { < x = uwasx; < y = uwasy; < //if (isiPad) document.getElementById('myh1').innerHTML+=" to1=" + to1 + " to2=" + to2 + " ... " + Math.floor((Math.random() * 123) + 0) + ";" + to1 + "-" + "+" + alreadypickedlist + "_" + toggle + " " + uwasx + "," + uwasy; < uwasx = -1; < uwasy = -1; < } < 433,434c308 < //document.getElementById('myh1').innerHTML = 'Double click cards (or drag & drop) to match denomination to accumulate "tricks"... most tricks wins'; < document.getElementById('myh1').innerHTML = 'Click cards (or drag & drop) to match denomination to accumulate "tricks"... most tricks wins'; --- > document.getElementById('myh1').innerHTML = 'Double click cards and try to match denomination to accumulate "tricks"... most tricks wins'; 531,534d404 < < if (h1atend != '') document.getElementById('myh1').innerHTML = h1atend; < < isiPad=wasiPad;