init original code

This commit is contained in:
Linex CD 2016-11-29 23:42:29 +08:00
parent 54017849c3
commit 68f35f7495
29 changed files with 2677 additions and 0 deletions

View File

@ -1 +1,2 @@
#battlecity
网上找的小霸王坦克游戏源码修了些bug,做了点优化.

BIN
audio/attack.mp3 Normal file

Binary file not shown.

BIN
audio/bulletCrack.mp3 Normal file

Binary file not shown.

BIN
audio/move.mp3 Normal file

Binary file not shown.

BIN
audio/playerCrack.mp3 Normal file

Binary file not shown.

BIN
audio/prop.mp3 Normal file

Binary file not shown.

BIN
audio/start.mp3 Normal file

Binary file not shown.

BIN
audio/tankCrack.mp3 Normal file

Binary file not shown.

330
css/default.css Normal file

File diff suppressed because one or more lines are too long

BIN
dota.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 KiB

BIN
images/Thumbs.db Normal file

Binary file not shown.

BIN
images/menu.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
images/tankAll.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

51
index.html Normal file
View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="zh" class="no-js demo-1">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="js/jquery.min.js"></script>
<script src="js/Helper.js"></script>
<script src="js/keyboard.js"></script>
<script src="js/const.js"></script>
<script src="js/level.js"></script>
<script src="js/crackAnimation.js"></script>
<script src="js/prop.js"></script>
<script src="js/bullet.js"></script>
<script src="js/tank.js"></script>
<script src="js/num.js"></script>
<script src="js/menu.js"></script>
<script src="js/map.js"></script>
<script src="js/Collision.js"></script>
<script src="js/stage.js"></script>
<script src="js/main.js"></script>
<link rel="stylesheet" type="text/css" href="css/default.css" />
<style type="text/css">
#canvasDiv canvas{
position:absolute;
}
</style>
</head>
<body bgcolor=black>
<div style="width:100%; height:100%;background-image:url(dota.jpg);" >
<div class="container" >
<div class="main clearfix" style="position:fixed;bottom:12px;height:488px;">
<div style="position: fixed;margin:5px auto;width:100%;height:448px;">
<div id="canvasDiv" style="margin-left:auto;margin-right:auto;">
<canvas id="wallCanvas" ></canvas>
<canvas id="tankCanvas" ></canvas>
<canvas id="grassCanvas" ></canvas>
<canvas id="overCanvas" ></canvas>
<canvas id="stageCanvas"></canvas>
</div>
</div>
</div>
</div><!-- /container -->
</div>
</body>
</html>

194
js/Collision.js Normal file
View File

