Difficulty setting: Huh, what ? Dumb Real easy Easy Normal Hard Real hard Master Impossible - - -
Highscores seit letztem Reload
Anzahl Klicks:
Spielstand:
Solve speed: Fast Normal Slow
[Beschreibung]
[Kompatibilität]
[Code]
<STYLE type=text/css> INPUT.play { FONT-WEIGHT: bold; FONT-SIZE: 125%; WIDTH: 2em; FONT-FAMILY: monospace } DIV { TEXT-ALIGN: center } DIV TABLE { MARGIN-LEFT: auto; MARGIN-RIGHT: auto; TEXT-ALIGN: left } </STYLE> <SCRIPT type=text/javascript> /* I put into this script everything I thought would be remotely confusing. If you understood everything, I recommend you get some help, immediately. The intellect, as a means for the preservation of the individual, unfolds its chief powers in simulation. - Friedrich Nietzsche (1844-1900) - */ var Size = new Number(6); var Moves = new Array(); var noGame = 1; var FD; var Board = new function() { this.init = function() { var a; Solve.init(); for(var i = 0; i < Size * Size; this.set(i++,0)); for(var i = 0; i < 3 + 3 * FD.selectedIndex; i++) { Board.clicked(a = Math.floor(Math.random() * Size) + "-" + Math.floor(Math.random() * Size),1); Solve.add(a); } } this.clicked = function(square,c) { var x,y; this.change(x = parseInt(square.split("-")[0]),y = parseInt(square.split("-")[1]),c); this.change(x - 1,y,c); this.change(x + 1,y,c); this.change(x,y - 1,c); this.change(x,y + 1,c); } this.change = function(x,y,c) { if(this.check(x,y)) this.set(x + Size * y,(parseInt(this.get(x,y)) + c) & 3); } this.set = function(square,val) { window.document.forms["playForm"].elements[square].value = val; } this.get = function(x,y) { return (this.check(x,y) ? window.document.forms["playForm"].elements[x + Size * y].value : ' '); } this.check = function(x,y) { return (x >= 0 && y >= 0 && x < Size && y < Size); } } var Counter = new function() { this.counter = 0; this.counterID = 0; this.set = function(i) { this.stop(); this.counter = i; this.show(); } this.get = function() { return this.counter; } this.show = function() { window.document.forms["CounterForm"]["Counter"].value = this.counter; } this.add = function(i) { if((this.counter += i) <= 0) this.set(0); this.show(); } this.start = function() { this.set(1000); this.counterID = setInterval('Counter.add(-1)',166); } this.stop = function() { if(this.counterID) clearInterval(this.counterID); this.counterID = 0; } } var Solve = new function() { this.solve = new Array(); this.solveID = 0; this.init = function() { this.stop(); this.solve.length = 0; for(var i = 0; i < 9; window.document.forms["hintForm"].elements[i++].value = ' '); } this.add = function() { for(var i = 0; i < arguments.length; this.solve.push(arguments[i++])); this.solve.sort(); for(var i = 0; i <= this.solve.length - 4; i++) if(this.solve[i] == this.solve[i + 1] && this.solve[i] == this.solve[i + 2] && this.solve[i] == this.solve[i + 3]) this.solve.splice(i--,4); return this.solve.length; } this.start = function() { this.solveID = setInterval('Solve.run()',window.document.forms["solveForm"].SolveSpeed.options[window.document.forms["solveForm"].SolveSpeed.selectedIndex].value); } this.stop = function() { if(this.solveID) clearInterval(this.solveID); this.solveID = 0; } this.run = function() { var i; if(i = this.solve.pop()) return Board.clicked(i,3); this.stop(); } this.hint = function() { var i = this.solve[Math.floor(Math.random() * this.solve.length)]; var x = parseInt(i.split("-")[0]); var y = parseInt(i.split("-")[1]); window.document.forms["hintForm"].elements[0].value = Board.get(x - 1,y - 1); window.document.forms["hintForm"].elements[1].value = Board.get(x,y - 1); window.document.forms["hintForm"].elements[2].value = Board.get(x + 1,y - 1); window.document.forms["hintForm"].elements[3].value = Board.get(x - 1,y); window.document.forms["hintForm"].elements[4].value = Board.get(x,y); window.document.forms["hintForm"].elements[5].value = Board.get(x + 1,y); window.document.forms["hintForm"].elements[6].value = Board.get(x - 1,y + 1); window.document.forms["hintForm"].elements[7].value = Board.get(x,y + 1); window.document.forms["hintForm"].elements[8].value = Board.get(x + 1,y + 1); } } var Highscores = new function() { this.highscores = new Array(); this.init = function() { for(var i = 0; i < FD.length; i++) { this.highscores[i] = new Array(10); for(var j = 0; j < 10; this.highscores[i][j++] = 1); } } this.add = function(score) { this.highscores[FD.selectedIndex].push(score); this.highscores[FD.selectedIndex].sort(); this.highscores[FD.selectedIndex].reverse(); this.highscores[FD.selectedIndex].pop(); this.show(score); } this.show = function(score) { for(var i = 0, t = ''; i < 10; t += (i < 9 ? ' ' : '') + (i + 1) + ': ' + this.highscores[FD.selectedIndex][i] + (score == this.highscores[FD.selectedIndex][i++] ? ' <--' : '') + '\n'); window.document.forms["scoreForm"].Scores.value = t; } } function buttonNew() { Board.init(); Moves.length = window.document.forms["clicksForm"].Clicks.value = 0; Highscores.show(0); Counter.start(); noGame = 0; } function buttonMove(x) { if(noGame) return; Board.clicked(x,3); window.document.forms["clicksForm"].Clicks.value = Moves.push(x); if(Solve.add(x,x,x)) return; noGame = 1; Counter.stop(); if((i = 3 + 3 * FD.selectedIndex - Moves.length) < 0) Counter.add(7 * i); Highscores.add(Counter.get()); } function buttonUndo(flag) { if(noGame) return; Counter.add(-20); while(flag-- && (i = Moves.pop())) Board.clicked(i,1),Solve.add(i); window.document.forms["clicksForm"].Clicks.value = Moves.length; } function buttonHint() { if(noGame) return; Counter.add(-35); Solve.hint(); } function buttonSolve() { if(noGame) return; noGame = 1; Counter.set(0); Solve.start(); } function doOnload() { FD = window.document.forms["settingsForm"]["Difficulty"]; Highscores.init(); } </SCRIPT>
onload=doOnload()
<TABLE cellSpacing=5 cellPadding=0 border=0> <TBODY> <TR> <TD colSpan=2> <FORM name=settingsForm onsubmit="return false;" action=buttonmania.htm method=get> <P>Difficulty setting: <SELECT onchange=buttonNew() name=Difficulty> <OPTION>Huh, what ?</OPTION> <OPTION>Dumb</OPTION> <OPTION>Real easy</OPTION> <OPTION>Easy</OPTION> <OPTION selected>Normal</OPTION> <OPTION>Hard</OPTION> <OPTION>Real hard</OPTION> <OPTION>Master</OPTION> <OPTION>Impossible</OPTION></SELECT> - <INPUT title="Start a new game" onclick=buttonNew() type=button value=New> - <INPUT title="Restart the board" onclick=buttonUndo(-1); type=button value=Restart> - <INPUT title="Undo last move" onclick=buttonUndo(1); type=button value=Undo> </P></FORM></TD></TR> <TR> <TD> <FORM name=playForm onsubmit="return false;" action=buttonmania.htm method=get> <!-- <p> <script type="text/javascript"> for(y = 0; y < Size; y++,window.document.write("<br>")) for(x = 0; x < Size; x++) window.document.write('<input class="play" type="button" value="0" onClick="buttonMove(\'' + x + '-' + y + '\')">'); </script> </p> --> <TABLE cellSpacing=0 cellPadding=0 border=0> <TBODY> <TR> <TD><INPUT class=play onclick="buttonMove('0-0')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('1-0')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('2-0')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('3-0')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('4-0')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('5-0')" type=button value=0></TD></TR> <TR> <TD><INPUT class=play onclick="buttonMove('0-1')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('1-1')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('2-1')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('3-1')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('4-1')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('5-1')" type=button value=0></TD></TR> <TR> <TD><INPUT class=play onclick="buttonMove('0-2')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('1-2')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('2-2')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('3-2')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('4-2')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('5-2')" type=button value=0></TD></TR> <TR> <TD><INPUT class=play onclick="buttonMove('0-3')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('1-3')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('2-3')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('3-3')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('4-3')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('5-3')" type=button value=0></TD></TR> <TR> <TD><INPUT class=play onclick="buttonMove('0-4')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('1-4')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('2-4')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('3-4')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('4-4')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('5-4')" type=button value=0></TD></TR> <TR> <TD><INPUT class=play onclick="buttonMove('0-5')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('1-5')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('2-5')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('3-5')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('4-5')" type=button value=0></TD> <TD><INPUT class=play onclick="buttonMove('5-5')" type=button value=0></TD></TR></TBODY></TABLE></FORM></TD> <TD> <FORM name=scoreForm onsubmit="return false;" action=buttonmania.htm method=get> <P><TEXTAREA name=Scores rows=11 readOnly cols=18> Highscores seit letztem Reload </TEXTAREA> </P></FORM></TD></TR> <TR> <TD> <FORM name=clicksForm onsubmit="return false;" action=buttonmania.htm method=get> <P>Anzahl Klicks: <INPUT readOnly size=3 value=0 name=Clicks> </P></FORM></TD> <TD> <FORM name=CounterForm onsubmit="return false;" action=buttonmania.htm method=get> <P>Spielstand: <INPUT readOnly size=6 value=0 name=Counter> </P></FORM></TD></TR> <TR> <TD> <FORM name=hintForm onsubmit="return false;" action=buttonmania.htm method=get> <TABLE cellSpacing=0 cellPadding=0 border=0> <TBODY> <TR> <TD><INPUT class=play type=button value=" "></TD> <TD><INPUT class=play type=button value=" "></TD> <TD><INPUT class=play type=button value=" "></TD></TR> <TR> <TD><INPUT class=play type=button value=" "></TD> <TD><INPUT class=play type=button value=" "></TD> <TD><INPUT class=play type=button value=" "></TD></TR> <TR> <TD><INPUT class=play type=button value=" "></TD> <TD><INPUT class=play type=button value=" "></TD> <TD><INPUT class=play type=button value=" "></TD></TR></TBODY></TABLE> <DIV> <P><INPUT onclick=buttonHint() type=button value=Hint></P></DIV></FORM></TD> <TD> <FORM name=solveForm onsubmit="return false;" action=buttonmania.htm method=get> <P>Solve speed: <SELECT name=SolveSpeed> <OPTION value=500>Fast</OPTION> <OPTION value=900 selected>Normal</OPTION> <OPTION value=1300>Slow</OPTION></SELECT> </P> <P><INPUT onclick=buttonSolve() type=button value=Solve> </P></FORM></TD></TR></TBODY></TABLE></DIV>
Patrick Dostert
Kopieren Sie bitte den Code