[KnightGame]

Score: 0

Ziel des Spiels ist es, mit der Springerfigur in möglichst wenigen Zügen alle Felder zu erreichen.

[Code]

[zwischen <BODY> und </BODY>]

<!-- Original: Ben Joffe -->
<!-- Web Site: http://www.joffe.tk/ -->
<script>
document.write('<table style=cursor:pointer;cursor:hand border=2 cellpadding=0 cellspacing=0>')
var squarenum=0;
var curnum=0;
curcol="#996633";
for(var count1=0; count1<8; count1++){
document.write('<tr>')
if(curcol=="#996633") {curcol="#663300"} else curcol="#996633";
for(var count=0; count<8; count++){
if(curcol=="#996633") {curcol="#663300"} else curcol="#996633";
document.write('<td bgcolor='+curcol+' id='+curnum+' name='+squarenum+' width=50 height=50 onclick=\"moveto(this);\"> </td>');
curnum++;
squarenum++
}
document.write('</tr>')
curnum+=20;
}
document.write('</table>')
document.getElementById(0).innerHTML="<img src=jsimages/horse.gif>";
document.getElementById(0).bgColor="#FF99FF";
var squares=new Array(true);

var score=0;
var where;
var oldwhere=0;
function moveto(square){
where=square.id;
if ((oldwhere==where-26 || oldwhere==where-30 || oldwhere==where-55 || oldwhere==where-57 || oldwhere-26==where || oldwhere-30==where || oldwhere-55==where || oldwhere-57==where))
{
score++;
document.getElementById("scorey").innerHTML=score;
document.getElementById(oldwhere).innerHTML=" ";
document.getElementById(where).innerHTML="<img src=jsimages/horse.gif width=48 height=48>";
document.getElementById(where).bgColor="#FF99FF";
oldwhere=where;
squares[square.name]=true;
}
for (var i=0; i<63; i++) if (squares[i]!=true) var stuffed=true
if (stuffed!=true) {alert("You win in only "+score+" moves!");window.location.href=window.location.href;}
}
</script>
<p>Score: <span id=scorey>0</span><br>

[Autor]

Ben Joffe

[Download]

Kopieren Sie bitte den Code

Copyright © 1998- Nightfire Webworker Archiv Script No: 538