<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>坦克大战</title>
<style type="text/css">
body { background-color:#000; margin: 0 0 0 0; width:100%;height:100%;}
div#main {padding: 0 0 0 0;width:800px;height:500px;background:url(images/ground.bmp);}
</style>
</head>
<script type="text/javascript" src="js/Common.js"></script>
<script type="text/javascript" src="js/Config.js"></script>
<script type="text/javascript" src="js/Base.js"></script>
<script type="text/javascript" src="js/Region.js"></script>
<script type="text/javascript" src="js/GameUnit.js"></script>
<script type="text/javascript" src="js/KeyCodeList.js"></script>
<script type="text/javascript" src="js/AIAction.js"></script>
<script type="text/javascript">
var emTankIdx = 3;
var emTanks = new Array(20);
function enemyDestroyed() {//地方坦克死后重新升成一辆坦克
if (emTankIdx < emTanks.length) {
var x, y;
do {
y = 10;
x = Math.floor(Math.random() * 3) * 220 + 40;
emTanks[emTankIdx].Test(x, y);
} while (emTanks[emTankIdx].Overlaped());
emTanks[emTankIdx].Draw(x, y);
emTanks[emTankIdx].ready(1);
emTankIdx++;
}
}
var killed = 0;
</script>
<script type="text/javascript">
var Game = function () { this.initialize.apply(this, arguments) };
Game.prototype = {
initialize: function () {
//水
var water1 = new Region("water1", 50, 2, "water");
water1.Draw(0, 150);
//水
var water2 = new Region("water2", 50, 2, "water");
water2.Draw(0, 300);
var iron = new Region("iron", 20, 2, "iron");
iron.Draw(250, 225);
var myTank = new GameUnit("mytank", 1, 1, "TankHuman");//己方坦克
myTank.Draw(200, 460);
myTank.whenDead = function () {
alert("你死了,你总共歼灭了" + killed + "辆坦克");
location.href = location.href;
}
var home = new GameUnit("home", 1, 1, "Home");//老家
home.Draw(400, 460);
home.whenDead = function () {
alert("Game Over!你总共歼灭了" + killed + "辆坦克");
location.href = location.href;
}
//保护老家的砖头块
var block1 = new GameUnit("block1", 1, 1, "Block");
var block2 = new GameUnit("block2", 1, 1, "Block");
var block3 = new GameUnit("block3", 1, 1, "Block");
var block4 = new GameUnit("block4", 1, 1, "Block");
var block5 = new GameUnit("block5", 1, 1, "Block");
var block6 = new GameUnit("block6", 1, 1, "Block");
var block7 = new GameUnit("block7", 1, 1, "Block");
var block8 = new GameUnit("block8", 1, 1, "Block");
var block9 = new GameUnit("block9", 1, 1, "Block");
block1.Draw(380, 480);
block2.Draw(380, 464);
block3.Draw(380, 448);
block4.Draw(396, 448);
block5.Draw(412, 448);
block6.Draw(428, 448);
block7.Draw(444, 448);
block8.Draw(444, 464);
block9.Draw(444, 480);
//敌方坦克
for (var i = 0; i < emTanks.length; i++) {
var id = "tank" + i;
emTanks[i] = new GameUnit(id, 1, 1, "TankComputer");
emTanks[i].whenDead = function () {//一辆坦克死后过两秒重新生成一辆坦克
killed++;
setTimeout("enemyDestroyed()", 2000);
};
}
emTanks[0].Draw(40, 10);
emTanks[0].ready(1);
emTanks[1].Draw(480, 10);
emTanks[1].ready(1);
emTanks[2].Draw(260, 10);
emTanks[2].ready(1);
}
}
window.onload = function () {
new Game();
}
</script>
<body>
<div id="main">
<div id="_back"> </div>
<div id="_fore"> </div>
</div>
</body>
</html>