有人可以解答嗎?!
類似推格子的遊戲
加註解
感激(詳細一點 初學網路程式設計)
<!DOCTYPE html>
<html>
<head>
<meta charset = "uf-8">
<title>HW-09</title>
<style>
body{
font-size: 75px;
font-weight: bold;
font-family: Sans-Serif;
color: blue;
}
table{
width: 400px;
border-collapse: collapse;
}
td{
height: 100px;
width: 100px;
margin: 0px;
padding: 0px;
border:4px gray solid;
}
</style>
var Tile = new Array(16);
var i, j, temp;
function start(){
createTiles();
for (i = 0; i < 16; i++){<br>Tile[i] = document.getElementById(i);
if (i!=0)
Tile[i][removed]=i;
//window.alert(i);
}
for(i = 0; i < 16; i++){<br>j = parseInt(Math.random()*16);
temp = Tile[i][removed];
Tile[i][removed] = Tile[j][removed];
Tile[j][removed] = temp;
//window.alert(j);
}
}
function createTiles(){
var tbody = document.getElementById("tablebody");
for (var i = 0; i < 16 ; ){<br>var row = document.createElement("tr");
for (var j = 0; j < 4; j++,i++ ){<br>var cell = document.createElement("td");
cell.setAttribute("id", i);
cell.setAttribute("onclick", "Swap("+i+")");
row.appendChild( cell );
}
tbody.appendChild( row );
}
}
function Swap(e){
j = -1;
i = e;
if(i <= 14 && Tile[i+1][removed] == 0) j = i+1;
if(i >= 1 && Tile[i-1][removed] == 0) j = i-1;
if(i <= 11 && Tile[i+4][removed] == 0) j = i+4;
if(i >= 4 && Tile[i-4][removed] == 0) j = i-4;
//window.alert("j = "+j+"i = "+i);
if(j != -1){
temp = Tile[i][removed];
Tile[i][removed] = Tile[j][removed];
Tile[j][removed] = temp;
gameCheck();
}
}
function gameCheck(){
for(i = 0; i < 15; i++)<br>if(Tile[i][removed] != i+1) break;
if(i == 15)
[removed]("YOU ARE WIN!!");
//window.alert("i = "+i);
}
addEventListener("load", start , false);
//var tbody = document.getElementById("tablebody");
//window.addEventListener("onclick", window.alert(), false);
</head>
<body>
</body>
</html>
![[求助]HTML5 & javascript問題!!!!!!](http://attach.mobile01.com/attach/201301/mobile01-9c935eb71a4a50753692753978e533e5.jpg)