»
EnglishFrenchVietnamese

Print - Concentration-Using Different Images - JavaScriptBank.com

Full version: jsB@nk » Game » Puzzle » Concentration-Using Different Images
URL: https://www.javascriptbank.com/concentration-dif-small-index.html

Concentration-Using Different Images © JavaScriptBank.comMemory game where you try to remember where the matching tiles are.

Full version: jsB@nk » Game » Puzzle » Concentration-Using Different Images
URL: https://www.javascriptbank.com/concentration-dif-small-index.html



CSS
<style type="text/css">body{background-color:#ffffff;font-size:10pt;color:#00436e;font-family:sans-serif;}</style><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<script language="javascript">/*ORIGINAL SCRIPT CREATED Brian Gosselin OF http://scriptasylum.comEDITED BY Michael Rottmeier OF http://michael-rottmeier.bei.t-online.deTHIS VERSION ADDS THE ABILTY TO MATCH DIFFERENT BUT RELATED IMAGESINSTEAD OF THE SAME IMAGE.*/var pics=new Array();for(i=1;i<=8;i++){pics[i]=new Image();pics[i].src='K_image'+i+'.gif';}for(i=93;i<=100;i++){pics[i]=new Image();pics[i].src='K_image'+i+'.gif';}var map=new Array(1,100,2,99,3,98,4,97,5,96,6,95,7,94,8,93)var user=new Array();var temparray=new Array();var clickarray=new Array(0,0);var ticker, sec, min, ctr, id=0, oktoclick, finished;function init(){clearTimeout(id);for(i=0;i<=15;i++)user[i]=0;ticker=0; min=0; sec=0; ctr=0; finished=0;oktoclick=true;document.forms["f"].b.value=" Neustart ";scramble();id=setInterval('runclk()', 995);for(i=0;i<=15;i++){document.images[('img'+i)].src="K_image0.gif";document.images[('img'+i)].alt="";}}function runclk(){min=Math.floor(ticker/60);sec=(ticker-(min*60))+'';if(sec.length==1){sec="0"+sec};ticker++;document.forms["f"].b.value="    "+min+":"+sec+"    ";}function scramble(){for(z=0;z<5;z++){for(x=0;x<=15;x++){temparray[0]=Math.floor(Math.random()*16);temparray[1]=map[temparray[0]];temparray[2]=map[x];map[x]=temparray[1];map[temparray[0]]=temparray[2];}}}function showimage(but){if(oktoclick){oktoclick=false; document.images[('img'+but)].src='K_image'+map[but]+'.gif';//document.images[('img'+but)].alt='Image '+map[but];if(ctr==0){ctr++;clickarray[0]=but;oktoclick=true;}else{clickarray[1]=but;ctr=0;setTimeout('returntoold()', 600);}}}function returntoold(){if((clickarray[0]==clickarray[1])&&(!user[clickarray[0]])){document.images[('img'+clickarray[0])].src="K_image0.gif";document.images[('img'+clickarray[0])].alt="";oktoclick=true;}else{if((Math.floor(map[clickarray[0]] + map[clickarray[1]])) != 101){if(user[clickarray[0]]==0){document.images[('img'+clickarray[0])].src="K_image0.gif";document.images[('img'+clickarray[0])].alt="";}if(user[clickarray[1]]==0){document.images[('img'+clickarray[1])].src="K_image0.gif";document.images[('img'+clickarray[1])].alt="";}}if((Math.floor(map[clickarray[0]] + map[clickarray[1]])) == 101){if(user[clickarray[0]]==0&&user[clickarray[1]]==0){finished++; }user[clickarray[0]]=1;user[clickarray[1]]=1;}if(finished >= 8){alert('Well, done in '+document["f"].b.value+'. Great !');/// Change Value of the ClockclearTimeout(id);document.forms["f"].b.value = 'Neustart';/// End}else{oktoclick=true;}}}//window.onload=init;</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<table cellpadding="2" cellspacing="0" border="1"><tr><td width="25">1</td><td width="25">2</td><td width="25">3</td><td width="25">4</td><td width="25">5</td><td width="25">6</td><td width="25">7</td><td width="25">8</td></tr><tr><td>100</td><td>99</td><td>98</td><td>97</td><td>96</td><td>95</td><td>94</td><td>93</td></tr></table><table cellpadding="0" cellspacing="0" border="0"><script language="javascript">var t='';for(r=0;r<=3;r++){t+='<tr>';for(c=0;c<=3;c++){t+='<td align="center"><a href="javascript:showimage('+((4*r)+c)+')" onClick="this.blur()"><img src="K_image0.gif" name="img'+((4*r)+c)+'" alt="" border="0" width=68></a></td>';}t+='</tr>';}document.write(t);</script></table><br><br><form name="f"><input type="button" value="Neustart" name="b" onClick="init()"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


Files
http://javascriptbank.com/javascript/game/Concentration_Dif_Small/Concentration_Dif_Small_images.zip