boolean isPaintShot = true;
int a = 0, b = 0 , c = 0;
int [] directs = new int [10];
static //敌人坦克集合
Vector
int enSize = 3; //敌人坦克初始数量
int enSizes = 5; //敌人坦克画面总数量
int hintEnemyTanks = 0;//击中敌人坦克数量
public void showInfo(Graphics g ){//画提示信息
//画出提出坦克
this.drawTank(80, 330, g, 0, 1);
this.drawTank(160, 330, g, 0, 0);
g.setColor(Color.BLACK);
g.drawString(Recoder.getEnNum() + "", 105, 350);
g.drawString(Recoder.getMyLife() + "", 185, 350);
//画出成绩
g.setColor(Color.BLACK);
Font f = new Font("宋体", Font.BOLD, 15);
g.setFont(f);
g.drawString("你的总成绩:", 400, 20);
this.drawTank(410, 30, g, 0, 1);
g.drawString((20 - Recoder.getEnNum()) + "", 435, 50);
}
public void paint(Graphics g){
super.paint(g);
g.fillRect(0, 0, 400, 300);
this.showInfo(g);//画出提示信息
//自己坦克
if(hero.isLive == true){
this.drawTank(hero.getX(), hero.getY(), g, hero.direct, hero.type);
}else{
if(Recoder.getMyLife() > 0){
hero = new Hero(30, 270 ,0,0,10 , true);
hero.isLive = true;
}
}
//画出敌人坦克
for(int i = 0; i
EnemyTask et = ets.get(i);
if(!et.isLive){
ets.remove(i);
if(Recoder.getEnNum() >0){
this.drawTank(50, 0, g, 1, 1);
ets.add(et);
//et.isLive = true;
Thread t = new Thread(et);
t.start();
}
// if(Recoder.getEnNum() > 0){
// et.isLive = true;
// }
}
if(et.isLive){
this.drawTank(et.getX(), et.getY(),
g, et.direct, et.type);
System.out.println("et.ss.size()"+et.ss.size());
for(int j = 0; j < et.ss.size(); j++){//敌人坦克子弹
s = et.ss.get(j);
if(s.isLive){
if(isPaintShot){
g.fill3DRect(s.x, s.y, 5, 10, false);
}
}else{
et.ss.remove(j);
}
}
}
// if(!et.isLive){
// ets.remove(i);
// }
}
//画出子弹
for(int i = 0; i< hero.ss.size(); i++){
if(hero.ss.get(i)!= null && hero.ss.get(i).isLive == true){
g.fill3DRect(hero.ss.get(i).x, hero.ss.get(i).y, 5, 10, false);
}
if(hero.ss.get(i).isLive == false){
hero.ss.remove(hero.ss.get(i));
}
}
}
// public void hintTank2(shot s , Hero et){
// switch (et.direct) {
// case 0:
// case 1:
// if(s.x < et.x + 20 && s.x > et.x
// && s.y < et.y + 30 && s.y > et.y){
// s.isLive = false;
// et.isLive = false;
// }
// //break;
// case 2:
// case 3:
// if(s.x < et.x + 30 && s.x > et.x
// && s.y < et.y + 20 && s.y > et.y){
// s.isLive = false;
// et.isLive = false;
// }
// //break;
//
//// default:
//// break;
// }
//
// }
public boolean hintTank(shot s , Tank et){
boolean b = false;
switch (et.direct) {
case 0:
case 1:
if(s.x < et.x + 20 && s.x > et.x
&& s.y < et.y + 30 && s.y > et.y){
s.isLive = false;
et.isLive = false;
b = true;
}
break;
case 2:
case 3:
if(s.x < et.x + 30 && s.x > et.x
&& s.y < et.y + 20 && s.y > et.y){
s.isLive = false;
et.isLive = false;
b = true;
}
break;
// default:
// break;
}
return b;
}
public void drawTank (int x , int y , Graphics g , int direct , int type){
switch(type){//坦克类型
case 0:
g.setColor(Color.RED);
break;
case 1:
g.setColor(Color.BLUE);
break;
}
switch (direct) {
case 0://向上
g.fill3DRect(x, y, 5, 30, false );
g.fill3DRect(x + 15, y, 5, 30, false );
g.fill3DRect(x + 5, y + 5, 10, 20, false );
g.fillOval(x + 5, y + 10, 10, 10);
g.drawLine(x + 10, y,x + 10, y + 15);
break;
case 1://向下
g.fill3DRect(x, y, 5, 30, false );
g.fill3DRect(x + 15, y, 5, 30, false );
g.fill3DRect(x + 5, y + 5, 10, 20, false );
g.fillOval(x + 5, y + 10, 10, 10);
g.drawLine(x + 10, y + 15,x + 10,y + 30 );
break;
case 2://向左
g.fill3DRect(x, y, 30, 5, false );
g.fill3DRect(x , y + 15, 30, 5, false );
g.fill3DRect(x + 5, y + 5, 20, 10, false );
g.fillOval(x + 10, y + 5, 10, 10);
g.drawLine(x , y +