@ -0,0 +1,194 @@
/**
* 检测2个物体是否碰撞
* @param object1 物体1
* @param object2 物体2
* @param overlap 允许重叠的大小
* @returns {Boolean} 如果碰撞了返回true
*/
function CheckIntersect(object1, object2, overlap)
{
// x-轴 x-轴
// A1------>B1 C1 A2------>B2 C2
// +--------+ ^ +--------+ ^
// | object1| | y-轴 | object2| | y-轴
// | | | | | |
// +--------+ D1 +--------+ D2
//
//overlap是重叠的区域值
A1 = object1.x + overlap;
B1 = object1.x + object1.size - overlap;
C1 = object1.y + overlap;
D1 = object1.y + object1.size - overlap;
A2 = object2.x + overlap;
B2 = object2.x + object2.size - overlap;
C2 = object2.y + overlap;
D2 = object2.y + object2.size - overlap;
//假如他们在x-轴重叠
if(A1 >= A2 && A1 <= B2
|| B1 >= A2 && B1 <= B2)
{
//判断y-轴重叠
if(C1 >= C2 && C1 <= D2 || D1 >= C2 && D1 <= D2)
{
return true;
}
}
return false;
}
/**
* 坦克与地图块碰撞
* @param tank 坦克对象
* @param mapobj 地图对象
* @returns {Boolean} 如果碰撞返回true
*/
function tankMapCollision(tank,mapobj){
//移动检测,记录最后一次的移动方向,根据方向判断+-overlap,
var tileNum = 0;//需要检测的tile数
var rowIndex = 0;//map中的行索引
var colIndex = 0;//map中的列索引
var overlap = 3;//允许重叠的大小
//根据tank的x、y计算出map中的row和col
if(tank.dir == UP){
rowIndex = parseInt((tank.tempY + overlap - mapobj.offsetY)/mapobj.tileSize);
colIndex = parseInt((tank.tempX + overlap- mapobj.offsetX)/mapobj.tileSize);
}else if(tank.dir == DOWN){
//向下即dir==1的时候行索引的计算需要+tank.Height
rowIndex = parseInt((tank.tempY - overlap - mapobj.offsetY + tank.size)/mapobj.tileSize);
colIndex = parseInt((tank.tempX + overlap- mapobj.offsetX)/mapobj.tileSize);
}else if(tank.dir == LEFT){
rowIndex = parseInt((tank.tempY + overlap- mapobj.offsetY)/mapobj.tileSize);
colIndex = parseInt((tank.tempX + overlap - mapobj.offsetX)/mapobj.tileSize);
}else if(tank.dir == RIGHT){
rowIndex = parseInt((tank.tempY + overlap- mapobj.offsetY)/mapobj.tileSize);
//向右即dir==3的时候列索引的计算需要+tank.Height
colIndex = parseInt((tank.tempX - overlap - mapobj.offsetX + tank.size)/mapobj.tileSize);
}
if(rowIndex >= mapobj.HTileCount || rowIndex < 0 || colIndex >= mapobj.wTileCount || colIndex < 0){
return true;
}
if(tank.dir == UP || tank.dir == DOWN){
var tempWidth = parseInt(tank.tempX - map.offsetX - (colIndex)*mapobj.tileSize + tank.size - overlap);//去除重叠部分
if(tempWidth % mapobj.tileSize == 0 ){
tileNum = parseInt(tempWidth/mapobj.tileSize);
}else{
tileNum = parseInt(tempWidth/mapobj.tileSize) + 1;
}
for(var i=0;i<tileNum && colIndex+i < mapobj.wTileCount ;i++){
var mapContent = mapobj.mapLevel[rowIndex][colIndex+i];
if(mapContent == WALL || mapContent == GRID || mapContent == WATER || mapContent == HOME || mapContent == ANOTHREHOME){
if(tank.dir == UP){
tank.y = mapobj.offsetY + rowIndex * mapobj.tileSize + mapobj.tileSize - overlap;
}else if(tank.dir == DOWN){
tank.y = mapobj.offsetY + rowIndex * mapobj.tileSize - tank.size + overlap;
}
return true;
}
}
}else{
var tempHeight = parseInt(tank.tempY - map.offsetY - (rowIndex)*mapobj.tileSize + tank.size - overlap);//去除重叠部分
if(tempHeight % mapobj.tileSize == 0 ){
tileNum = parseInt(tempHeight/mapobj.tileSize);
}else{
tileNum = parseInt(tempHeight/mapobj.tileSize) + 1;
}
for(var i=0;i<tileNum && rowIndex+i < mapobj.HTileCount;i++){
var mapContent = mapobj.mapLevel[rowIndex+i][colIndex];
if(mapContent == WALL || mapContent == GRID || mapContent == WATER || mapContent == HOME || mapContent == ANOTHREHOME){
if(tank.dir == LEFT){
tank.x = mapobj.offsetX + colIndex * mapobj.tileSize + mapobj.tileSize - overlap;
}else if(tank.dir == RIGHT){
tank.x = mapobj.offsetX + colIndex * mapobj.tileSize - tank.size + overlap;
}
return true;
}
}
}
return false;
}
/**
* 子弹与地图块的碰撞
* @param bullet 子弹对象
* @param mapobj 地图对象
*/
function bulletMapCollision(bullet,mapobj){
var tileNum = 0;//需要检测的tile数
var rowIndex = 0;//map中的行索引
var colIndex = 0;//map中的列索引
var mapChangeIndex = [];//map中需要更新的索引数组
var result = false;//是否碰撞
//根据bullet的x、y计算出map中的row和col
if(bullet.dir == UP){
rowIndex = parseInt((bullet.y - mapobj.offsetY)/mapobj.tileSize);
colIndex = parseInt((bullet.x - mapobj.offsetX)/mapobj.tileSize);
}else if(bullet.dir == DOWN){
//向下即dir==1的时候行索引的计算需要+bullet.Height
rowIndex = parseInt((bullet.y - mapobj.offsetY + bullet.size)/mapobj.tileSize);
colIndex = parseInt((bullet.x - mapobj.offsetX)/mapobj.tileSize);
}else if(bullet.dir == LEFT){
rowIndex = parseInt((bullet.y - mapobj.offsetY)/mapobj.tileSize);
colIndex = parseInt((bullet.x - mapobj.offsetX)/mapobj.tileSize);
}else if(bullet.dir == RIGHT){
rowIndex = parseInt((bullet.y - mapobj.offsetY)/mapobj.tileSize);
//向右即dir==3的时候列索引的计算需要+bullet.Height
colIndex = parseInt((bullet.x - mapobj.offsetX + bullet.size)/mapobj.tileSize);
}
if(rowIndex >= mapobj.HTileCount || rowIndex < 0 || colIndex >= mapobj.wTileCount || colIndex < 0){
return true;
}
if(bullet.dir == UP || bullet.dir == DOWN){
var tempWidth = parseInt(bullet.x - map.offsetX - (colIndex)*mapobj.tileSize + bullet.size);
if(tempWidth % mapobj.tileSize == 0 ){
tileNum = parseInt(tempWidth/mapobj.tileSize);
}else{
tileNum = parseInt(tempWidth/mapobj.tileSize) + 1;
}
for(var i=0;i<tileNum && colIndex+i < mapobj.wTileCount ;i++){
var mapContent = mapobj.mapLevel[rowIndex][colIndex+i];
if(mapContent == WALL || mapContent == GRID || mapContent == HOME || mapContent == ANOTHREHOME){
//bullet.distroy();
result = true;
if(mapContent == WALL){
//墙被打掉
mapChangeIndex.push([rowIndex,colIndex+i]);
}else if(mapContent == GRID){
}else{
isGameOver = true;
break;
}
}
}
}else{
var tempHeight = parseInt(bullet.y - map.offsetY - (rowIndex)*mapobj.tileSize + bullet.size);
if(tempHeight % mapobj.tileSize == 0 ){
tileNum = parseInt(tempHeight/mapobj.tileSize);
}else{
tileNum = parseInt(tempHeight/mapobj.tileSize) + 1;
}
for(var i=0;i<tileNum && rowIndex+i < mapobj.HTileCount;i++){
var mapContent = mapobj.mapLevel[rowIndex+i][colIndex];
if(mapContent == WALL || mapContent == GRID || mapContent == HOME || mapContent == ANOTHREHOME){
//bullet.distroy();
result = true;
if(mapContent == WALL){
//墙被打掉
mapChangeIndex.push([rowIndex+i,colIndex]);
}else if(mapContent == GRID){
}else{
isGameOver = true;
break;
}
}
}
}
//更新地图
map.updateMap(mapChangeIndex,0);
return result;
}

62
js/Helper.js Normal file
View File

@ -0,0 +1,62 @@
/**
* 数组删除某个元素
* @param arg 元素
* @returns
*/
Array.prototype.remove = function(arg){
var i=0,n=0;
var arrSize = this.length;
for(i=0;i<arrSize;i++){
if(this[i] != arg){
this[n++]=this[i];
}
}
if(n<i){
this.length = n;
}
};
/**
* 数组根据下标删除元素
* @param index 元素下标
* @returns
*/
Array.prototype.removeByIndex = function(index){
var i=0,n=0;
var arrSize = this.length;
for(i=0;i<arrSize;i++){
if(this[i] != this[index]){
this[n++]=this[i];
}
}
if(n<i){
this.length = n;
}
};
/**
* 数组是否包含某个元素
* @param arg 元素
* @returns
*/
Array.prototype.contain = function(arg){
var i=0;
var arrSize = this.length;
for(i=0;i<arrSize;i++){
if(this[i] == arg){
return true;
}
}
return false;
};

123
js/bullet.js Normal file
View File

