matecno
03-09-2007, 09:13 PM
Can anyone tell me what is wrong with this code that I wrote to manage the concentration game?
<html>
<head>
<!--
Filename: tiles.htm
Supporting files: ldown.gif, lup.gif, pback.jpg, pr.gif, premier.css,
rdown.gif, rup.gif, slide00.jpg - slide11.jpg
-->
<title>The Concentration Game</title>
<link href="games.css" rel="stylesheet" type="text/css" />
<script src="tiles.js" type="text/javascript"></script>
<script>
var FlipCount, Tile1, Tile2;
FlipCount=0
//function ShowAll() {
//for(i=0; i<=15; i++) {
//document.write
//}
//}
function FlipBack() {
document.images[Tile1].src = "tile.jpg";
document.images.[Tile2].src = "tile.jpg";
FlipCount=0;
}
function CheckTiles() {
if (document.images[Tile1].src == document.images[Tile2].src) {
FlipCount=0;
}
else {
setTimeout("FlipBack()", 8);
}
}
function Flip(i) {
document.images.[i].src = Tiles[i].src;
if (FlipCount==0) {
Tile1=i;
FlipCount=1;
}
else {
Tile2=i;
CheckTiles();
}
}
</script>
</head>
<body>
<form action="">
<!-- Concentration Tiles -->
<div id="board">
<a href="http://www.yahoo.com"><img src="tile.jpg" alt="" onClick="document.Flip(0)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(1)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(2)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(3)" width="75" height="75" /></a>
<br />
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(4)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(5)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(6)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(7)" width="75" height="75" /></a>
<br />
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(8)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(9)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(10)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(11)" width="75" height="75" /></a>
<br />
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(12)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(13)" width="75" height="75"/></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(14)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(15)" width="75" height="75" /></a>
</div>
<div id="main">
<p id="title">
<img src="logo.jpg" alt="Game Etc." width="240" height="55" />
</p>
<p>Play the Concentration game! Click the tiles on the left and
match pairs of identical images. Click the <b>Reload Tiles</b> button
below to randomize the position of the tiles and play again. Click the
<b>Show Tiles</b> button to view the solution.</p>
<p id="formp">
<input type="button" value="Reload Tiles" />
<input type="button" value="Show Tiles" />
</p>
</div>
</form>
</body>
</html>
<html>
<head>
<!--
Filename: tiles.htm
Supporting files: ldown.gif, lup.gif, pback.jpg, pr.gif, premier.css,
rdown.gif, rup.gif, slide00.jpg - slide11.jpg
-->
<title>The Concentration Game</title>
<link href="games.css" rel="stylesheet" type="text/css" />
<script src="tiles.js" type="text/javascript"></script>
<script>
var FlipCount, Tile1, Tile2;
FlipCount=0
//function ShowAll() {
//for(i=0; i<=15; i++) {
//document.write
//}
//}
function FlipBack() {
document.images[Tile1].src = "tile.jpg";
document.images.[Tile2].src = "tile.jpg";
FlipCount=0;
}
function CheckTiles() {
if (document.images[Tile1].src == document.images[Tile2].src) {
FlipCount=0;
}
else {
setTimeout("FlipBack()", 8);
}
}
function Flip(i) {
document.images.[i].src = Tiles[i].src;
if (FlipCount==0) {
Tile1=i;
FlipCount=1;
}
else {
Tile2=i;
CheckTiles();
}
}
</script>
</head>
<body>
<form action="">
<!-- Concentration Tiles -->
<div id="board">
<a href="http://www.yahoo.com"><img src="tile.jpg" alt="" onClick="document.Flip(0)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(1)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(2)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(3)" width="75" height="75" /></a>
<br />
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(4)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(5)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(6)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(7)" width="75" height="75" /></a>
<br />
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(8)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(9)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(10)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(11)" width="75" height="75" /></a>
<br />
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(12)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(13)" width="75" height="75"/></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(14)" width="75" height="75" /></a>
<a href="#"><img src="tile.jpg" alt="" onmousedown="Flip(15)" width="75" height="75" /></a>
</div>
<div id="main">
<p id="title">
<img src="logo.jpg" alt="Game Etc." width="240" height="55" />
</p>
<p>Play the Concentration game! Click the tiles on the left and
match pairs of identical images. Click the <b>Reload Tiles</b> button
below to randomize the position of the tiles and play again. Click the
<b>Show Tiles</b> button to view the solution.</p>
<p id="formp">
<input type="button" value="Reload Tiles" />
<input type="button" value="Show Tiles" />
</p>
</div>
</form>
</body>
</html>