文档库 最新最全的文档下载
当前位置:文档库 › 坦克大战java源代码审批稿

坦克大战java源代码审批稿

坦克大战java源代码审批稿
坦克大战java源代码审批稿

坦克大战j a v a源代码 YKK standardization office【 YKK5AB- YKK08- YKK2C- YKK18】

有些图片路径会出错要注意package ;

import 坦克类

class Tank

{

int x=0;

int y=0;

int color=0;

int speed=1;

int direct=0;

boolean isLive=true;

public Tank(int x,int y)

{

=x;

=y;

}

public int getX() {

return x;

}

public void setX(int x) {

= x;

}

public int getY() {

return y;

}

public void setY(int y) {

= y;

}

public int getDirect() {

return direct;

}

public void setDirect(int direct) {

= direct;

}

public int getColor() {

return color;

}

public void setColor(int color) {

= color;

}

}

;

import .*;

import .*;

import .*;

public class MyTankGame4 extends JFrame implements ActionListener{ MyPanel mp=null;

MyStartPanel msp=null;

quals("New Game"))

{

(msp);

mp=new MyPanel();

Thread mt=new Thread(mp);

();

(mp);

(mp);

(true);

}

}

}

etImage"/.jpg"));

etImage"/"));

image2=().getImage"/"));

image3=().getImage"/"));

}

//控制坦克移动

public void keyPressed(KeyEvent arg0) {

// TODO Auto-generated method stub

if()==

{

}else if()== {

}else if()== {

}else if()== {

}else if()== {

=0;

=0;

}

//发射子弹(连发5枚子弹)

if {

if()==

{

(),(),());

}

}

//控制坦克不能跑出边界

if if if if

//面板重绘

();

}

public void keyReleased(KeyEvent arg0) {

// TODO Auto-generated method stub

}

public void keyTyped(KeyEvent arg0) {

// TODO Auto-generated method stub

}

public void run() {

while(true)

{

try {

(50);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

();

}

//不停地调用敌人是否打中自己坦克函数

for(int i=0;i<();i++)

{

et=(i);

for(int j=0;j< {

Shot enshot=

if==true&&==true)

{

(enshot, hero);

}

}

}

//不停地调用是否打中敌人坦克函数

for(int i=0;i< {

Shot s=

if(s!=null&&==true)

{

for(int j=0;j<();j++)

{

EnemyTank et=(j);

if(et!=null&&==true)

{

(s, et);

}

}

}

}

//面板重绘

();

}

}

}

相关文档