»
Tiếng AnhTiếng PhápTiếng Việt

In - Xếp hình - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Trò chơi » Giải đố » Xếp hình
URL: https://www.javascriptbank.com/9quares-index.html

Xếp hình © JavaScriptBank.comTrò chơi JavaScript sẽ chia hình gốc làm chín phần bằng nhau và sắp xếp chúng ngẫu nhiên với nhau, nhiệm vụ của bạn là sắp xếp chín phần này lại để tạo nên hình gốc.

Phiên bản đầy đủ: jsB@nk » Trò chơi » Giải đố » Xếp hình
URL: https://www.javascriptbank.com/9quares-index.html



JavaScript
<script>Pix=new Array()Filled=new Array()for(x=1;x<10;x++){Filled[x]=1Pix[x]=new Image()Pix[x].src="Pic"+x+".jpg"}Filled[1]=0PosMov=new Array()PosMov[1]=new Array(2,4)PosMov[2]=new Array(1,5,3)PosMov[3]=new Array(2,6)PosMov[4]=new Array(1,5,7)PosMov[5]=new Array(2,4,6,8)PosMov[6]=new Array(3,5,9)PosMov[7]=new Array(4,8)PosMov[8]=new Array(5,7,9)PosMov[9]=new Array(6,8)function ClickOn(i){for(x=0;x<PosMov[i].length;x++){if(Filled[PosMov[i][x]]!=1)MoveIt(i,PosMov[i][x])}}function MoveIt(f,t){Filled[f]=0Filled[t]=1document["Img"+t].src=document["Img"+f].srcdocument["Img"+f].src='blnk.jpg'}function GiveUp(what){if(what=="Give Up"){for(c=1;c<10;c++){document["Img"+c].src=Pix[c].src}document.forms[0].button1.value="Replay"}if(what=="Replay"){location.reload()}}Stp=0function Init(){while(Stp<100){i=Math.ceil(Math.random()*9)for(x=0;x<PosMov[i].length;x++){if(Filled[PosMov[i][x]]!=1) {MoveIt(i,PosMov[i][x])Stp++}}}}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<body onload="setTimeout('Init()',500)"><table cellspacing=0 cellpadding=0 border=0><script>for(x=0;x<3;x++){document.write("<tr>")for(y=1;y<4;y++){document.write("<td><a href='javascript:ClickOn("+(3*x+y)+")'><img name='Img"+(3*x+y)+"' src=Pic"+(3*x+y)+".jpg border=0></a></td>")}}</script></table>Click on the square pieces.<br>If they can be slid horizontally or vertically<br>to the empty (black) space, they will slide.<br><form><input type=button name="button1" value="Give Up" onclick="GiveUp(this.value)"></form></body><!--    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/9quares/blnk.jpghttp://javascriptbank.com/javascript/game/9quares/origin.jpghttp://javascriptbank.com/javascript/game/9quares/pic1.jpghttp://javascriptbank.com/javascript/game/9quares/pic2.JPGhttp://javascriptbank.com/javascript/game/9quares/pic3.JPGhttp://javascriptbank.com/javascript/game/9quares/pic4.JPGhttp://javascriptbank.com/javascript/game/9quares/pic5.JPGhttp://javascriptbank.com/javascript/game/9quares/pic6.JPGhttp://javascriptbank.com/javascript/game/9quares/pic7.JPGhttp://javascriptbank.com/javascript/game/9quares/pic8.JPGhttp://javascriptbank.com/javascript/game/9quares/pic9.JPG