@ -0,0 +1,123 @@
var Bullet = function(context,owner,type,dir){
this.ctx = context;
this.x = 0;
this.y = 0;
this.owner = owner; //子弹的所属者
this.type = type;//1、玩家 2、敌方
this.dir = dir;
this.speed = 3;
this.size = 6;
this.hit = false;
this.isDestroyed = false;
this.draw = function(){
this.ctx.drawImage(RESOURCE_IMAGE,POS["bullet"][0]+this.dir*this.size,POS["bullet"][1],this.size,this.size,this.x,this.y,this.size,this.size);
this.move();
};
this.move = function(){
if(this.dir == UP){
this.y -= this.speed;
}else if(this.dir == DOWN){
this.y += this.speed;
}else if(this.dir == RIGHT){
this.x += this.speed;
}else if(this.dir == LEFT){
this.x -= this.speed;
}
this.isHit();
};
/**
* 碰撞检测
*/
this.isHit = function(){
if(this.isDestroyed){
return;
}
//临界检测
if(this.x < map.offsetX){
this.x = map.offsetX;
this.hit = true;
}else if(this.x > map.offsetX + map.mapWidth - this.size){
this.x = map.offsetX + map.mapWidth - this.size;
this.hit = true;
}
if(this.y < map.offsetY){
this.y = map.offsetY;
this.hit = true;
}else if(this.y > map.offsetY + map.mapHeight - this.size){
this.y = map.offsetY + map.mapHeight - this.size;
this.hit = true;
}
//子弹是否碰撞了其他子弹
if(!this.hit){
if(bulletArray != null && bulletArray.length > 0){
for(var i=0;i<bulletArray.length;i++){
if(bulletArray[i] != this && this.owner.isAI != bulletArray[i].owner.isAI && bulletArray[i].hit == false && CheckIntersect(bulletArray[i],this,0)){
this.hit = true;
bulletArray[i].hit = true;
break;
}
}
}
}
if(!this.hit){
//地图检测
if(bulletMapCollision(this,map)){
this.hit = true;
}
//是否击中坦克
if(this.type == BULLET_TYPE_PLAYER){
if(enemyArray != null || enemyArray.length > 0){
for(var i=0;i<enemyArray.length;i++){
var enemyObj = enemyArray[i];
if(!enemyObj.isDestroyed && CheckIntersect(this,enemyObj,0)){
CheckIntersect(this,enemyObj,0);
if(enemyObj.lives > 1){
enemyObj.lives --;
}else{
enemyObj.distroy();
}
this.hit = true;
break;
}
}
}
}else if(this.type == BULLET_TYPE_ENEMY){
if(player1.lives > 0 && CheckIntersect(this,player1,0)){
if(!player1.isProtected && !player1.isDestroyed){
player1.distroy();
}
this.hit = true;
}else if(player2.lives > 0 && CheckIntersect(this,player2,0)){
if(!player2.isProtected && !player2.isDestroyed){
player2.distroy();
}
this.hit = true;
}
}
}
if(this.hit){
this.distroy();
}
};
/**
* 销毁
*/
this.distroy = function(){
this.isDestroyed = true;
crackArray.push(new CrackAnimation(CRACK_TYPE_BULLET,this.ctx,this));
if(!this.owner.isAI){
BULLET_DESTROY_AUDIO.play();
}
};
};

79
js/const.js Normal file
View File

@ -0,0 +1,79 @@
/**
* 静态变量
*/
var SCREEN_WIDTH = 512; //屏幕宽
var SCREEN_HEIGHT = 448;//屏幕高
/**************图片资源*****************/
var MENU_IMAGE = new Image();
MENU_IMAGE.src = "images/menu.gif";
var RESOURCE_IMAGE = new Image();
RESOURCE_IMAGE.src = "images/tankAll.gif";
/**************各个图块在图片中的位置*****************/
var POS = new Array();
POS["selectTank"] = [128,96];
POS["stageLevel"] = [396,96];
POS["num"] = [256,96];
POS["map"] = [0,96];
POS["home"] = [256,0];
POS["score"] = [0,112];
POS["player"] = [0,0];
POS["protected"] = [160,96];
POS["enemyBefore"] = [256,32];
POS["enemy1"] = [0,32];
POS["enemy2"] = [128,32];
POS["enemy3"] = [0,64];
POS["bullet"] = [80,96];
POS["tankBomb"] = [0,160];
POS["bulletBomb"] = [320,0];
POS["over"] = [384,64];
POS["prop"] = [256,110];
/**************声音资源*****************/
var START_AUDIO = new Audio("audio/start.mp3");
var BULLET_DESTROY_AUDIO = new Audio("audio/bulletCrack.mp3");
var TANK_DESTROY_AUDIO = new Audio("audio/tankCrack.mp3");
var PLAYER_DESTROY_AUDIO = new Audio("audio/playerCrack.mp3");
var MOVE_AUDIO = new Audio("audio/move.mp3");
var ATTACK_AUDIO = new Audio("audio/attack.mp3");
var PROP_AUDIO = new Audio("audio/prop.mp3");
/**************游戏状态*****************/
var GAME_STATE_MENU = 0;
var GAME_STATE_INIT = 1;
var GAME_STATE_START = 2;
var GAME_STATE_OVER = 3;
var GAME_STATE_WIN = 4;
/**************地图块*****************/
var WALL = 1;
var GRID = 2;
var GRASS = 3;
var WATER = 4;
var ICE = 5;
var HOME = 9;
var ANOTHREHOME = 8;
/**************坦克及子弹的四个方向*****************/
var UP = 0;
var DOWN = 1;
var LEFT = 2;
var RIGHT = 3;
/**************坦克及子弹的四个方向*****************/
var ENEMY_LOCATION = [192,0,384]; //相对与主游戏区
/**************子弹类型*****************/
var BULLET_TYPE_PLAYER = 1;
var BULLET_TYPE_ENEMY = 2;
/**************爆炸类型****************/
var CRACK_TYPE_TANK = "tank";
var CRACK_TYPE_BULLET = "bullet";

38
js/crackAnimation.js Normal file
View File

@ -0,0 +1,38 @@
var CrackAnimation = function(type,context,crackObj){
this.times = 0;
this.ctx = context;
this.frame = 0;
this.x = 0;
this.y = 0;
this.posName = "";
this.size = 0;
this.isOver = false;
this.tempDir = 1;
this.owner = crackObj;
if(type == CRACK_TYPE_TANK){
this.posName = "tankBomb";
this.size = 66;
this.frame = 4;
}else{
this.posName = "bulletBomb";
this.size = 32;
this.frame = 3;
}
this.x = crackObj.x + (parseInt(crackObj.size - this.size)/2);
this.y = crackObj.y + (parseInt(crackObj.size - this.size)/2);
this.draw = function(){
var gaptime = 3;
var temp = parseInt(this.times/gaptime);
this.ctx.drawImage(RESOURCE_IMAGE,POS[this.posName][0]+temp*this.size,POS[this.posName][1],this.size,this.size,this.x,this.y,this.size,this.size);
this.times += this.tempDir;
if(this.times > this.frame * gaptime - parseInt(gaptime/2)){
this.tempDir = -1;
}
if(this.times <= 0){
this.isOver = true;
}
};
};

18
js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

58
js/keyboard.js Normal file
View File

@ -0,0 +1,58 @@
/**
* 键盘按钮
*/
var Keyboard = function(){
this.UP = 38;
this.DOWN = 40;
this.RIGHT = 39;
this.LEFT = 37;
this.SPACE = 32;
this.TAB = 9;
this.ENTER = 13;
this.CTRL = 17;
this.ALT = 18;
this.Num0 = 48;
this.Num1 = 49;
this.Num2 = 50;
this.Num3 = 51;
this.Num4 = 52;
this.Num5 = 53;
this.Num6 = 54;
this.Num7 = 55;
this.Num8 = 56;
this.Num9 = 57;
this.A = 65;
this.B = 66;
this.C = 67;
this.D = 68;
this.E = 69;
this.F = 70;
this.G = 71;
this.H = 72;
this.I = 73;
this.J = 74;
this.K = 75;
this.L = 76;
this.M = 77;
this.N = 78;
this.O = 79;
this.P = 80;
this.Q = 81;
this.R = 82;
this.S = 83;
this.T = 84;
this.U = 85;
this.V = 86;
this.W = 87;
this.X = 88;
this.Y = 89;
this.Z = 90;
};
var keyboard = new Keyboard();

