坦克大战java代码具体解释_java建议坦克大战代码(1)

package t1;

public class BaoZha {

int x, y;

int shengcunqi = 9;

boolean shengming = true;

public BaoZha(int x, int y) {

super();

this.x = x;

this.y = y;

}

public void scqjs() {

if (shengcunqi > 0) {

shengcunqi--;

} else {

this.shengming = false;

}

}

}

package t1;

import java.util.Vector;

import t1.DiTank;

class DiTank extends Tank implements Runnable

{

int time=0;

Vector dzd=new Vector();

Vector dtk;

public Vector getDtk() {

return dtk;

}

public void setDtk(Vector dtk) {

this.dtk = dtk;

}

public DiTank(int x, int y) {

super(x, y);

}

public boolean hxpz() {

boolean b=false;

switch (fangxiang){

case 0:

for(int i=0;i

{

DiTank dt=dtk.get(i);

if(dt!=this)

{

if(dt.fangxiang==0dt.fangxiang==2)

{

if(this.x>=dt.x && this.x<=dt.x+20 && this.y>=dt.y && this.y<=dt.y+30)

{

return true;

}

if(this.x+20>=dt.x && this.x+20<=dt.x+20 && this.y>=dt.y && this.y<=dt.y+30)

{

return true;

}

}

if(dt.fangxiang==3dt.fangxiang==1)

{

if(this.x>=dt.x && this.x<=dt.x+30 && this.y>=dt.y && this.y<=dt.y+20)

{

return true;

}

if(this.x+20>=dt.x && this.x+20<=dt.x+30 && this.y>=dt.y && this.y<=dt.y+20)

{

return true;

}

}

}

}

break;

case 1:

for(int i=0;i

{

DiTank dt=dtk.get(i);

if(dt!=this)

{

if(dt.fangxiang==0dt.fangxiang==2)

{

if(this.x>=dt.x&&this.x<=dt.x+20&&this.y>=dt.y&&this.y<=dt.y+30)

{

return true;

}

//下一点

if(this.x>=dt.x&&this.x<=dt.x+20&&this.y+20>=dt.y&&this.y+20<=dt.y+30)

{

return true;

}

}

if(dt.fangxiang==3dt.fangxiang==1)

{

if(this.x>=dt.x&&this.x<=dt.x+30&&this.y>=dt.y&&this.y<=dt.y+20)

{

return true;

}

if(this.x>=dt.x&&this.x<=dt.x+30&&this.y+20>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值