POSUVANIE CISEL

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

103
p103.html, p1031.html, p1032.html / p103.zip
Hra usporiadavanie cisel
4257b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code (p103.html):

<HTML> <HEAD> <title> JavaScript DESTINATION - P103 </title> </HEAD> <FRAMESET ROWS="40%,60%"> <FRAME SRC="p1031.html" name="ga1"> <FRAME SRC="p1032.html" name="ga2"> </FRAMESET> </HTML>

Zdrojovy tvar / Source code (p1031.html):

<HTML> <HEAD> </HEAD> <BODY> Stlacte tlacitko, ked si chcete zahrat tuto hru ! </BODY> </HTML>

Zdrojovy tvar / Source code (p1032.html):

<HTML> <HEAD> <script language="JavaScript"> <!-- function initArray() { this.length = initArray.arguments.length for (var i = 0; i < this.length; i++) this[i+1] = initArray.arguments[i] } var startpos = new initArray(9,9,9,9,9,0,0,0,9,0,0,0,9,0,0,0,9,9,9,9); var pos = new initArray(9,9,9,9,9,0,0,0,9,0,0,0,9,0,0,0,9,9,9,9); var nummoves= 0; function random() { today = new Date(); num = today.getTime(); num = Math.round(Math.abs(Math.sin (num)*1000000)) % 9; return num; } function display(pos) { parent.ga1.document.close(); parent.ga1.document.open(); parent.ga1.document.write("<form>"); parent.ga1.document.write("<input type='Button' value=' "+pos[6]+" ' onClick='parent.ga2.move(6)'>"); parent.ga1.document.write("<input type='Button' value=' "+pos[7]+" ' onClick='parent.ga2.move(7)'>"); parent.ga1.document.write("<input type='Button' value=' "+pos[8]+" ' onClick='parent.ga2.move(8)'> <br>"); parent.ga1.document.write("<input type='Button' value=' "+pos[10]+" ' onClick='parent.ga2.move(10)'>"); parent.ga1.document.write("<input type='Button' value=' "+pos[11]+" ' onClick='parent.ga2.move(11)'>"); parent.ga1.document.write("<input type='Button' value=' "+pos[12]+" ' onClick='parent.ga2.move(12)'><br>"); parent.ga1.document.write("<input type='Button' value=' "+pos[14]+" ' onClick='parent.ga2.move(14)'>"); parent.ga1.document.write("<input type='Button' value=' "+pos[15]+" ' onClick='parent.ga2.move(15)'>"); parent.ga1.document.write("<input type='Button' value=' "+pos[16]+" ' onClick='parent.ga2.move(16)'>"); parent.ga1.document.write("<p><br>Pocet presunov: "+nummoves+"<br>"); win(); } function move(num) { if (pos[num-4]==0) { pos[num-4]= pos[num]; pos[num]= 0; nummoves++; } else {if (pos[num-1]==0){ pos[num-1]= pos[num]; pos[num]= 0; nummoves++; } else {if (pos[num+1]==0){ pos[num+1]= pos[num]; pos[num]= 0; nummoves++; } else {if (pos[num+4]==0){ pos[num+4]= pos[num]; pos[num]= 0; nummoves++; } } } } display(pos); } function win() { if (pos[6]== 1 & pos[7]== 2 & pos[8]== 3 & pos[10]== 4 & pos[11]== 5 & pos[12]== 6 & pos[14]== 7 & pos[15]== 8 & pos[16]== 0) { if (confirm('Zvladol si to ! Este raz ?')) newgame(); } } function newgame() { var helparray= new initArray(0,0,0,0,0,0,0,0,0); for (var i=1; i<9;i++) { randomnum= random(); while (helparray[randomnum] || 0) { randomnum= random(); } helparray[randomnum]= i; } for (var i=1; i<21;i++) { pos[i]= startpos[i]; } for (var i=1; i<4; i++) { for (var j=0; j<3; j++) { pos[i+5+j*4]= helparray[i+3*j]; } } nummoves=0; display(pos); } // --> </script> </HEAD> <p> <center> <FORM NAME="buttonbar"> <INPUT TYPE="button" VALUE="Start novej hry" onClick="newgame()"> </FORM> </center> <h1>Pravidla</h1><p> Cielom je usporiadat cisla v prvom ramci na spravne poradie. 0 je prazdne miesto. Na miesto nuly mozete presunut lubovolne ine cislo. Cisla musite usporiadat takto:<p> <form> <input type="button" value=" 1 "><input type="button" value=" 2 "><input type="button" value=" 3 "><br> <input type="button" value=" 4 "><input type="button" value=" 5 "><input type="button" value=" 6 "><br> <input type="button" value=" 7 "><input type="button" value=" 8 "><input type="button" value=" 0 "><br> </form> </body> </HTML>
[ Navrat / BACK ]