怎样把我们的格式wps复制表格格式不变到子弹上

把其他网页的文字复制到自己网页中,格式要怎么修改,才能跟我们自己打上去的效果一样,可以随意编辑_百度知道电视剧中开枪是怎么弄的??是真子弹真枪??我可看到有弹壳驳出._百度知道消失的子弹好看吗?详细点 ,不要网上复制黏贴,谢谢!!_百度知道坦克大战游戏 全部代码,W向上运动S向下,A向左,D向右运动 J发射子弹。。两个java文件,分别为MyTankGame3.java和Members.java文件,复制黏贴到myeclipse上就可以/*
* 功能:坦克大战游戏的4.0版本,
* 1画出坦克
* 2我的坦克可以上下左右移动
* 3,可以发射子弹,子弹可以连发(最多连发5颗)
* 4,当我的坦克击中敌人坦克时,敌人坦克就消失(爆炸的效果)
* 5,我被击中后显示爆炸效果
* 6,防止敌人坦克重叠运动
* 6.1决定把判断是否碰撞的函数写到EnemyTank里面去
* 7,可以分关
* 7.1做一个开始的panel,它是一个空的
* 7.2闪烁效果
* 8可以暂停继续游戏
* 8.1当用户点击暂停时,子弹的速度和坦克的速度设为0,并让坦克的方向不发生变化
* 9可以记录玩家的成绩
* 9.1 用文件流(单机版的游戏一般都是用文件流保存,大型网络游戏才会用数据库)
* 9.2单写一个记录类,记录玩家及坦克的信息
* 9.3 先完成保存共击毁了多少敌人坦克
* 10java如何操作声音文件
*/第一个JAVA文件:
package com.test1;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.ActionE
import java.awt.event.ActionL
import java.awt.event.KeyE
import java.awt.event.KeyL
public class MyTankGame3 extends JFrame implements ActionListener {
MyPanel mp =
// 定义一个开始的面板
MyStartPanel msp =
// 做出我需要的菜单
JMenuBar jmb =
// 开始游戏
JMenu jm1 =
JMenuItem jmi1 =
JMenuItem jmi2 =
JMenuItem jmi3 =
JMenuItem jmi4 =
public static void main(String[] args) {
// TODO Auto-generated method stub
MyTankGame3 demo = new MyTankGame3();
public MyTankGame3() {
// // mp=new MyPanel();
// // this.add(mp);
// Thread t=new Thread(mp);
// t.start();
// this.addKeyListener(mp);
// this.setLocation(350,100);
// 创建菜单及菜单选项
jmb = new JMenuBar();
jm1 = new JMenu(&游戏(G)&);
jm1.setMnemonic('G');
jmi1 = new JMenuItem(&开始新游戏(N)&);
jmi2 = new JMenuItem(&退出游戏(E)&);
jmi3 = new JMenuItem(&存盘退出游戏(C)&);
jmi4 = new JMenuItem(&继续上局游戏(S)&);
jmi4.addActionListener(this);
jmi4.setActionCommand(&conGame&);
jmi3.addActionListener(this);
jmi3.setActionCommand(&save&);
jmi2.addActionListener(this);
jmi2.setActionCommand(&exit&);
jmi2.setMnemonic('E');
jm1.add(jmi1);
jm1.add(jmi2);
jm1.add(jmi3);
jm1.add(jmi4);
jmb.add(jm1);
// 对jmi1响应
jmi1.addActionListener(this);
jmi1.setActionCommand(&new game&);
msp = new MyStartPanel();
Thread t = new Thread(msp);
t.start();
this.setJMenuBar(jmb);
this.add(msp);
this.setTitle(&霍磊 我的坦克&);
this.setSize(600, 500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
// 对用户不同的点击做出处理
if (e.getActionCommand().equals(&new game&)) {
// 创建战场面板
mp = new MyPanel(&newGame&);
Thread t = new Thread(mp);
t.start();
// 先删除旧的面板
this.remove(msp);
this.add(mp);
this.addKeyListener(mp);
this.setVisible(true);
} else if (e.getActionCommand().equals(&exit&)) {
// 用户点击了退出系统菜单
// 保存击毁敌人数量
Recorder.keepRecording();
System.exit(0);
// 对存盘退出做处理
else if (e.getActionCommand().equals(&save&)) {
Recorder rd = new Recorder();
rd.setEts(mp.ets);
// 保存击毁敌人的数量和敌人的坐标
rd.keepRecAndEnemyTank();
System.exit(0);
} else if (e.getActionCommand().equals(&conGame&)) {
// 创建战场面板
mp = new MyPanel(&Con&);
// mp.flag=&Con&;
// mp.nodes=new Recorder().getNodesAndEnNums();
Thread t = new Thread(mp);
t.start();
// 先删除旧的面板
this.remove(msp);
this.add(mp);
this.addKeyListener(mp);
this.setVisible(true);
class MyStartPanel extends JPanel implements Runnable {
int times = 0;
public void paint(Graphics g) {
super.paint(g);
g.fillRect(0, 0, 400, 300);
// 提示信息
if (times % 2 == 0) {
// 开关信息的字体
g.setColor(Color.white);
Font myFont = new Font(&华文新魏&, Font.BOLD, 30);
g.setFont(myFont);
g.drawString(&Stage:
1&, 150, 150);
public void run() {
// TODO Auto-generated method stub
while (true) {
Thread.sleep(500);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
this.repaint();
// 我的面板
class MyPanel extends JPanel implements KeyListener, Runnable {
// 定义一个我的坦克,把创建的工作都放在构造函数里做
Hero hero =
// 判断是续上局还是新游戏
// String flag=&newGame&;
// 定义敌人坦克组
Vector&EnemyTank& ets = new Vector&EnemyTank&();
Vector&Node& nodes = new Vector&Node&();
Vector&Bomb& bombs = new Vector&Bomb&();
int enSize = 10;
Image image1 =
Image image2 =
Image image3 =
Image image4 =
// 重新paint
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.black);
g.fillRect(0, 0, 400, 300);
// 画出提示信息
this.showInfo(g);
if (hero.isLive) {
this.drawTank(hero.getX(), hero.getY(), g, hero.getDirect(), 1);
// 从ss中取出每颗子弹
for (int i = 0; i & hero.ss.size(); i++) {
Shot myShot = hero.ss.get(i);
if (myShot != null && myShot.isLive == true) {
g.draw3DRect(myShot.x, myShot.y, 1, 1, false);
if (myShot.isLive == false) {
// 从ss中删除该子弹
hero.ss.remove(myShot);
// 画出炸弹
for (int i = 0; i & bombs.size(); i++) {
// 取出炸弹
Bomb b = bombs.get(i);
// System.out.println(b.x+&
// System.out.println(b.life);
if (b.life & 7) {
g.drawImage(image1, b.x, b.y, 30, 30, this);
} else if (b.life & 6) {
g.drawImage(image2, b.x, b.y, 30, 30, this);
} else if (b.life & 3) {
g.drawImage(image3, b.x, b.y, 30, 30, this);
g.drawImage(image4, b.x, b.y, 30, 30, this);
// 让b的生命值减小
b.lifeDown();
// 如何炸弹生命值为0,就是把该炸弹重bombs向量去
if (b.life == 0) {
bombs.remove(b);
// 画出敌人坦克
for (int i = 0; i & ets.size(); i++) {
EnemyTank et = ets.get(i);
if (et.isLive) {
this.drawTank(et.getX(), et.getY(), g, et.getDirect(), 0);
// 再画出敌人坦克
for (int j = 0; j & et.ss.size(); j++) {
// 取出子弹
Shot enemyShot = et.ss.get(j);
if (enemyShot.isLive) {
g.draw3DRect(enemyShot.x, enemyShot.y, 1, 1, false);
// 如果敌人坦克死亡就从vector去掉
et.ss.remove(enemyShot);
public MyPanel(String flag) {
// 回复记录
Recorder.getRecording();
hero = new Hero(100, 100);
// 初始化敌人的坦克
if (flag.equals(&newGame&)) {
for (int i = 0; i & enS i++) {
// 创建一辆敌人坦克对象
EnemyTank et = new EnemyTank((i + 1) * 30, 0);
et.setColor(0);
et.setDirect(2);
// 将MyPanel上敌人坦克向量交给该敌人坦克
et.setEts(ets);
// 启动敌人坦克
Thread t = new Thread(et);
t.start();
// 给敌人坦克添加一个子弹
Shot s = new Shot(et.x + 10, et.y + 30, 2);
// 加入给敌人坦克
et.ss.add(s);
Thread t2 = new Thread(s);
t2.start();
ets.add(et);
nodes = new Recorder().getNodesAndEnNums();
for (int i = 0; i & nodes.size(); i++) { // 创建一辆敌人坦克对象
Node node = nodes.get(i);
EnemyTank et = new EnemyTank(node.x, node.y);
et.setColor(0);
et.setDirect(node.direct);
// 将MyPanel上敌人坦克向量交给该敌人坦克
et.setEts(ets);
// 启动敌人坦克
Thread t = new Thread(et);
t.start();
// 给敌人坦克添加一个子弹
Shot s = new Shot(et.x + 10, et.y + 30, 2);
// 加入给敌人坦克
et.ss.add(s);
Thread t2 = new Thread(s);
t2.start();
ets.add(et);
// 初始化图片
image1 = Toolkit.getDefaultToolkit().getImage(
Panel.class.getResource(&/bomb_1.jpg&));
image2 = Toolkit.getDefaultToolkit().getImage(
Panel.class.getResource(&/bomb_2.jpg&));
image3 = Toolkit.getDefaultToolkit().getImage(
Panel.class.getResource(&/bomb_3.jpg&));
image4 = Toolkit.getDefaultToolkit().getImage(
Panel.class.getResource(&/bomb_4.jpg&));
Bomb b1 = new Bomb(1, 1);
bombs.add(b1);
// 画出提示信息
public void showInfo(Graphics g) {
// 画出提示信息坦克(该坦克不参与战斗)
this.drawTank(80, 330, g, 0, 0);
g.setColor(Color.black);
g.drawString(Recorder.getEnNum() + & &, 110, 350);
this.drawTank(130, 330, g, 0, 1);
g.setColor(Color.black);
g.drawString(Recorder.getMyLife() + & &, 160, 350);
// 画出玩家的总成绩
g.setColor(Color.black);
Font f = new Font(&宋体&, Font.BOLD, 20);
g.setFont(f);
g.drawString(&老人家总成绩&, 420, 30);
this.drawTank(420, 60, g, 0, 0);
g.setColor(Color.black);
g.drawString(Recorder.getAllEnNum() + & &, 460, 80);
// 判断敌人的子弹是否击中我方坦克
public void hitMe() {
// 取出每一个敌人的坦克
for (int i = 0; i & this.ets.size(); i++) {
// 取出坦克
EnemyTank et = ets.get(i);
// 取出每一刻子弹
for (int j = 0; j & et.ss.size(); j++) {
Shot enemyShot = et.ss.get(j);
if (hero.isLive) {
if (this.hitTank(enemyShot, hero)) {
// 判断我的子弹是否击中敌人的坦克
public void hitEnemyTank() {
// 判断是否击中敌人坦克
for (int i = 0; i & hero.ss.size(); i++) {
// 取出子弹
Shot myShot = hero.ss.get(i);
// 判断子弹是否有效
if (myShot.isLive) {
// 取出每个坦克与之判断
for (int j = 0; j & ets.size(); j++) {
EnemyTank et = ets.get(j);
if (et.isLive) {
if (this.hitTank(myShot, et)) {
// 减少敌人数量
Recorder.reduceEnNum();
// 增加我的记录
Recorder.addEnNumRec();
// 写一个函数判断子弹是否集中坦克
public boolean hitTank(Shot s, Tank et) {
boolean b2 =
// 判断坦克方向
switch (et.direct) {
if (s.x & et.x && s.x & et.x + 20 && s.y & et.y && s.y & et.y + 30) {
// 子弹死亡
// 敌人坦克死亡
s.isLive =
et.isLive =
// 创建一颗炸弹,放入vector
Bomb b = new Bomb(et.x, et.y);
bombs.add(b);
if (s.x & et.x && s.x & et.x + 30 && s.y & et.y && s.y & et.y + 20) {
// 子弹死亡
// 敌人坦克死亡
s.isLive =
et.isLive =
// 创建一颗炸弹,放入vector
Bomb b = new Bomb(et.x, et.y);
bombs.add(b);
return b2;
// 画出坦克的函数
public void drawTank(int x, int y, Graphics g, int direct, int type) {
// 判断我的还是敌人的坦克
switch (type) {
g.setColor(Color.cyan);
g.setColor(Color.yellow);
switch (direct) {
case 0:// 炮筒向上
// 画出我的坦克
// g.setColor(Color.cyan);
g.fill3DRect(x, y, 5, 30, false);
g.fill3DRect(x + 15, y, 5, 30, false);
// g.setColor(Color.red);
g.fill3DRect(x + 5, y + 5, 10, 20, false);
g.fillOval(x + 5, y + 10, 10, 10);
g.setColor(Color.PINK);
g.drawLine(x, y + 5, x + 5, y + 5);
g.drawLine(x, y + 10, x + 5, y + 10);
g.drawLine(x, y + 15, x + 5, y + 15);
g.drawLine(x, y + 20, x + 5, y + 20);
g.drawLine(x, y + 25, x + 5, y + 25);
g.drawLine(x + 15, y + 5, x + 20, y + 5);
g.drawLine(x + 15, y + 10, x + 20, y + 10);
g.drawLine(x + 15, y + 15, x + 20, y + 15);
g.drawLine(x + 15, y + 20, x + 20, y + 20);
g.drawLine(x + 15, y + 25, x + 20, y + 25);
g.setColor(Color.white);
g.drawLine(x + 10, y + 15, x + 10, y - 8);
case 1:// 炮筒向右
// g.setColor(Color.cyan);
g.fill3DRect(x, y, 30, 5, false);
g.fill3DRect(x, y + 15, 30, 5, false);
// g.setColor(Color.red);
g.fill3DRect(x + 5, y + 5, 20, 10, false);
g.fillOval(x + 10, y + 5, 10, 10);
g.setColor(Color.PINK);
g.drawLine(x + 5, y, x + 5, y + 5);
g.drawLine(x + 10, y, x + 10, y + 5);
g.drawLine(x + 15, y, x + 15, y + 5);
g.drawLine(x + 20, y, x + 20, y + 5);
g.drawLine(x + 25, y, x + 25, y + 5);
g.drawLine(x + 5, y + 15, x + 5, y + 19);
g.drawLine(x + 10, y + 15, x + 10, y + 19);
g.drawLine(x + 15, y + 15, x + 15, y + 19);
g.drawLine(x + 20, y + 15, x + 20, y + 19);
g.drawLine(x + 25, y + 15, x + 25, y + 19);
g.setColor(Color.white);
g.drawLine(x + 15, y + 10, x + 30, y + 10);
// g.setColor(Color.cyan);
g.fill3DRect(x, y, 5, 30, false);
g.fill3DRect(x + 15, y, 5, 30, false);
// g.setColor(Color.red);
g.fill3DRect(x + 5, y + 5, 10, 20, false);
g.fillOval(x + 5, y + 10, 10, 10);
g.setColor(Color.PINK);
g.drawLine(x, y + 5, x + 5, y + 5);
g.drawLine(x, y + 10, x + 5, y + 10);
g.drawLine(x, y + 15, x + 5, y + 15);
g.drawLine(x, y + 20, x + 5, y + 20);
g.drawLine(x, y + 25, x + 5, y + 25);
g.drawLine(x + 15, y + 5, x + 20, y + 5);
g.drawLine(x + 15, y + 10, x + 20, y + 10);
g.drawLine(x + 15, y + 15, x + 20, y + 15);
g.drawLine(x + 15, y + 20, x + 20, y + 20);
g.drawLine(x + 15, y + 25, x + 20, y + 25);
g.setColor(Color.white);
g.drawLine(x + 10, y + 15, x + 10, y + 30);
// g.setColor(Color.cyan);
g.fill3DRect(x, y, 30, 5, false);
g.fill3DRect(x, y + 15, 30, 5, false);
// g.setColor(Color.red);
g.fill3DRect(x + 5, y + 5, 20, 10, false);
g.fillOval(x + 10, y + 5, 10, 10);
g.setColor(Color.PINK);
g.drawLine(x + 5, y, x + 5, y + 5);
g.drawLine(x + 10, y, x + 10, y + 5);
g.drawLine(x + 15, y, x + 15, y + 5);
g.drawLine(x + 20, y, x + 20, y + 5);
g.drawLine(x + 25, y, x + 25, y + 5);
g.drawLine(x + 5, y + 15, x + 5, y + 19);
g.drawLine(x + 10, y + 15, x + 10, y + 19);
g.drawLine(x + 15, y + 15, x + 15, y + 19);
g.drawLine(x + 20, y + 15, x + 20, y + 19);
g.drawLine(x + 25, y + 15, x + 25, y + 19);
g.setColor(Color.white);
g.drawLine(x + 15, y + 10, x, y + 10);
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
// 键按下处理 a向左 w向上 s向下 d向右
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
if (e.getKeyCode() == KeyEvent.VK_W) {
// 设置我的坦克的方向
this.hero.setDirect(0);
hero.moveUp();
} else if (e.getKeyCode() == KeyEvent.VK_D) {
hero.setDirect(1);
hero.moveRight();
} else if (e.getKeyCode() == KeyEvent.VK_S) {
hero.setDirect(2);
hero.moveDown();
} else if (e.getKeyCode() == KeyEvent.VK_A) {
hero.setDirect(3);
hero.moveLeft();
if (e.getKeyCode() == KeyEvent.VK_J) {// 开火
if (this.hero.ss.size() &= 15) {
this.hero.shotEnemy();
this.repaint();
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
public void run() {
// TODO Auto-generated method stub
while (true) {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
this.hitEnemyTank();
this.hitMe();
this.repaint();
第二个JAVA文件:
package com.test1;
import java.util.V
import java.io.*;
class Node {
public Node(int x, int y, int direct) {
this.direct =
// 记录类,同时也可以保存玩家的设置
class Recorder {
// 记录每一关有多少敌人
private static int enNum = 10;
// 设置我有多少可以用的人
private static int myLife = 3;
// 记录总共消灭多少敌人
private static int allEnNum = 0;
// 从文件中恢复记录点
static Vector&Node& nodes = new Vector&Node&();
private static FileWriter fw =
private static FileReader fr =
private static BufferedReader br =
private static BufferedWriter bw =
public Vector&EnemyTank& getEts() {
public void setEts(Vector&EnemyTank& ets1) {
this.ets = ets1;
private Vector&EnemyTank& ets = new Vector&EnemyTank&();
// 完成读取任务
public Vector&Node& getNodesAndEnNums() {
fr = new FileReader(&d:/myRecording.txt&);
br = new BufferedReader(fr);
String n = &&;
// 先读取第一行S
n = br.readLine();
allEnNum = Integer.parseInt(n);
while ((n = br.readLine()) != null) {
String[] xyz = n.split(& &);
Node node = new Node(Integer.parseInt(xyz[0]),
Integer.parseInt(xyz[1]), Integer.parseInt(xyz[2]));
nodes.add(node);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
br.close();
fr.close();
} catch ( e) {
// TODO Auto-generated catch block
e.printStackTrace();
// 保存击毁敌人坦克数量和坦克坐标,方向
public void keepRecAndEnemyTank() {
// 创建文件流
fw = new FileWriter(&d:/myRecording.txt&);
bw = new BufferedWriter(fw);
bw.write(allEnNum + &\r\n&);
// 保存当前活的敌人坦克坐标和方向
for (int i = 0; i & ets.size(); i++) {
EnemyTank et = ets.get(i);
// 取出第一个坦克
if (et.isLive) {
// 活的就保存
String recode = et.x + & & + et.y + & & + et.
// 写入到文件里
bw.write(recode + &\r\n&);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally { // 记住:后开先关闭,先开后关闭
bw.close();
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// 从文件中读取记录
public static void getRecording() {
fr = new FileReader(&d:/myRecording.txt&);
br = new BufferedReader(fr);
String n = br.readLine();
allEnNum = Integer.parseInt(n);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
br.close();
fr.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// 把玩家击毁敌人坦克保存到文件中
public static void keepRecording() {
// 创建文件流
fw = new FileWriter(&d:/myRecording.txt&);
bw = new BufferedWriter(fw);
bw.write(allEnNum + &\r\n&);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally { // 记住:后开先关闭,先开后关闭
bw.close();
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
public static int getAllEnNum() {
return allEnN
public static void setAllEnNum(int allEnNum) {
Recorder.allEnNum = allEnN
public static int getEnNum() {
return enN
public static void setEnNum(int enNum) {
Recorder.enNum = enN
public static int getMyLife() {
return myL
public static void setMyLife(int myLife) {
Recorder.myLife = myL
// 减少敌人数
public static void reduceEnNum() {
public static void addEnNumRec() {
allEnNum++;
class Bomb {
// 定义炸弹坐标
// 炸弹生命
int life = 9;
boolean isLive =
public Bomb(int x, int y) {
public void lifeDown() {
if (life & 0) {
this.isLive =
class Shot implements Runnable {
int speed = 6;
boolean isLive =
public Shot(int x, int y, int direct) {
this.direct =
public void run() {
while (true) {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
switch (direct) {
// System.out.println(&子弹坐标x=&+x+& y=&+y);
// 子弹何时死亡???
if (x & 0 || x & 400 || y & 0 || y & 300) {
this.isLive =
class Tank {
// 表示坦克的横坐标,和纵坐标
int x = 0;
int y = 0;
boolean isLive =
// 坦克的颜色
public int getColor() {
public void setColor(int color) {
this.color =
// 坦克的速度
int speed = 2;
public int getSpeed() {
public void setSpeed(int speed) {
this.speed =
// 坦克方向
// 0表示向上 1表示向右 2表示向下 3表示向左
int direct = 0;
public int getDirect() {
public void setDirect(int direct) {
this.direct =
public int getX() {
public void setX(int x) {
public int getY() {
public void setY(int y) {
public Tank(int x, int y) {
// 敌人的坦克
class EnemyTank extends Tank implements Runnable {
int times = 0;
// 定义一个向量,可以访问到Mypanel上的所有敌人
Vector&EnemyTank& ets = new Vector&EnemyTank&();
// 定义一个向量,可以存放敌人子弹
Vector&Shot& ss = new Vector&Shot&();
// 敌人添加子弹应该在刚刚创建坦克和坦克子弹死亡后
public EnemyTank(int x, int y) {
super(x, y);
// TODO Auto-generated constructor stub
// 得到MypANEL的敌人坦克向量
public void setEts(Vector&EnemyTank& vv) {
this.ets =
// 判断是否碰到敌人坦克
public boolean isTouchOtherEnemy() {
boolean b =
switch (this.direct) {
// 我的坦克向上,取出所有敌人坦克
for (int i = 0; i & ets.size(); i++) {
// 取出一个坦克
EnemyTank et = ets.get(i);
// 如果不是自己
if (et != this) {// 如果敌人坦克向上或向下
if (et.direct == 0 || et.direct == 2) {
if (this.x &= et.x && this.x &= et.x + 20
&& this.y &= et.y && this.y &= et.y + 30) {
if (this.x + 20 &= et.x && this.x + 20 &= et.x + 20
&& this.y + 20 &= et.y
&& this.y + 20 &= et.y + 30) {
if (et.direct == 1 || et.direct == 3) {
if (this.x &= et.x && this.x &= et.x + 30
&& this.y &= et.y && this.y &= et.y + 20) {
if (this.x + 20 &= et.x && this.x + 20 &= et.x + 30
&& this.y &= et.y && this.y &= et.y + 20) {
// 坦克向右
// 我的坦克向上,取出所有敌人坦克
for (int i = 0; i & ets.size(); i++) {
// 取出一个坦克
EnemyTank et = ets.get(i);
// 如果不是自己
if (et != this) {// 如果敌人坦克向上或向下
if (et.direct == 0 || et.direct == 2) {
if (this.x + 30 &= et.x && this.x + 30 &= et.x + 20
&& this.y &= et.y && this.y &= et.y + 30) {
if (this.x + 30 &= et.x && this.x + 30 &= et.x + 20
&& this.y + 20 &= et.y
&& this.y + 20 &= et.y + 30) {
if (et.direct == 1 || et.direct == 3) {
if (this.x + 30 &= et.x && this.x + 30 &= et.x + 30
&& this.y &= et.y && this.y &= et.y + 20) {
if (this.x + 30 &= et.x && this.x + 30 &= et.x + 30
&& this.y + 20 &= et.y
&& this.y + 20 &= et.y + 20) {
// 坦克向下
// 我的坦克向上,取出所有敌人坦克
for (int i = 0; i & ets.size(); i++) {
// 取出一个坦克
EnemyTank et = ets.get(i);
// 如果不是自己
if (et != this) {// 如果敌人坦克向上或向下
if (et.direct == 0 || et.direct == 2) {
if (this.x &= et.x && this.x &= et.x + 20
&& this.y + 30 &= et.y
&& this.y + 30 &= et.y + 30) {
if (this.x + 20 &= et.x && this.x + 20 &= et.x + 20
&& this.y + 30 &= et.y
&& this.y + 30 &= et.y + 30) {
if (et.direct == 1 || et.direct == 3) {
if (this.x &= et.x && this.x &= et.x + 30
&& this.y + 30 &= et.y
&& this.y + 30 &= et.y + 20) {
if (this.x + 20 &= et.x && this.x + 20 &= et.x + 30
&& this.y + 30 &= et.y
&& this.y + 30 &= et.y + 20) {
// 坦克向左
// 我的坦克向上,取出所有敌人坦克
for (int i = 0; i & ets.size(); i++) {
// 取出一个坦克
EnemyTank et = ets.get(i);
// 如果不是自己
if (et != this) {// 如果敌人坦克向上或向下
if (et.direct == 0 || et.direct == 2) {
if (this.x &= et.x && this.x &= et.x + 20
&& this.y &= et.y && this.y &= et.y + 30) {
if (this.x &= et.x && this.x &= et.x + 20
&& this.y &= et.y && this.y &= et.y + 30) {
if (et.direct == 1 || et.direct == 3) {
if (this.x &= et.x && this.x &= et.x + 30
&& this.y + 20 &= et.y
&& this.y + 20 &= et.y + 20) {
if (this.x &= et.x && this.x &= et.x + 30
&& this.y + 20 &= et.y
&& this.y + 20 &= et.y + 20) {
public void run() {
while (true) {
switch (this.direct) {
for (int i = 0; i & 30; i++) {
if (y & 0 && !this.isTouchOtherEnemy()) {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
for (int i = 0; i & 30; i++) {
if (x & 350 && !this.isTouchOtherEnemy()) {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
for (int i = 0; i & 30; i++) {
if (y & 230 && !this.isTouchOtherEnemy()) {
}// else System.out.println(&x的值是&+y);
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
for (int i = 0; i & 30; i++) {
if (x & 0 && !this.isTouchOtherEnemy()) {
Thread.sleep(50);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if (times % 2 == 0) {
if (isLive) {
if (ss.size() & 9) {
// 没有子弹了
switch (direct) {
s = new Shot(x + 10, y, 0);
ss.add(s);
s = new Shot(x + 30, y + 10, 1);
ss.add(s);
s = new Shot(x + 10, y + 30, 2);
ss.add(s);
s = new Shot(x, y + 10, 3);
ss.add(s);
// 启动子弹线程
Thread t = new Thread(s);
t.start();
// 让坦克随机产生一个方向
this.direct = (int) (Math.random() * 4);
// this.direct=Hero.this.
// 判断敌人坦克是否死亡
if (this.isLive == false) {// 让坦克退出线程
// 判断子弹是否没有
// 我的坦克
class Hero extends Tank {
Vector&Shot& ss = new Vector&Shot&();
// 父类的构造函数来初始化子类的变量
public Hero(int x, int y) {
super(x, y);
public void shotEnemy() {
switch (this.direct) {
s = new Shot(x + 10, y - 8, 0);
ss.add(s);
s = new Shot(x + 30, y + 10, 1);
ss.add(s);
s = new Shot(x + 10, y + 30, 2);
ss.add(s);
s = new Shot(x, y + 10, 3);
ss.add(s);
// 启动子弹线程
Thread t = new Thread(s);
t.start();
public void moveUp() {
public void moveRight() {
public void moveDown() {
public void moveLeft() {
随机推荐程序问答结果
如对文章有任何疑问请提交到,或者您对内容不满意,请您反馈给我们发贴求解。
,机器学习分类整理更新日期:: 21:47:22
如需转载,请注明文章出处和来源网址:
本文WWW.DOC100.NET DOC100.NET版权所有。}

我要回帖

更多关于 快手个人介绍格式复制 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信