坦克大战 70版文档格式.docx

上传人:b****5 文档编号:17378733 上传时间:2022-12-01 格式:DOCX 页数:17 大小:17.63KB
下载 相关 举报
坦克大战 70版文档格式.docx_第1页
第1页 / 共17页
坦克大战 70版文档格式.docx_第2页
第2页 / 共17页
坦克大战 70版文档格式.docx_第3页
第3页 / 共17页
坦克大战 70版文档格式.docx_第4页
第4页 / 共17页
坦克大战 70版文档格式.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

坦克大战 70版文档格式.docx

《坦克大战 70版文档格式.docx》由会员分享,可在线阅读,更多相关《坦克大战 70版文档格式.docx(17页珍藏版)》请在冰豆网上搜索。

坦克大战 70版文档格式.docx

Vector<

Emeny>

ets=newVector<

();

Bomb>

bombs=newVector<

intensize=6;

Imageimage1=null;

Imageimage2=null;

Imageimage3=null;

publicMypanel()

hero=newHero(20,200);

for(inti=0;

i<

ensize;

i++)

{

Emenyet=newEmeny((i+1)*50,0);

et.setColor(0);

et.setDriect

(2);

Threadt=newThread(et);

t.start();

Shots=newShot(et.x+10,et.y+30,2);

et.ss.add(s);

Threadt2=newThread(s);

t2.start();

ets.add(et);

}

image1=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("

/bomb_1.gif"

));

image2=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("

/bomb_2.gif"

image3=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("

/bomb_3.gif"

publicvoidpaint(Graphicsg)

super.paint(g);

g.fillRect(0,0,400,300);

this.drawTank(hero.getX(),hero.getY(),g,this.hero.driect,1);

hero.ss.size();

{Shotmyshot=hero.ss.get(i);

if(myshot!

=null&

&

myshot.islive==true)

g.draw3DRect(myshot.x,myshot.y,1,1,false);

if(myshot.islive==false)

hero.ss.remove(myshot);

bombs.size();

Bombb=bombs.get(i);

if(b.life>

6)

{

g.drawImage(image1,b.x,b.y,30,30,this);

}elseif(b.life>

3)

g.drawImage(image2,b.x,b.y,30,30,this);

}else

g.drawImage(image3,b.x,b.y,30,30,this);

}

b.lifedown();

if(b.life==0)

bombs.remove(b);

ets.size();

Emenyet=ets.get(i);

if(et.islive)

this.drawTank(et.getX(),et.getY(),g,et.getDriect(),0);

for(intj=0;

j<

et.ss.size();

j++)

Shotenemyshot=et.ss.get(j);

if(enemyshot.islive)

{

g.draw3DRect(enemyshot.x,enemyshot.y,1,1,false);

}

publicvoidhittank(Shots,Emenyet)

switch(et.driect)

case0:

case2:

if(s.x>

et.x&

s.x<

et.x+20&

s.y>

et.y&

s.y<

et.y+30)

s.islive=false;

et.islive=false;

Bombb=newBomb(et.x,et.y);

bombs.add(b);

case1:

case3:

et.x+30&

et.y+20)

publicvoiddrawTank(intx,inty,Graphicsg,intdriect,inttype)

switch(type)

g.setColor(Color.blue);

break;

g.setColor(Color.CYAN);

switch(driect)

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);

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+15,y+10,x+30,y+10);

break;

g.drawLine(x+10,y+15,x+10,y+30);

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+15,y+10,x,y+10);

@Override

publicvoidkeyPressed(KeyEventarg0){

if(arg0.getKeyCode()==KeyEvent.VK_W)

this.hero.setDriect(0);

this.hero.moveup();

}elseif(arg0.getKeyCode()==KeyEvent.VK_D)

this.hero.setDriect

(1);

this.hero.moveright();

}elseif(arg0.getKeyCode()==KeyEvent.VK_S)

this.hero.setDriect

(2);

this.hero.movedown();

}elseif(arg0.getKeyCode()==KeyEvent.VK_A)

this.hero.setDriect(3);

this.hero.moveleft();

if(arg0.getKeyCode()==KeyEvent.VK_J)

{if(this.hero.ss.size()<

5)

this.hero.shotemeny();

this.repaint();

publicvoidkeyReleased(KeyEventarg0){

publicvoidkeyTyped(KeyEventarg0){

publicvoidrun(){

while(true)

try

Thread.sleep(100);

}catch(Exceptione){

e.printStackTrace();

//判断是否击中

//quchutanke

Shotmyshot=hero.ss.get(i);

if(myshot.islive)

for(intj=0;

Emenyet=ets.get(i);

if(et.islive)

{

this.hittank(myshot,et);

}

classShotimplementsRunnable

intx;

inty;

intdriect;

intspeed=5;

booleanislive=true;

publicShot(intx,inty,intdriect)

this.x=x;

this.y=y;

this.driect=driect;

{try

Thread.sleep(50);

}catch(Exceptione)

switch(driect){

case0:

y-=speed;

break;

case1:

x+=speed;

case2:

y+=speed;

case3:

x-=speed;

if(x<

0||x>

400||y<

0||y>

300)

this.islive=false;

classTank

intcolor;

publicintgetColor(){

returncolor;

publicvoidsetColor(intcolor){

this.color=color;

publicintgetSpeed(){

returnspeed;

publicvoidsetSpeed(intspeed){

this.speed=speed;

intspeed=6;

intdriect=0;

publicintgetDriect(){

returndriect;

publicvoidsetDriect(intdriect){

this.driect=driect;

intx=0;

publicintgetX(){

returnx;

publicvoidsetX(intx){

this.x=x;

publicintgetY(){

returny;

publicvoidsetY(inty){

this.y=y;

inty=0;

publicTank(intx,inty)

classEmenyextendsTankimplementsRunnable

{

Shot>

ss=newVector<

publicEmeny(intx,inty)

super(x,y);

switch(this.driect)

for(inti=0;

20;

{try{

Thread.sleep(50);

}catch(Exceptione)

e.printStackTrace();

if(y>

0)

}}

15;

if(x<

360)

18;

if(y<

240)

10;

}if(x>

//suijishudriect

this.driect=(int)(Math.random()*4);

if(this.islive==false)

classHeroextendsTank

//Shots=null;

Shots=null;

publicHero(intx,inty)

publicvoidshotemeny()

switch(this.driect)

s=newShot(x+10,y,0);

ss.add(s);

s=newShot(x+30,y+10,1);

s=newShot(x+10,y+30,2);

s=newShot(x,y+10,3);

Threadt=newThread(s);

publicvoidmoveup()

y-=speed;

publicvoidmovedown()

y+=speed;

publicvoidmoveleft()

x-=speed;

publicvoidmoveright()

x+=speed;

classBomb

intlife=9;

publicBomb(intx,inty)

publicvoidlifedown()

if(life>

life--;

}else

this.islive=false;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 社交礼仪

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1