日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java大战坦克代码_坦克大战java源代码.doc

發(fā)布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java大战坦克代码_坦克大战java源代码.doc 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

坦克大戰(zhàn)java源代碼

有些圖片路徑會出錯 要注意

package com.tankgame;

import java.util.Vector;

//坦克類

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)

{

this.x=x;

this.y=y;

}

public int getX() {

return x;

}

public void setX(int x) {

this.x = x;

}

public int getY() {

return y;

}

public void setY(int y) {

this.y = y;

}

public int getDirect() {

return direct;

}

public void setDirect(int direct) {

this.direct = direct;

}

public int getColor() {

return color;

}

public void setColor(int color) {

this.color = color;

}

}

//我的坦克

class Hero extends Tank

{

Shot shot=null;

Vector shotm=new Vector();

public Hero(int x,int y)

{

super(x,y);

this.color=5;

}

//坦克具有一個打擊敵人的方法

public void shotenemy(int x,int y,int direct)

{

switch(direct)

{

case 0:

shot=new Shot(this.x+10,this.y,0);

shotm.add(shot);

break;

case 1:

shot=new Shot(this.x+30,this.y+10,1);

shotm.add(shot);

break;

case 2:

shot=new Shot(this.x+10,this.y+30,2);

shotm.add(shot);

break;

case 3:

shot=new Shot(this.x,this.y+10,3);

shotm.add(shot);

break;

}

Thread th=new Thread(shot);

th.start();

}

//調(diào)整速度

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

{

Vectorensh=new Vector();

Vectorets=new Vector();

public EnemyTank(int x, int y)

{

super(x, y);

this.setColor(2);

this.setDirect(2);

}

//獲取MPanel上的敵人坦克

public void setets(Vector vv)

{

this.ets=vv;

}

//判斷敵人的坦克是否碰撞

public boolean isTouch()

{

boolean b=false;

EnemyTank et=null;

switch(direct)

{

case 0:

for(int i=0;i

{

et=ets.get(i);

if(et!=this)

{

if(et.direct==0||et.direct==2)

{

if(this.x>=et.x&&thi

總結(jié)

以上是生活随笔為你收集整理的java大战坦克代码_坦克大战java源代码.doc的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。