1)Copy the following code(from <html> to </html> including the two of them as well) as it is and paste it in your notepad….

2)Save it with the name  Game.html

NOTE: Save  it with a     “.html”  and NOT  “.txt:

CODE :starts from the next line

<html>
<body>

<center>
<h2>Try to put all the pieces in alphabetical order, ‘A’ through ‘O’. Awesome!</h2>

<form name=pad>
<table border=2 cellpadding=2 cellspacing=2>
<tr>
<td colspan=4 align=center>Shift It 4×4 Game</td>
</tr>

<SCRIPT LANGUAGE=”JavaScript”>

<!– Original: Rohan –>
<!– Web Site: http://Technebula –>

<!– Begin
bx=3; by=3;
for (y=0;y<4;y++)
{
document.write(‘<tr>’);

for (x=0;x<4;x++)
{
document.write(‘<td><tt><input type=button value=” ” ‘);
document.write(‘onclick=”move(‘+x+’,’+y+’);”></tt></td>’);
}
document.write(‘</tr>’);
}

function move(x,y)
{

ax=Math.abs(bx-x);
ay=Math.abs(by-y);
if (((ax*ay)==0)&&((ax+ay)==1)) {
f=document.pad;
f.elements[4*by+bx].value=f.elements[4*y+x].value;
f.elements[4*y+x].value=” “;
bx=x; by=y; f.msg.value++;
}
}
function rndize() {
alpha=”ABCDEFGHIJKLMNO “;
for (i=0;i<16;i++)
{
x=0;
y=0;
while (document.pad.elements[4*y+x].value!=” “)
{
x=Math.floor(Math.random()*4);
y=Math.floor(Math.random()*4);
}
document.pad.elements[4*y+x].value=alpha.substring(i,i+1);
}
bx=x;
by=y;
}
rndize();
// End –>
</script>

<tr>
<td colspan=4><input type=text size=20 name=msg></td>
</tr>
</table>
</form>
<a href=”https://technebula.wordpress.com”><h2>Play more games online</h2>
</center>
</body>
</html>

Advertisements