633
js/level.js Normal file
View File

@ -0,0 +1,633 @@
/**
* 地图数组
* 1水泥墙 2铁墙 3 4 5 9
*/
var map1 =
[
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0],
[0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0],
[0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0],
[0,0,1,1,0,0,1,1,0,0,1,1,2,2,1,1,0,0,1,1,0,0,1,1,0,0],
[0,0,1,1,0,0,1,1,0,0,1,1,2,2,1,1,0,0,1,1,0,0,1,1,0,0],
[0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0],
[0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0],
[0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,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4,4,4,1,5,4,0,3,3,4,3,3,3,4,3,0,1,4,2,0,1,4,3,0,4],
[0,0,2,4,1,5,4,0,3,0,4,4,4,4,4,0,0,1,4,2,0,1,4,4,3,4],
[0,1,5,5,5,5,4,3,3,1,1,1,1,1,1,1,0,1,4,3,3,3,3,4,0,4],
[0,0,5,4,4,4,4,3,3,0,0,0,3,3,3,3,3,1,4,4,4,0,3,4,0,4],
[0,0,5,0,1,3,5,0,3,0,0,0,3,1,1,1,3,1,0,3,4,0,3,4,3,4],
[5,5,5,0,1,3,5,0,3,0,2,2,3,2,2,0,3,0,0,3,4,0,0,4,4,4],
[0,0,1,1,0,0,1,1,0,0,0,1,1,1,1,0,0,0,4,4,3,3,3,3,3,3],
[0,0,0,0,0,0,0,0,0,0,0,1,9,8,1,0,0,0,4,4,0,0,3,3,0,0],
[0,0,0,0,0,0,0,0,0,0,0,1,8,8,1,0,0,0,4,4,0,0,3,3,0,0]
];

377
js/main.js Normal file
View File

