PDA

View Full Version : Javascript game guidance



Rapala
Mar 26th, 2007, 10:48 AM
Hi all

I am very new too Javascript and I am looking for help and guidance here.

I am trying to design a game where the user has to put the numbers in numerical order. I want the user to be able to click the jars they want to move and then locate them to their new position.

As I said I dont want anyone to do the work for me but just to merely correct any mistakes in my code or what functions etc are required.

Cheers

Rapala



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Javascript Game</title>
<script type="text/javascript">
var blank_pos = 24, count = 0, pos = new Array(), nam = new Array();
pos[1] = 3;
pos[2] = 1;
pos[3] = 2;
pos[4] = 15;
pos[5] = 8;
pos[6] = 21;
pos[7] = 17;
pos[8] = 6;
pos[9] = 18;
pos[10] = 24;
pos[11] = 12;
pos[12] = 10;
pos[13] = 13;
pos[14] = 9;
pos[15] = 16;
pos[16] = 4;
pos[17] = 20;
pos[18] = 5;
pos[19] = 19;
pos[20] = 7;
pos[21] = 23;
pos[22] = 14;
pos[23] = 22;
pos[24] = 11;

function start() {
nam[1] = images/jam3;
nam[2] = images/jam1;
nam[3] = images/jam2;
nam[4] = images/jam15;
nam[5] = images/jam8;
nam[6] = images/jam21;
nam[7] = images/jam17;
nam[8] = images/jam6;
nam[9] = images/jam18;
nam[10] = images/jam24;
nam[11] = images/jam12;
nam[12] = images/jam10;
nam[13] = images/jam13;
nam[14] = images/jam9;
nam[15] = images/jam16;
nam[16] = images/jam4;
nam[17] = images/jam20;
nam[18] = images/jam5;
nam[19] = images/jam19;
nam[20] = images/jam7;
nam[21] = images/jam23;
nam[22] = images/jam14;
nam[23] = images/jam22;
nam[24] = images/jam11;
}

function onclick()
{

}

function move()
{

}

function reposition()
{
}



function swapPieces()
{
}
</script>
</head>

<body>
<div align="center">
<table width="164" border="2" cellpadding="0" cellspacing="5" bordercolor="#996633" bgcolor="#996633">
<tr>
<td><img src="images/jam3.gif" width="75" height="75"></td>
<td><img src="images/jam1.gif" width="75" height="75"></td>
<td><img src="images/jam2.gif" width="75" height="75"></td>
<td><img src="images/jam15.gif" width="75" height="75"></td>
<td><img src="images/jam8.gif" width="75" height="75"></td>
<td><img src="images/jam21.gif" width="75" height="75"></td>
</tr>
<tr>
<td><img src="images/jam17.gif" width="75" height="75"></td>
<td><img src="images/jam6.gif" width="75" height="75"></td>
<td><img src="images/jam18.gif" width="75" height="75"></td>
<td><img src="images/jam24.gif" width="75" height="75"></td>
<td><img src="images/jam12.gif" width="75" height="75"></td>
<td><img src="images/jam10.gif" width="75" height="75"></td>
</tr>
<tr>
<td><img src="images/jam13.gif" width="75" height="75"></td>
<td><img src="images/jam9.gif" width="75" height="75"></td>
<td><img src="images/jam16.gif" width="75" height="75"></td>
<td><img src="images/jam4.gif" width="75" height="75"></td>
<td><img src="images/jam20.gif" width="75" height="75"></td>
<td><img src="images/jam5.gif" width="75" height="75"></td>
</tr>
<tr>
<td><img src="images/jam19.gif" width="75" height="75"></td>
<td><img src="images/jam7.gif" width="75" height="75"></td>
<td><img src="images/jam23.gif" width="75" height="75"></td>
<td><img src="images/jam14.gif" width="75" height="75"></td>
<td><img src="images/jam22.gif" width="75" height="75"></td>
<td><img src="images/jam11.gif" width="75" height="75"></td>
</tr>
</table>
</div>
</body>
</html>