Caligula
12-12-2010, 12:08 AM
Please can anyone help?
hello I am novice when it comes to writing code and as i'm writing some code for a sliding puzzle game, i have managed to display the images.
but now i need to write the functions to see if the image when clicked on is next to the blank one and then to move them if this is true.
<Html>
<Head>
<Title> Sliding Puzzle Game</Title>
<Script Language = "JavaScript">
var images = new Array();
//var initialise
var id = 0;
alert("starting");
window.onerror = handleError;
function handleError(strMessage, strURL, intLine)
//the above function catches any errors and display what and where.
{
document.write("<br/>The following Error occurred:");
document.write("<br/>Message: " + strMessage);
document.write("<br/>Code: " + strURL);
document.write("<br/>On line: " + intLine);
}
function Write2screen(){
var k=0;
for (i=0; i< 4; i++) {
for (j=0; j<4; j++) {
id++; //give picture unique id after each iteration
images[k] = "Images/" + k + ".jpg";
document.write(" <img src= '"+images[k]+"' id='"+id+"'/>");
k++;
}
document.write("<br/>");
}
}
function CanMoveTile() {
// checks to see whether the cell at postion cellNum
// is next to the black tile and returns true if and
// only if this is the case
}
function moveTile(id) {
// this function moves the tile that was clicked on (if the tile can actually be moved)
}
Write2screen();
</Script>
</Head>
<body onClick=moveTile(id)>
</body>
</Html>
many thanks in advance
hello I am novice when it comes to writing code and as i'm writing some code for a sliding puzzle game, i have managed to display the images.
but now i need to write the functions to see if the image when clicked on is next to the blank one and then to move them if this is true.
<Html>
<Head>
<Title> Sliding Puzzle Game</Title>
<Script Language = "JavaScript">
var images = new Array();
//var initialise
var id = 0;
alert("starting");
window.onerror = handleError;
function handleError(strMessage, strURL, intLine)
//the above function catches any errors and display what and where.
{
document.write("<br/>The following Error occurred:");
document.write("<br/>Message: " + strMessage);
document.write("<br/>Code: " + strURL);
document.write("<br/>On line: " + intLine);
}
function Write2screen(){
var k=0;
for (i=0; i< 4; i++) {
for (j=0; j<4; j++) {
id++; //give picture unique id after each iteration
images[k] = "Images/" + k + ".jpg";
document.write(" <img src= '"+images[k]+"' id='"+id+"'/>");
k++;
}
document.write("<br/>");
}
}
function CanMoveTile() {
// checks to see whether the cell at postion cellNum
// is next to the black tile and returns true if and
// only if this is the case
}
function moveTile(id) {
// this function moves the tile that was clicked on (if the tile can actually be moved)
}
Write2screen();
</Script>
</Head>
<body onClick=moveTile(id)>
</body>
</Html>
many thanks in advance