java游戏合集打包下载(java小程序小游戏代码

一)坦克大战

import java.awt.*;

导入Java.awt.event.*;

import java.util.List;

import javax.swing.JOptionPane;

publicclasstankclientextendsframeimplementsactionlistener {

//*

私有状态长时间服务版本=1l;

publicstaticfinalintfram _ width=800; //

publicstaticfinalintfram _ length=600;

publicstaticbooleanprintable=true;

MenuBar jmb=null;

Menu jm1=null,jm2=null,jm3=null,jm4=null;

MenuItem jmi1=null,jmi2=null,jmi3=null,jmi4=null,jmi5=null,

jmi6=null,jmi7=null,jmi8=null,jmi9=null;

image屏幕图像=null;

tankhometank=newtank (300,560,true,Direction.STOP,this ); //

List theRiver=new ArrayList (;

列表tanks=new ArrayList (;

List bombTanks=new ArrayList (;

列表蓝牙=new ArrayList (;

列表树=new ArrayList (;

列表home wall=new ArrayList (;

列表other wall=new ArrayList (;

列表金属墙=new ArrayList (;

公共语音更新(图形) {

sreen image=this.create image (fram _ width,Fram_length );

graphics GPS=screen image.get graphics (;

Color c=gps.getColor (;

GS.setcolor(color.gray );

GS.fillrect (0,0,Fram_width,Fram_length );

GPS.setcolor(c;

frampaint(GPS;

g .图形图像(屏幕图像,0,0,空);

}

publicvoidframpaint (图形) {

Color c=g.getColor (;

g.setcolor(color.green );

Font f1=g.getFont (;

g.setfont(newfont(‘timesRoman ‘,Font.BOLD,20 );

g.drawString (最高得分: )、200、70 );

g.setfont(newfont(‘timesRoman ‘,Font.ITALIC,30 );

g.Drawstring(‘Tanks.size ),400,70 );

g.setfont(newfont(‘timesRoman ‘,Font.BOLD,20 );

g.drawString (得分: )、500、70 );

g.setfont(newfont(‘timesRoman ‘,Font.ITALIC,30 );

g.Drawstring(‘hometank.getlife ),650,70 );

g .设置字体(f1;

if(tanks.size(==0home.islive ) ) homeTank.isLive ) }

Font f=g.getFont (;

g.setfont(newfont(‘timesRoman ‘,Font.BOLD,60 );

this.otherWall.clear (;

g.drawString (、310、300 );

g .设置字体(f;

}

if(hometank.islive(==false ) )。

Font f=g.getFont (;

g.setfont(newfont(‘timesRoman ‘,Font.BOLD,40 ) );

tanks.clear (;

bullets.clear (;

g .设置字体(f;

}

g.setcolor(c;

for(intI=0; i theRiver.size (; I ) {

riverr=theriver.get(I;

r.draw(g );

}

for(intI=0; i theRiver.size (; I ) {

riverr=theriver.get(I;

hometank.Collideriver(r;

r.draw(g );

}

home.draw(g;

家庭坦克. draw (g;

家庭水槽. eat (blood;

for(intI=0; i bullets.size (; I ) {

bulletsm=bullets.get(I;

m.hittanks(tanks );

m.hittank (家用水箱);

知识共享签名-允许非商业使用4.0国际协议,转载引文应遵循相同协议。

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注