»
EnglishFrenchVietnamese

Print - Knight Game - JavaScriptBank.com

Full version: jsB@nk » Game » Knight Game
URL: https://www.javascriptbank.com/knight-game-index.html

Knight Game © JavaScriptBank.comThis logic game is simple and fun to play. Simply move the knight in legal knight chess moves to every square on the board in as few moves as possible.

Full version: jsB@nk » Game » Knight Game
URL: https://www.javascriptbank.com/knight-game-index.html



HTML
<script>// Ben Joffe , http://www.joffe.tk/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);\">&nbsp;</td>');curnum++;squarenum++}document.write('</tr>')curnum+=20;}document.write('</table>')document.getElementById(0).innerHTML="<img src=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="&nbsp;";document.getElementById(where).innerHTML="<img src=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=trueif (stuffed!=true) {alert("You win in only "+score+" moves!");window.location.href=window.location.href;}}</script><p>Score: <span id=scorey>0</span><!--    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/Knight_Game/horse.gif