@ -0,0 +1,377 @@
var ctx;//2d画布
var wallCtx;//地图画布
var grassCtx;//草地画布
var tankCtx;//坦克画布
var overCtx;//结束画布
var menu = null;//菜单
var stage = null;//舞台
var map = null;//地图
var player1 = null;//玩家1
var player2 = null;//玩家2
var prop = null;
var enemyArray = [];//敌方坦克
var bulletArray = [];//子弹数组
var keys = [];//记录按下的按键
var crackArray = [];//爆炸数组
var gameState = GAME_STATE_MENU;//默认菜单状态
var level = 1;
var maxEnemy = 20;//敌方坦克总数
var maxAppearEnemy = 5;//屏幕上一起出现的最大数
var appearEnemy = 0; //已出现的敌方坦克
var mainframe = 0;
var isGameOver = false;
var overX = 176;
var overY = 384;
var emenyStopTime = 0;
var homeProtectedTime = -1;
var propTime = 300;
$(document).ready(function(){
initScreen();
initObject();
setInterval(gameLoop,20);
});
function initScreen(){
var canvas = $("#stageCanvas");
ctx = canvas[0].getContext("2d");
canvas.attr({"width":SCREEN_WIDTH});
canvas.attr({"height":SCREEN_HEIGHT});
wallCtx = $("#wallCanvas")[0].getContext("2d");
grassCtx = $("#grassCanvas")[0].getContext("2d");
$("#wallCanvas").attr({"width":SCREEN_WIDTH});
$("#wallCanvas").attr({"height":SCREEN_HEIGHT});
$("#grassCanvas").attr({"width":SCREEN_WIDTH});
$("#grassCanvas").attr({"height":SCREEN_HEIGHT});
tankCtx = $("#tankCanvas")[0].getContext("2d");
$("#tankCanvas").attr({"width":SCREEN_WIDTH});
$("#tankCanvas").attr({"height":SCREEN_HEIGHT});
overCtx = $("#overCanvas")[0].getContext("2d");
$("#overCanvas").attr({"width":SCREEN_WIDTH});
$("#overCanvas").attr({"height":SCREEN_HEIGHT});
$("#canvasDiv").css({"width":SCREEN_WIDTH});
$("#canvasDiv").css({"height":SCREEN_HEIGHT});
$("#canvasDiv").css({"background-color":"#000000"});
}
function initObject(){
menu = new Menu(ctx);
stage = new Stage(ctx,level);
map = new Map(wallCtx,grassCtx);
player1 = new PlayTank(tankCtx);
player1.x = 129 + map.offsetX;
player1.y = 385 + map.offsetY;
player2 = new PlayTank(tankCtx);
player2.offsetX = 128; //player2的图片x与图片1相距128
player2.x = 256 + map.offsetX;
player2.y = 385 + map.offsetY;
appearEnemy = 0; //已出现的敌方坦克
enemyArray = [];//敌方坦克
bulletArray = [];//子弹数组
keys = [];//记录按下的按键
crackArray = [];//爆炸数组
isGameOver = false;
overX = 176;
overY = 384;
overCtx.clearRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
emenyStopTime = 0;
homeProtectedTime = -1;
propTime = 1000;
}
function gameLoop(){
switch(gameState){
case GAME_STATE_MENU:
menu.draw();
break;
case GAME_STATE_INIT:
stage.draw();
if(stage.isReady == true){
gameState = GAME_STATE_START;
}
break;
case GAME_STATE_START:
drawAll();
if(isGameOver ||(player1.lives <=0 && player2.lives <= 0)){
gameState = GAME_STATE_OVER;
map.homeHit();
PLAYER_DESTROY_AUDIO.play();
}
if(appearEnemy == maxEnemy && enemyArray.length == 0){
gameState = GAME_STATE_WIN;
}
break;
case GAME_STATE_WIN:
nextLevel();
break;
case GAME_STATE_OVER:
gameOver();
break;
}
}
$(document).keydown(function(e){
switch(gameState){
case GAME_STATE_MENU:
if(e.keyCode == keyboard.ENTER){
gameState = GAME_STATE_INIT;
//只有一个玩家
if(menu.playNum == 1){
player2.lives = 0;
}
}else{
var n = 0;
if(e.keyCode == keyboard.DOWN){
n = 1;
}else if(e.keyCode == keyboard.UP){
n = -1;
}
menu.next(n);
}
break;
case GAME_STATE_START:
if(!keys.contain(e.keyCode)){
keys.push(e.keyCode);
}
//射击
if(e.keyCode == keyboard.SPACE && player1.lives > 0){
player1.shoot(BULLET_TYPE_PLAYER);
}else if(e.keyCode == keyboard.ENTER && player2.lives > 0){
player2.shoot(BULLET_TYPE_ENEMY);
}else if(e.keyCode == keyboard.N){
nextLevel();
}else if(e.keyCode == keyboard.P){
preLevel();
}
break;
}
});
$(document).keyup(function(e){
keys.remove(e.keyCode);
});
function initMap(){
map.setMapLevel(level);;
map.draw();
drawLives();
}
function drawLives(){
map.drawLives(player1.lives,1);
map.drawLives(player2.lives,2);
}
function drawBullet(){
if(bulletArray != null && bulletArray.length > 0){
for(var i=0;i<bulletArray.length;i++){
var bulletObj = bulletArray[i];
if(bulletObj.isDestroyed){
bulletObj.owner.isShooting = false;
bulletArray.removeByIndex(i);
i--;
}else{
bulletObj.draw();
}
}
}
}
function keyEvent(){
if(keys.contain(keyboard.W)){
player1.dir = UP;
player1.hit = false;
player1.move();
}else if(keys.contain(keyboard.S)){
player1.dir = DOWN;
player1.hit = false;
player1.move();
}else if(keys.contain(keyboard.A)){
player1.dir = LEFT;
player1.hit = false;
player1.move();
}else if(keys.contain(keyboard.D)){
player1.dir = RIGHT;
player1.hit = false;
player1.move();
}
if(keys.contain(keyboard.UP)){
player2.dir = UP;
player2.hit = false;
player2.move();
}else if(keys.contain(keyboard.DOWN)){
player2.dir = DOWN;
player2.hit = false;
player2.move();
}else if(keys.contain(keyboard.LEFT)){
player2.dir = LEFT;
player2.hit = false;
player2.move();
}else if(keys.contain(keyboard.RIGHT)){
player2.dir = RIGHT;
player2.hit = false;
player2.move();
}
}
function addEnemyTank(){
if(enemyArray == null || enemyArray.length >= maxAppearEnemy || maxEnemy == 0){
return ;
}
appearEnemy++;
var rand = parseInt(Math.random()*3);
var obj = null;
if(rand == 0){
obj = new EnemyOne(tankCtx);
}else if(rand == 1){
obj = new EnemyTwo(tankCtx);
}else if(rand == 2){
obj = new EnemyThree(tankCtx);
}
obj.x = ENEMY_LOCATION[parseInt(Math.random()*3)] + map.offsetX;
obj.y = map.offsetY;
obj.dir = DOWN;
enemyArray[enemyArray.length] = obj;
//更新地图右侧坦克数
map.clearEnemyNum(maxEnemy,appearEnemy);
}
function drawEnemyTanks(){
if(enemyArray != null || enemyArray.length > 0){
for(var i=0;i<enemyArray.length;i++){
var enemyObj = enemyArray[i];
if(enemyObj.isDestroyed){
enemyArray.removeByIndex(i);
i--;
}else{
enemyObj.draw();
}
}
}
if(emenyStopTime > 0){
emenyStopTime --;
}
}
function drawAll(){
tankCtx.clearRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
if(player1.lives>0){
player1.draw();
}
if(player2.lives > 0){
player2.draw();
}
drawLives();
if(appearEnemy<maxEnemy){
if(mainframe % 100 == 0){
addEnemyTank();
mainframe = 0;
}
mainframe++;
}
drawEnemyTanks();
drawBullet();
drawCrack();
keyEvent();
if(propTime<=0){
drawProp();
}else{
propTime --;
}
if(homeProtectedTime > 0){
homeProtectedTime --;
}else if(homeProtectedTime == 0){
homeProtectedTime = -1;
homeNoProtected();
}
}
function drawCrack(){
if(crackArray != null && crackArray.length > 0){
for(var i=0;i<crackArray.length;i++){
var crackObj = crackArray[i];
if(crackObj.isOver){
crackArray.removeByIndex(i);
i--;
if(crackObj.owner == player1){
player1.renascenc(1);
}else if(crackObj.owner == player2){
player2.renascenc(2);
}
}else{
crackObj.draw();
}
}
}
}
function gameOver(){
overCtx.clearRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
overCtx.drawImage(RESOURCE_IMAGE,POS["over"][0],POS["over"][1],64,32,overX+map.offsetX,overY+map.offsetY,64,32);
overY -= 2 ;
if(overY <= parseInt(map.mapHeight/2)){
initObject();
//只有一个玩家
if(menu.playNum == 1){
player2.lives = 0;
}
gameState = GAME_STATE_MENU;
}
}
function nextLevel(){
level ++;
if(level == 22){
level = 1;
}
initObject();
//只有一个玩家
if(menu.playNum == 1){
player2.lives = 0;
}
stage.init(level);
gameState = GAME_STATE_INIT;
}
function preLevel(){
level --;
if(level == 0){
level = 21;
}
initObject();
//只有一个玩家
if(menu.playNum == 1){
player2.lives = 0;
}
stage.init(level);
gameState = GAME_STATE_INIT;
}
function drawProp(){
var rand = Math.random();
if(rand < 0.4 && prop == null){
prop = new Prop(overCtx);
prop.init();
}
if(prop != null){
prop.draw();
if(prop.isDestroyed){
prop = null;
propTime = 1000;
}
}
}
function homeNoProtected(){
var mapChangeIndex = [[23,11],[23,12],[23,13],[23,14],[24,11],[24,14],[25,11],[25,14]];
map.updateMap(mapChangeIndex,WALL);
};

155
js/map.js Normal file
View File

