romeo which is the blue snail is only allowed to take one step to one of the eight boxes around at one time, and he has to go through all the boxes to reach his true love juliet. i am really lost with the math stuff here so pleasr any of you give me some advice, thanks here is what i have done so far <html> <head> <title>Romeo & Juliet</title> </head> <body> <center> <H1> Romeo & Juliet </h1> </center> <center> <script> document.write('<table style=cursorointer;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+=; } document.write('</table>') document.getElementById(90).innerHTML="<img width=40 height=40 src=romeo.gif>"; document.getElementById(90).bgColor="#FF99FF"; var squares=new Array(true); var score=0; var where; var oldwhere=0; function moveto(square){ where=square.id; if ((oldwhere==where- || oldwhere==where- || oldwhere==where- || oldwhere==where- || oldwhere- ==where || oldwhere- ==where || oldwhere- ==where || oldwhere- ==where)) { score++; document.getElementById("scorey").innerHTML=score; document.getElementById(oldwhere).innerHTML=" "; document.getElementById(where).innerHTML="<img src=romeo.gif width=40 height=40>"; document.getElementById(where).bgColor="#FF99FF"; oldwhere=where; squares[square.name]=true; } for (var i=0; i<63; i++) if (squares!=true) var stuffed=true if (stuffed!=true) {alert("You finally see Juliet again in only "+score+" moves!");window.location.href=window.location.href;} } </script> <div style ="position:absolute;left:270;top:175;width:297;height:250"> <img width = 40 height= 40 src="juliet.gif"> </div> <div style ="position:absolute;left:331;top:480;width:297;height:250">Score: <span id=scorey>0</span> </div><br> <p> <div style="position:absolute;left:220;top:505;width:400;height:300"> <input type=button value=" Back " onClick=> </div> <div style="position:absolute;left:350;top:505;width:420;height:280"> <input type="RESET" value="New Attempt" > </div> </body> </html>
There, I fixed the math stuff for you. I don't know about the rest. <div id="scorey"></div> <script type="text/javascript"> document.write('<table style="cursor:pointer;cursor:hand;" border="2" cellpadding="0" cellspacing="0">') var squarenum = 0; var curnum = 0; var curcol = "#996633"; for (var count1 = 0; count1 < 8; count1++) { document.write('<tr>') curcol = curcol == '#996633' ? '#663300' : '#996633'; for (var count = 0; count < 8; count++) { curcol = curcol == '#996633' ? '#663300' : '#996633'; document.write('<td bgcolor="'+ curcol +'" id="'+ curnum +'" name="'+ squarenum +'" width="50" height="50" onclick="moveto(this);"> </td>'); curnum++; squarenum++ } document.write('</tr>') } document.write('</table>') document.getElementById(0).innerHTML = '<img width="40" height="40" src="romeo.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 -1|| oldwhere == where - 9 || oldwhere == where - 8 || oldwhere == where -7 || where == oldwhere -1 || where == oldwhere -9 || where == oldwhere -8 || where == oldwhere -7 ) { score++; document.getElementById("scorey").innerHTML = score; document.getElementById(oldwhere).innerHTML = " "; document.getElementById(where).innerHTML = '<img src="romeo.gif" width="40" height="40">'; 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 finally see Juliet again in only "+score+" moves!"); window.location.href = window.location.href; } } </script> Code (markup):