下载此文档

坦克大战java源代码.docx


文档分类:IT计算机 | 页数:约15页 举报非法文档有奖
1/15
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/15 下载此文档
文档列表 文档介绍
有 些 图 片 路 径 会 出 错
package nkgame;
〃坦克类
class Tank
{
int x=0;
int y=0;
int color=0;
int speed=1;
int direct=0;
boolea n isLive=true;
public Tan k(i nt x,i nt y)
{
=x;
=y;
}
public in t getX() {
return x;
}
public void setX(i nt x) {
= x;
}
public in t getY() {
return y;
}
public void setY(i nt y) {
= y;
}
public int getDirect() {
return direct;
}
public void setDirect(i nt direct) { = direct;
} public in t getColor() { retur n color;
}
public void setColor(i nt color) { = color;
}
}
〃我的坦克
class Hero exte nds Tank
{
Shot shot=null;
Vector<Shot> shotm=new Vector<Shot>(); public Hero(i nt x,i nt y)
super(x,y);
=5;
}
//坦克具有一个打击敌人的方法
public void shotenemy(int x,int y,int direct)
{ switch(direct)
{
case 0:
shot=new Shot(+10,,0); (shot);
break; case 1:
shot=new Shot(+30,+10,1); (shot);
break; case 2:
shot=new Shot(+10,+30,2); (shot);
break; case 3:
shot=new Shot(,+10,3); (shot);
break;
}
Thread th=new Thread(shot); ();
}
//调整速度
public void moveup()
{
y-=speed;
}
public void moveright()
{
x+=speed;
}
public void movedown()
{
y+=speed;
}
public void moveleft()
{ x-=speed;
}
}
//敌人的坦克
class EnemyTank extends Tank implements Runnable
Vector<Shot>ensh=new Vector<Shot>();
Vector<EnemyTank>ets=new Vector<EnemyTank>();
public EnemyTank(int x, int y)
{
super(x, y);
(2);
(2);
}
//获取 MPanel 上的敌人坦克
public void setets(Vector<EnemyTank> vv)
{
=vv;
}
//判断敌人的坦克是否碰撞
public boolean isTouch()
{
boolean b=false;
EnemyTank et=null; switch(direct)
{
case 0:
for(int i=0;i<();i++)
{ et=(i); if(et!=this)
{
if(==0||==2)
{ if(>=&&<=+20&&<=+30&&>) {
return true;
} if(+20>=&&+20<=+20&&<=+30&&>)

坦克大战java源代码 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数15
  • 收藏数0 收藏
  • 顶次数0
  • 上传人薄荷牛奶
  • 文件大小15 KB
  • 时间2020-12-14