@ -0,0 +1,155 @@
var Map = function(wCtx,gCtx){
this.level = 1;
this.mapLevel = null;
this.wallCtx = wCtx;
this.grassCtx = gCtx;
this.offsetX = 32; //主游戏区的X偏移量
this.offsetY = 16;//主游戏区的Y偏移量
this.wTileCount = 26; //主游戏区的宽度地图块数
this.HTileCount = 26;//主游戏区的高度地图块数
this.tileSize = 16; //地图块的大小
this.homeSize = 32; //家图标的大小
this.num = new Num(this.wallCtx);
this.mapWidth = 416;
this.mapHeight = 416;
this.setMapLevel = function(level){
this.level = level;
var tempMap = eval("map"+this.level);
this.mapLevel = new Array();
for(var i=0;i<tempMap.length;i++){
this.mapLevel[i] = new Array();
for(var j=0;j<tempMap[i].length;j++){
this.mapLevel[i][j] = tempMap[i][j];
}
}
};
/**
* 绘制地图
*/
this.draw = function(){
this.wallCtx.fillStyle = "#7f7f7f";
this.wallCtx.fillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
this.wallCtx.fillStyle = "#000";
this.wallCtx.fillRect(this.offsetX,this.offsetY,this.mapWidth,this.mapHeight);//主游戏区
this.grassCtx.clearRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
for(var i=0;i<this.HTileCount;i++){
for(var j=0;j<this.wTileCount;j++){
if(this.mapLevel[i][j] == WALL || this.mapLevel[i][j] == GRID || this.mapLevel[i][j] == WATER || this.mapLevel[i][j] == ICE){
this.wallCtx.drawImage(RESOURCE_IMAGE,this.tileSize*(this.mapLevel[i][j]-1) + POS["map"][0], POS["map"][1],this.tileSize,this.tileSize,j*this.tileSize + this.offsetX, i*this.tileSize + this.offsetY,this.tileSize,this.tileSize) ;
}else if(this.mapLevel[i][j] == GRASS){
this.grassCtx.drawImage(RESOURCE_IMAGE,this.tileSize*(this.mapLevel[i][j]-1) + POS["map"][0], POS["map"][1],this.tileSize,this.tileSize,j*this.tileSize + this.offsetX, i*this.tileSize + this.offsetY,this.tileSize,this.tileSize);
}else if(this.mapLevel[i][j] == HOME){
this.wallCtx.drawImage(RESOURCE_IMAGE,POS["home"][0], POS["home"][1], this.homeSize, this.homeSize, j*this.tileSize + this.offsetX, i*this.tileSize + this.offsetY, this.homeSize, this.homeSize) ;
}
}
}
this.drawNoChange();
this.drawEnemyNum(maxEnemy);
this.drawLevel();
this.drawLives(0,1);
this.drawLives(0,2);
};
/**
* 画固定不变的部分
*/
this.drawNoChange = function(){
this.wallCtx.drawImage(RESOURCE_IMAGE, POS["score"][0], POS["score"][1], 30, 32, 464, 256, 30, 32);//player1
this.wallCtx.drawImage(RESOURCE_IMAGE, 30 + POS["score"][0], POS["score"][1], 30, 32, 464, 304, 30, 32);//player2
//30,32旗帜的size, 464, 352旗帜在canvas中位置
this.wallCtx.drawImage(RESOURCE_IMAGE, 60 + POS["score"][0], POS["score"][1], 30, 32, 464, 352, 32, 30);//画旗帜
};
/**
* 画关卡数
*/
this.drawLevel = function(){
this.num.draw(this.level,468, 384);
};
/**
* 画右侧敌方坦克数
* @param enemyNum 地方坦克总数
*/
this.drawEnemyNum = function(enemyNum){
var x = 466;
var y = 34;
var enemySize = 16;
for(var i=1;i<=enemyNum;i++){
var tempX = x;
var tempY = y + parseInt((i+1)/2)*enemySize;
if(i%2 == 0){
tempX = x + enemySize;
}
this.wallCtx.drawImage(RESOURCE_IMAGE,92 + POS["score"][0],POS["score"][1],14, 14,tempX, tempY,14, 14);
}
};
/**
* 清除右侧敌方坦克数从最下面开始清楚
* @param totolEnemyNum 敌方坦克的总数
* @param enemyNum 已出现的敌方坦克数
*/
this.clearEnemyNum = function(totolEnemyNum,enemyNum){
var x = 466;
var y = 34 + this.offsetY;
if(enemyNum <= 0){
return ;
}
var enemySize = 16;
this.wallCtx.fillStyle = "#7f7f7f";
var tempX = x + (enemyNum % 2)*enemySize;
var tempY = y + (Math.ceil(totolEnemyNum/2)-1)*enemySize - (parseInt((enemyNum-1)/2))*enemySize;
this.wallCtx.fillRect(tempX,tempY,14,14);
};
/**
* 画坦克的生命数
* @param lives 生命数
* @param which 坦克索引1代表玩家1 2代表玩家2
*/
this.drawLives = function(lives,which){
var x = 482;
var y = 272;
if(which == 2){
y = 320;
}
this.wallCtx.fillStyle = "#7f7f7f";
this.wallCtx.fillRect(x,y,this.num.size,this.num.size);
this.num.draw(lives,x,y);
//this.wallCtx.drawImage(RESOURCE_IMAGE,POS["num"][0]+lives*14,POS["num"][1],14, 14,x, y,14, 14);
};
/**
* 更新地图
* @param indexArr 需要更新的地图索引数组二维数组[[1,1],[2,2]]
* @param target 更新之后的数值
*/
this.updateMap = function(indexArr,target){
if(indexArr != null && indexArr.length > 0){
var indexSize = indexArr.length;
for(var i=0;i<indexSize;i++){
var index = indexArr[i];
this.mapLevel[index[0]][index[1]] = target;
if(target > 0){
this.wallCtx.drawImage(RESOURCE_IMAGE,this.tileSize*(target-1) + POS["map"][0], POS["map"][1],this.tileSize,this.tileSize,index[1]*this.tileSize + this.offsetX, index[0]*this.tileSize + this.offsetY,this.tileSize,this.tileSize) ;
}else{
this.wallCtx.fillStyle = "#000";
this.wallCtx.fillRect(index[1]*this.tileSize + this.offsetX, index[0]*this.tileSize + this.offsetY,this.tileSize,this.tileSize);
}
}
}
};
this.homeHit = function(){
this.wallCtx.drawImage(RESOURCE_IMAGE,POS["home"][0]+this.homeSize, POS["home"][1], this.homeSize, this.homeSize, 12*this.tileSize + this.offsetX, 24*this.tileSize + this.offsetY, this.homeSize, this.homeSize) ;
};
};

50
js/menu.js Normal file
View File

@ -0,0 +1,50 @@
/**
* 游戏开始菜单
**/
var Menu = function(context){
this.ctx = context;
this.x = 0;
this.y = SCREEN_HEIGHT;
this.selectTank = new SelectTank();
this.playNum = 1;
this.times = 0;
/**
* 画菜单
*/
this.draw = function(){
this.times ++ ;
var temp = 0;
if( parseInt(this.times / 6) % 2 == 0){
temp = 0;
}else{
temp = this.selectTank.size;
}
if(this.y <= 0){
this.y = 0;
}else{
this.y -= 5;
}
this.ctx.clearRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
this.ctx.save();
//画背景
this.ctx.drawImage(MENU_IMAGE, this.x, this.y);
//画选择坦克
this.ctx.drawImage(RESOURCE_IMAGE,POS["selectTank"][0],POS["selectTank"][1] + temp,this.selectTank.size,this.selectTank.size,
this.selectTank.x,this.y + this.selectTank.ys[this.playNum-1],this.selectTank.size,this.selectTank.size);
this.ctx.restore();
};
/**
* 选择坦克上下移动
*/
this.next = function(n){
this.playNum += n;
if(this.playNum > 2){
this.playNum = 1;
}else if(this.playNum < 1){
this.playNum = 2;
}
};
};

24
js/num.js Normal file
View File

