坦克大战java版Word文档格式.docx

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

坦克大战java版Word文档格式.docx

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

坦克大战java版Word文档格式.docx

JMenujm=null;

JMenuItemjmi1,jmi2;

inti=1;

booleanover=false;

publicstaticvoidmain(String[]args){

//TODOAuto-generatedmethodstub

Mytankmytank=newMytank();

Threadt1=newThread(mytank);

t1.start();

}

publicMytank()

{

jmb=newJMenuBar();

jm=newJMenu("

游戏(G)"

);

jm.setMnemonic('

G'

jmi1=newJMenuItem("

开始游戏"

jmi2=newJMenuItem("

退出"

jmi1.setActionCommand("

newgame"

jmi2.setActionCommand("

exit"

jmi1.addActionListener(this);

jmi2.addActionListener(this);

jm.add(jmi1);

jm.add(jmi2);

jmb.add(jm);

msp=newmystartpanel(i);

Threadt=newThread(msp);

t.start();

this.add(msp);

this.setJMenuBar(jmb);

this.setSize(400,320);

this.setUndecorated(true);

this.setResizable(false);

this.setIconImage((newImageIcon("

image/tankicon.jpg"

)).getImage());

this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);

this.setTitle("

Tank3.0"

this.setVisible(true);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

publicvoidactionPerformed(ActionEvente){

if(e.getActionCommand().equals("

))

{

mp=newmypanel();

Threadt=newThread(mp);

t.start();

this.remove(msp);

msp.islive=false;

this.add(mp);

jmi1.setEnabled(false);

this.addKeyListener(mp);

this.setVisible(true);

}elseif(e.getActionCommand().equals("

System.exit(0);

}

publicvoidrun(){

while(true)

try{

Thread.sleep(500);

}catch(InterruptedExceptione){

//TODOAuto-generatedcatchblock

e.printStackTrace();

}

if(msp.islive==false&

&

mp.ets.size()==0)

{

if(i==9)

{

gameovergameover=newgameover("

YES!

"

Threadt=newThread(gameover);

t.start();

this.remove(mp);

this.add(gameover);

this.setVisible(true);

break;

}

i++;

msp=newmystartpanel(i);

Threadt=newThread(msp);

t.start();

jmi1.setEnabled(true);

this.remove(mp);

this.add(msp);

this.setVisible(true);

if(!

msp.islive&

!

mp.hero.islive)

gameovergameover=newgameover("

GameOver!

Threadt=newThread(gameover);

this.add(gameover);

break;

}

classmystartpanelextendsJPanelimplementsRunnable

{

inttime=0;

booleanislive=true;

inti;

publicmystartpanel(inti)

this.i=i;

shuliang.setEnnum(i*3);

publicvoidpaint(Graphicsg)

super.paint(g);

g.fillRect(0,0,390,265);

if(time%2==0)

{

g.setColor(Color.yellow);

Fontmyfont=newFont("

隶书"

Font.BOLD,30);

g.setFont(myfont);

g.drawString("

stage:

"

+i,120,140);

Thread.sleep(1000);

time++;

islive)break;

this.repaint();

classgameoverextendsJPanelimplementsRunnable

Stringname=null;

publicgameover(Stringname)

this.name=name;

g.setColor(Color.black);

g.drawString(name,130,150);

if(time==5)System.exit(0);

classmypanelextendsJPanelimplementsKeyListener,Runnable

Herohero=null;

Vector<

enemytank>

ets=newVector<

();

intensize=shuliang.getEnnum();

Imageimage1=null;

Imageimage2=null;

Imageimage3=null;

bonb>

bonbs=newVector<

publicmypanel()

hero=newHero(200,230);

for(inti=0;

i<

ensize;

i++)

{

intx=(i+1)*50;

if(x>

300)x=x%300;

enemytanket=newenemytank(x,0);

shots=newshot(et.x+10,et.y+30,2);

Threadt2=newThread(s);

t2.start();

et.ss.add(

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

当前位置:首页 > IT计算机 > 互联网

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

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