@ -0,0 +1,24 @@
var Num = function(context){
this.ctx = context;
this.size = 14;
this.draw = function(num,x,y){
var tempX = x;
var tempY = y;
var tempNumArray = [];
if(num == 0){
tempNumArray.push(0);
}else{
while(num > 0){
tempNumArray.push(num % 10);
num = parseInt(num/10);
}
}
for(var i=tempNumArray.length-1;i>=0;i--){
tempX = x+(tempNumArray.length-i-1) * this.size;
this.ctx.drawImage(RESOURCE_IMAGE,POS["num"][0]+tempNumArray[i]*14,POS["num"][1],this.size, this.size,tempX, tempY,this.size, this.size);
}
};
};

82
js/prop.js Normal file
View File

@ -0,0 +1,82 @@
var Prop = function(context){
this.x = 0;
this.y = 0;
this.duration = 600;
this.type = 0;
this.hit = false;
this.width = 30;
this.height = 28;
this.ctx = context;
this.isDestroyed = false;
this.size = 28;
this.init = function(){
this.ctx.clearRect(this.x,this.y,this.width,this.height);
this.duration = 600;
this.type = parseInt(Math.random() * 6);
this.x = parseInt(Math.random() * 384)+map.offsetX;
this.y = parseInt(Math.random() * 384)+map.offsetY;
this.isDestroyed = false;
};
this.draw = function(){
if(this.duration > 0 && !this.isDestroyed){
this.ctx.drawImage(RESOURCE_IMAGE,POS["prop"][0]+this.type*this.width,POS["prop"][1],this.width,this.height,this.x,this.y,this.width,this.height);
this.duration -- ;
this.isHit();
}else{
this.ctx.clearRect(this.x,this.y,this.width,this.height);
this.isDestroyed = true;
}
};
this.isHit = function(){
var player = null;
if(player1.lives > 0 && CheckIntersect(this,player1,0)){
this.hit = true;
player = player1;
}else if(player2.lives > 0 && CheckIntersect(this,player2,0)){
this.hit = true;
player = player2;
}
if(this.hit){
PROP_AUDIO.play();
this.isDestroyed = true;
this.ctx.clearRect(this.x,this.y,this.width,this.height);
switch(this.type){
case 0:
player.lives ++;
break;
case 1:
emenyStopTime = 500;
break;
case 2:
var mapChangeIndex = [[23,11],[23,12],[23,13],[23,14],[24,11],[24,14],[25,11],[25,14]];
map.updateMap(mapChangeIndex,GRID);
homeProtectedTime = 500;
break;
case 3:
if(enemyArray != null || enemyArray.length > 0){
for(var i=0;i<enemyArray.length;i++){
var enemyObj = enemyArray[i];
enemyObj.distroy();
}
}
break;
case 4:
break;
case 5:
player.isProtected = true;
player.protectedTime = 500;
break;
}
}
};
};

51
js/stage.js Normal file
View File

@ -0,0 +1,51 @@
var Stage = function(context,l){
this.ctx = context;
this.ctx.fillStyle = "#7f7f7f";
this.drawHeigth = 15;
this.level = l;
this.temp = 0;
this.dir = 1; //中间切换的方向1合上2展开
this.isReady = false;//标识地图是否已经画好
this.levelNum = new Num(context);
this.init = function(level){
this.dir = 1;
this.isReady = false;
this.level = level;
this.temp = 0;
};
this.draw = function(){
if(this.dir == 1){
//temp = 15*15 灰色屏幕已经画完
if(this.temp == 225){
//78,14为STAGE字样在图片资源中的宽和高194,208为canvas中的位置
this.ctx.drawImage(RESOURCE_IMAGE, POS["stageLevel"][0], POS["stageLevel"][1], 78, 14, 194, 208, 78, 14);
//14为数字的宽和高308, 208为canvas中的位置
this.levelNum.draw(this.level,308, 208);
//this.ctx.drawImage(RESOURCE_IMAGE,POS["num"][0]+this.level*14,POS["num"][1],14, 14,308, 208,14, 14);
//绘制地图,调用main里面的方法
initMap();
}else if(this.temp == 225 + 600){
//600即调用了600/15次主要用来停顿
this.temp = 225;
this.dir = -1;
START_AUDIO.play();
}else{
this.ctx.fillRect(0, this.temp, 512, this.drawHeigth);
this.ctx.fillRect(0, 448 - this.temp - this.drawHeigth , 512, this.drawHeigth);
}
}else{
if(this.temp >= 0){
this.ctx.clearRect(0, this.temp , 512, this.drawHeigth);
this.ctx.clearRect(0, 448 - this.temp - this.drawHeigth, 512, this.drawHeigth);
}else{
this.isReady = true;
}
}
this.temp += this.drawHeigth * this.dir;
};
};

351
js/tank.js Normal file
View File

@ -0,0 +1,351 @@
/**
* 坦克基类
* @returns
*/
var Tank = function(){
this.x = 0;
this.y = 0;
this.size = 32;//坦克的大小
this.dir = UP;//方向0上 1下 2左3
this.speed = 1;//坦克的速度
this.frame = 0;//控制敌方坦克切换方向的时间
this.hit = false; //是否碰到墙或者坦克
this.isAI = false; //是否自动
this.isShooting = false;//子弹是否在运行中
this.bullet = null;//子弹
this.shootRate = 0.6;//射击的概率
this.isDestroyed = false;
this.tempX = 0;
this.tempY = 0;
this.move = function(){
//如果是AI坦克在一定时间或者碰撞之后切换方法
if(this.isAI && emenyStopTime > 0 ){
return;
}
this.tempX = this.x;
this.tempY = this.y;
if(this.isAI){
this.frame ++;
if(this.frame % 100 == 0 || this.hit){
this.dir = parseInt(Math.random()*4);//随机一个方向
this.hit = false;
this.frame = 0;
}
}
if(this.dir == UP){
this.tempY -= this.speed;
}else if(this.dir == DOWN){
this.tempY += this.speed;
}else if(this.dir == RIGHT){
this.tempX += this.speed;
}else if(this.dir == LEFT){
this.tempX -= this.speed;
}
this.isHit();
if(!this.hit){
this.x = this.tempX;
this.y = this.tempY;
}
};
/**
* 碰撞检测
*/
this.isHit = function(){
//临界检测
if(this.dir == LEFT){
if(this.x <= map.offsetX){
this.x = map.offsetX;
this.hit = true;
}
}else if(this.dir == RIGHT){
if(this.x >= map.offsetX + map.mapWidth - this.size){
this.x = map.offsetX + map.mapWidth - this.size;
this.hit = true;
}
}else if(this.dir == UP ){
if(this.y <= map.offsetY){
this.y = map.offsetY;
this.hit = true;
}
}else if(this.dir == DOWN){
if(this.y >= map.offsetY + map.mapHeight - this.size){
this.y = map.offsetY + map.mapHeight - this.size;
this.hit = true;
}
}
if(!this.hit){
//地图检测
if(tankMapCollision(this,map)){
this.hit = true;
}
}
//坦克检测
/*if(enemyArray != null && enemyArray.length >0){
var enemySize = enemyArray.length;
for(var i=0;i<enemySize;i++){
if(enemyArray[i] != this && CheckIntersect(enemyArray[i],this,0)){
this.hit = true;
break;
}
}
}*/
};
/**
* 是否被击中
*/
this.isShot = function(){
};
/**
* 射击
*/
this.shoot = function(type){
if(this.isAI && emenyStopTime > 0 ){
return;
}
if(this.isShooting){
return ;
}else{
var tempX = this.x;
var tempY = this.y;
this.bullet = new Bullet(this.ctx,this,type,this.dir);
if(this.dir == UP){
tempX = this.x + parseInt(this.size/2) - parseInt(this.bullet.size/2);
tempY = this.y - this.bullet.size;
}else if(this.dir == DOWN){
tempX = this.x + parseInt(this.size/2) - parseInt(this.bullet.size/2);
tempY = this.y + this.size;
}else if(this.dir == LEFT){
tempX = this.x - this.bullet.size;
tempY = this.y + parseInt(this.size/2) - parseInt(this.bullet.size/2);
}else if(this.dir == RIGHT){
tempX = this.x + this.size;
tempY = this.y + parseInt(this.size/2) - parseInt(this.bullet.size/2);
}
this.bullet.x = tempX;
this.bullet.y = tempY;
if(!this.isAI){
ATTACK_AUDIO.play();
}
this.bullet.draw();
//将子弹加入的子弹数组中
bulletArray.push(this.bullet);
this.isShooting = true;
}
};
/**
* 坦克被击毁
*/
this.distroy = function(){
this.isDestroyed = true;
crackArray.push(new CrackAnimation(CRACK_TYPE_TANK,this.ctx,this));
TANK_DESTROY_AUDIO.play();
};
};
/**
* 菜单选择坦克
* @returns
*/
var SelectTank = function(){
this.ys = [250, 281];//两个Y坐标分别对应1p和2p
this.x = 140;
this.size = 27;
};
SelectTank.prototype = new Tank();
/**
* 玩家坦克
* @param context 画坦克的画布
* @returns
*/
var PlayTank = function(context){
this.ctx = context;
this.lives = 3;//生命值
this.isProtected = true;//是否受保护
this.protectedTime = 500;//保护时间
this.offsetX = 0;//坦克2与坦克1的距离
this.speed = 2;//坦克的速度
this.draw = function(){
this.hit = false;
this.ctx.drawImage(RESOURCE_IMAGE,POS["player"][0]+this.offsetX+this.dir*this.size,POS["player"][1],this.size,this.size,this.x,this.y,this.size,this.size);
if(this.isProtected){
var temp = parseInt((500-this.protectedTime)/5)%2;
this.ctx.drawImage(RESOURCE_IMAGE,POS["protected"][0],POS["protected"][1]+32*temp,32, 32,this.x,this.y,32, 32);
this.protectedTime--;
if(this.protectedTime == 0){
this.isProtected = false;
}
}
};
this.distroy = function(){
this.isDestroyed = true;
crackArray.push(new CrackAnimation(CRACK_TYPE_TANK,this.ctx,this));
PLAYER_DESTROY_AUDIO.play();
};
this.renascenc = function(player){
this.lives -- ;
this.dir = UP;
this.isProtected = true;
this.protectedTime = 500;
this.isDestroyed = false;
var temp= 0 ;
if(player == 1){
temp = 129;
}else{
temp = 256;
}
this.x = temp + map.offsetX;
this.y = 385 + map.offsetY;
};
};
PlayTank.prototype = new Tank();
/**
* 敌方坦克1
* @param context 画坦克的画布
* @returns
*/
var EnemyOne = function(context){
this.ctx = context;
this.isAppear = false;
this.times = 0;
this.lives = 1;
this.isAI = true;
this.speed = 1.5;
this.draw = function(){
this.times ++;
if(!this.isAppear){
var temp = parseInt(this.times/5)%7;
this.ctx.drawImage(RESOURCE_IMAGE,POS["enemyBefore"][0]+temp*32,POS["enemyBefore"][1],32,32,this.x,this.y,32,32);
if(this.times == 34){
this.isAppear = true;
this.times = 0;
this.shoot(2);
}
}else{
this.ctx.drawImage(RESOURCE_IMAGE,POS["enemy1"][0]+this.dir*this.size,POS["enemy1"][1],32,32,this.x,this.y,32,32);
//以一定的概率射击
if(this.times %50 ==0){
var ra = Math.random();
if(ra < this.shootRate){
this.shoot(2);
}
this.times = 0;
}
this.move();
}
};
};
EnemyOne.prototype = new Tank();
/**
* 敌方坦克2
* @param context 画坦克的画布
* @returns
*/
var EnemyTwo = function(context){
this.ctx = context;
this.isAppear = false;
this.times = 0;
this.lives = 2;
this.isAI = true;
this.speed = 1;
this.draw = function(){
this.times ++;
if(!this.isAppear){
var temp = parseInt(this.times/5)%7;
this.ctx.drawImage(RESOURCE_IMAGE,POS["enemyBefore"][0]+temp*32,POS["enemyBefore"][1],32,32,this.x,this.y,32,32);
if(this.times == 35){
this.isAppear = true;
this.times = 0;
this.shoot(2);
}
}else{
this.ctx.drawImage(RESOURCE_IMAGE,POS["enemy2"][0]+this.dir*this.size,POS["enemy2"][1],32,32,this.x,this.y,32,32);
//以一定的概率射击
if(this.times %50 ==0){
var ra = Math.random();
if(ra < this.shootRate){
this.shoot(2);
}
this.times = 0;
}
this.move();
}
};
};
EnemyTwo.prototype = new Tank();
/**
* 敌方坦克3
* @param context 画坦克的画布
* @returns
*/
var EnemyThree = function(context){
this.ctx = context;
this.isAppear = false;
this.times = 0;
this.lives = 3;
this.isAI = true;
this.speed = 0.5;
this.draw = function(){
this.times ++;
if(!this.isAppear){
var temp = parseInt(this.times/5)%7;
this.ctx.drawImage(RESOURCE_IMAGE,POS["enemyBefore"][0]+temp*32,POS["enemyBefore"][1],32,32,this.x,this.y,32,32);
if(this.times == 35){
this.isAppear = true;
this.times = 0;
this.shoot(2);
}
}else{
this.ctx.drawImage(RESOURCE_IMAGE,POS["enemy3"][0]+this.dir*this.size+(3-this.lives)*this.size*4,POS["enemy3"][1],32,32,this.x,this.y,32,32);
//以一定的概率射击
if(this.times %50 ==0){
var ra = Math.random();
if(ra < this.shootRate){
this.shoot(2);
}
this.times = 0;
}
this.move();
}
};
};
EnemyThree.prototype = new Tank();