当前位置: 首页 > news >正文

dns设置 看国外网站wordpress是干什么的

dns设置 看国外网站,wordpress是干什么的,win怎么没有wordpress,嘉兴招聘网JAVA坦克大战游戏v3 素材 bomb_3.gif bomb_2.gif bomb_1.gif 项目结构 游戏演示 MyTankGame3.java /*** 功能:坦克游戏的5.0[]* 1.画出坦克.* 2.我的坦克可以上下左右移动* 3.可以发射子弹,子弹连发(最多5)* 4.当我的坦克击中敌人坦克时#xff0c;敌人就消失(爆炸的效…JAVA坦克大战游戏v3 素材 bomb_3.gif bomb_2.gif bomb_1.gif 项目结构 游戏演示 MyTankGame3.java /*** 功能:坦克游戏的5.0[]* 1.画出坦克.* 2.我的坦克可以上下左右移动* 3.可以发射子弹,子弹连发(最多5)* 4.当我的坦克击中敌人坦克时敌人就消失(爆炸的效果)* 5.我被击中后显示爆炸效果* 6.防止敌人坦克重叠运动(*)* 6.1决定把判断是否碰撞的函数写到EnemyTank类* 7.可以分关(*)* 7.1做一个开始的Panle,它是一个空的* 7.2闪烁效果* 8.可以在玩游戏的时候暂停和继续** 8.1当用户点击暂停时子弹的速度和坦克速度设为0,并让坦克的方向不要变化* 9.可以记录玩家的成绩** 9.1用文件流.* 9.2单写一个记录类完成对玩家记录* 9.3先完成保存共击毁了多少辆敌人坦克的功能.* 9.4存盘退出游戏,可以记录当时的敌人坦克坐标并可以恢复* 10.java如何操作声音文件** 10.1对声音文件的操作*/ package org.example; import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; import java.io.*; public class MyTankGame3 extends JFrame implements ActionListener {MyPanel mpnull; //定义一个游戏面板MyStartPanel mspnull; //定义一个开始面板JMenuBar jmbnull; //菜单条JMenu jm1null; //菜单JMenuItem jmilnull; //菜单选项1 开始新游戏JMenuItem jmi2null; //菜单选项2 退出游戏JMenuItem jmi3null; //菜单选项3 存盘退出游戏JMenuItem jmi4null; //菜单选项4 继续上局游戏//主函数public static void main(String[] args) {// TODO Auto-generated method stub//定义一个MyTankGame3 的对象mtg并创建它MyTankGame3 mtgnew MyTankGame3();}//未完//构造函数public MyTankGame3(){//创建菜单及菜单选项jmbnew JMenuBar();jm1 new JMenu(游戏(G));//设置快捷方式jm1.setMnemonic(G);jmil 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(saveExit);jmi2.addActionListener(this);jmi2.setActionCommand(exit);jmi2.setMnemonic(E);//对jmil相应jmil.addActionListener(this);jmil.setActionCommand(newgame);jm1.add(jmil);jm1.add(jmi2);jm1.add(jmi3);jm1.add(jmi4);jmb.add(jm1);mspnew MyStartPanel();Thread tnew Thread(msp);t.start();this.setJMenuBar(jmb);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(msp);this.setSize(600, 500);this.setVisible(true);}//未完public void actionPerformed(ActionEvent arg0) {// TODO Auto-generated method stub//对用户不同的点击作出不同的处理if(arg0.getActionCommand().equals(newgame)){mpnew MyPanel(newGame);//创建战场面板Thread tnew Thread(mp);//启动mp线程t.start();this.remove(msp); //先删除旧的开始面板this.add(mp);this.addKeyListener(mp);//注册监听this.setVisible(true); //显示,刷新JFrame}else if(arg0.getActionCommand().equals(exit)){//用户点击了退出系统的菜单//保存击毁敌人数量.Recorder.keepRecording();System.exit(0);}//对存盘退出左处理else if(arg0.getActionCommand().equals(saveExit)){System.out.println(111);System.out.println(mp.ets.sizemp.ets.size());//工作Recorder rdnew Recorder();rd.setEts(mp.ets);//保存击毁敌人的数量和敌人的坐标rd.keepRecAndEnemyTank();//退出System.exit(0);}else if(arg0.getActionCommand().equals(conGame)){//创建战场面板mpnew MyPanel(con);//启动mp线程Thread tnew Thread(mp);t.start();//先删除旧的开始面板this.remove(msp);this.add(mp);//注册监听this.addKeyListener(mp);//显示,刷新JFramethis.setVisible(true);}} //MyTankGame3()构造函数完 }//class MyTankGame3完 //class MyStartPanel 打开游戏的第一个画面就是一个提示作用 class MyStartPanel extends JPanel implements Runnable {int times0; //设置时间public void paint(Graphics g){super.paint(g);g.fillRect(0, 0, 400, 300);//提示信息if(times%20) //每隔一秒闪动一次{g.setColor(Color.yellow);//开关信息的字体Font myFontnew Font(华文新魏,Font.BOLD,30);g.setFont(myFont);g.drawString(stage: 1, 150, 150);}}public void run() {// TODO Auto-generated method stubwhile(true){//休眠try{Thread.sleep(100);} catch (Exception e) {e.printStackTrace();// TODO: handle exception}times;this.repaint();//重画}} }//class MyStartPanel完 //class MyPanel,我的面板,游戏就在这个面板上运行 class MyPanel extends JPanel implements KeyListener,Runnable {//定义一个我的坦克Hero heronull;//定义敌人的坦克组VectorEnemyTank etsnew VectorEnemyTank();VectorNode nodesnew VectorNode();//定义炸弹集合VectorBomb bombsnew VectorBomb();int enSize3;//定义三张图片,三张图片才能组成一颗炸弹Image image1null;Image image2null;Image image3null; //class MyPanel未完//MyPanel()构造函数public MyPanel(String flag){//恢复记录Recorder.getRecoring();heronew Hero(100,100);if(flag.equals(newGame))//如果玩家点击的是开始新游戏{//初始化敌人的坦克for(int i0;ienSize;i){//创建一辆敌人的坦克对象EnemyTank etnew EnemyTank((i1)*50,0);et.setColor(0);//颜色设置为黄色et.setDirect(2);//方向设置为朝上//将MyPanel的敌人坦克向量交给该敌人坦克et.setEts(ets);//启动敌人的坦克Thread tnew Thread(et);t.start();//给敌人坦克添加一颗子弹Shot snew Shot(et.x10,et.y30,2);//加入给敌人坦克et.ss.add(s);Thread t2new Thread(s);t2.start();//加入ets.add(et);}}//判断完毕还有下一个判断//MyPanel()构造函数未完//玩游戏只有两种情况要么新游戏要么接着玩保存和退出不在这个地方做判断else{System.out.println(接着玩);nodesnew Recorder().getNodesAndEnNums();//初始化敌人的坦克for(int i0;inodes.size();i){Node nodenodes.get(i);//创建一辆敌人的坦克对象EnemyTank etnew EnemyTank(node.x,node.y);et.setColor(0);et.setDirect(node.direct);//将MyPanel的敌人坦克向量交给该敌人坦克et.setEts(ets);//启动敌人的坦克Thread tnew Thread(et);t.start();//给敌人坦克添加一颗子弹Shot snew Shot(et.x10,et.y30,2);//加入给敌人坦克et.ss.add(s);Thread t2new Thread(s);t2.start();//加入ets.add(et);}}//判断完毕//创建图片try {image1ImageIO.read(new File(images/O.png));image2ImageIO.read(new File(images/S.png));image3ImageIO.read(new File(images/T.png));} catch (Exception e) {e.printStackTrace();// TODO: handle exception}//播放开战声音AePlayWave apwnew AePlayWave(out/ring05.wav);apw.start();}//MyPanel()构造函数完//showInfo(Graphics g)函数画出提示信息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(), 165, 350);//画出玩家的总成绩g.setColor(Color.black);Font fnew 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 paint(Graphics g)函数整个游戏的前台public void paint(Graphics g){super.paint(g);g.fillRect(0, 0, 400, 300);//画出提示信息this.showInfo(g);//画出自己的坦克if(hero.isLive){this.drawTank(hero.getX(), hero.getY(), g, this.hero.direct, 1);}//从ss,中取出每颗子弹并画出for(int i0;ihero.ss.size();i){Shot myShothero.ss.get(i);//画出子弹,画出一颗子弹if(myShot!nullmyShot.isLivetrue){ // g.drawOval(myShot.x, myShot.y, 50, 50);g.draw3DRect(myShot.x, myShot.y, 1, 1,false);}if(myShot.isLivefalse){//从ss中删除掉该子弹hero.ss.remove(myShot);}}//画出炸弹for(int i0;ibombs.size();i){System.out.println(bombs.size()bombs.size());//取出炸弹Bomb bbombs.get(i);if(b.life6){g.drawImage(image1, b.x, b.y, 30, 30, this);}else if(b.life3){g.drawImage(image2, b.x, b.y, 30, 30, this);}else{g.drawImage(image3, b.x, b.y, 30, 30, this);}//让b的生命值减小b.lifeDown();//如果炸弹生命值为0,就把该炸弹重bombs向量去掉if(b.life0){bombs.remove(b);}}//画出敌人的坦克for(int i0;iets.size();i){EnemyTank etets.get(i);if(et.isLive){this.drawTank(et.getX(), et.getY(), g, et.getDirect(), 0);//再画出敌人的子弹//System.out.println(坦克子弹有:et.ss.size());for(int j0;jet.ss.size();j){//取出子弹Shot enemyShotet.ss.get(j);if(enemyShot.isLive){//System.out.println(第 i坦克的 j颗子弹xenemyShot.x);g.draw3DRect(enemyShot.x, enemyShot.y, 1, 1,false);}else{//如果敌人的坦克死亡就从Vector去掉et.ss.remove(enemyShot);}}}}}//paint(Graphics g)函数完 //class MyPanel未完//public void hitMe()函数敌人的坦克是否击中我public void hitMe(){//取出每一个敌人的坦克for(int i0;ithis.ets.size();i){//取出坦克EnemyTank etets.get(i);//取出每一颗子弹for(int j0;jet.ss.size();j){//取出坦克的子弹Shot enemyShotet.ss.get(j);if(hero.isLive){if(this.hitTank(enemyShot, hero)){}}}}}//判断我的子弹是否击中敌人的坦克public void hitEnemyTank(){//判断是否击中敌人的坦克for(int i0;ihero.ss.size();i){//取出子弹Shot myShothero.ss.get(i);//判断子弹是否有效if(myShot.isLive){//取出每个坦克与它判断for(int j0;jets.size();j){//取出坦克EnemyTank etets.get(j);if(et.isLive){if(this.hitTank(myShot, et)){//减少敌人数量Recorder.reduceEnNum();//增加我的记录Recorder.addEnNumRec();}}}}}}//写一个函数专门判断子弹是否击中敌人坦克public boolean hitTank(Shot s,Tank et){boolean b2false;//判断该坦克的方向switch(et.direct){//如果敌人坦克的方向是上或者是下case 0:case 2:if(s.xet.xs.xet.x20s.yet.ys.yet.y30){//击中//子弹死亡s.isLivefalse;//敌人坦克死亡et.isLivefalse;b2true;//创建一颗炸弹,放入VectorBomb bnew Bomb(et.x,et.y);//放入Vectorbombs.add(b);}break;case 1:case 3:if(s.xet.xs.xet.x30s.yet.ys.yet.y20){//击中//子弹死亡s.isLivefalse;//敌人坦克死亡et.isLivefalse;b2true;//创建一颗炸弹,放入VectorBomb bnew Bomb(et.x,et.y);//放入Vectorbombs.add(b);}}return b2;}//画出坦克的函数(扩展)public void drawTank(int x,int y,Graphics g,int direct,int type){//判断是什么类型的坦克switch(type){case 0:g.setColor(Color.cyan);break;case 1:g.setColor(Color.yellow);break;}//判断方向switch(direct){//向上case 0://画出我的坦克(到时再封装成一个函数)//1.画出左边的矩形g.fill3DRect(x, y, 5, 30,false);//2.画出右边矩形g.fill3DRect(x15,y , 5, 30,false);//3.画出中间矩形g.fill3DRect(x5,y5 , 10, 20,false);//4.画出圆形g.fillOval(x5, y10, 10, 10);//5.画出线g.drawLine(x10, y15, x10, y);break;case 1://炮筒向右//画出上面矩形g.fill3DRect(x, y, 30, 5,false);//画出下面的矩形g.fill3DRect(x, y15, 30, 5, false);//画出中间的矩形g.fill3DRect(x5, y5, 20, 10, false);//画出圆形g.fillOval(x10, y5, 10, 10);//画出线g.drawLine(x15, y10, x30, y10);break;case 2://向下//画出我的坦克(到时再封装成一个函数)//1.画出左边的矩形g.fill3DRect(x, y, 5, 30,false);//2.画出右边矩形g.fill3DRect(x15,y , 5, 30,false);//3.画出中间矩形g.fill3DRect(x5,y5 , 10, 20,false);//4.画出圆形g.fillOval(x5, y10, 10, 10);//5.画出线g.drawLine(x10, y15, x10, y30);break;case 3://向左//画出上面矩形g.fill3DRect(x, y, 30, 5,false);//画出下面的矩形g.fill3DRect(x, y15, 30, 5, false);//画出中间的矩形g.fill3DRect(x5, y5, 20, 10, false);//画出圆形g.fillOval(x10, y5, 10, 10);//画出线g.drawLine(x15, y10, x, y10);break;}}//键按下处理 a 表示向左 s 表示 下 w 表示向上 d表示右public void keyPressed(KeyEvent arg0) {// TODO Auto-generated method stubif(arg0.getKeyCode()KeyEvent.VK_W){//设置我的坦克的方向this.hero.setDirect(0);this.hero.moveUp();}else if(arg0.getKeyCode()KeyEvent.VK_D){//向右this.hero.setDirect(1);this.hero.moveRight();}else if(arg0.getKeyCode()KeyEvent.VK_S){//向下this.hero.setDirect(2);this.hero.moveDown();}else if(arg0.getKeyCode()KeyEvent.VK_A){//向左this.hero.setDirect(3);this.hero.moveLeft();}if(arg0.getKeyCode()KeyEvent.VK_J){//判断玩家是否按下j//开火//System.out.println(this.hero.ss.size()this.hero.ss.size());if(this.hero.ss.size()4){this.hero.shotEnemy();}}//必须重新绘制Panelthis.repaint();}public void keyReleased(KeyEvent arg0) {// TODO Auto-generated method stub}public void keyTyped(KeyEvent arg0) {// TODO Auto-generated method stub}//class MyPanel的线程函数public void run() {// TODO Auto-generated method stub//每隔100毫秒去重绘while(true){try {Thread.sleep(100);} catch (Exception e) {e.printStackTrace();// TODO: handle exception}this.hitEnemyTank();//函数判断敌人的子弹是否击中我this.hitMe();//重绘this.repaint();}} }//class MyPanel完 Members.java package org.example;import javax.sound.sampled.*; import java.io.*; import java.util.Vector; public class Members{}//播放声音的类 class AePlayWave extends Thread {private String filename;public AePlayWave(String wavfile) {filename wavfile;}public void run() {File soundFile new File(filename);AudioInputStream audioInputStream null;try {audioInputStream AudioSystem.getAudioInputStream(soundFile);} catch (Exception e1) {e1.printStackTrace();return;}AudioFormat format audioInputStream.getFormat();SourceDataLine auline null;DataLine.Info info new DataLine.Info(SourceDataLine.class, format);try {auline (SourceDataLine) AudioSystem.getLine(info);auline.open(format);} catch (Exception e) {e.printStackTrace();return;}auline.start();int nBytesRead 0;//这是缓冲byte[] abData new byte[512];try {while (nBytesRead ! -1) {nBytesRead audioInputStream.read(abData, 0, abData.length);if (nBytesRead 0)auline.write(abData, 0, nBytesRead);}} catch (IOException e) {e.printStackTrace();return;} finally {auline.drain();auline.close();}} }//class AePlayWave extends Thread完 class Node{int x;int y;int direct;public Node(int x,int y,int direct){this.xx;this.yy;this.directdirect;} } //记录类,同时也可以保存玩家的设置 class Recorder {//记录每关有多少敌人private static int enNum20;//设置我有多少可以用的人private static int myLife3;//记录总共消灭了多少敌人private static int allEnNum0;//从文件中恢复记录点static VectorNode nodesnew VectorNode();private static FileWriter fwnull;private static BufferedWriter bwnull;private static FileReader frnull;private static BufferedReader brnull;private VectorEnemyTank etsnew VectorEnemyTank();//public VectorNode getNodesAndEnNums()函数public VectorNode getNodesAndEnNums(){try {frnew FileReader(d:\\myRecording.txt);brnew BufferedReader(fr);String n;//先读取第一行nbr.readLine();allEnNumInteger.parseInt(n);while((nbr.readLine())!null){String []xyzn.split( );Node nodenew Node(Integer.parseInt(xyz[0]),Integer.parseInt(xyz[1]),Integer.parseInt(xyz[2]));nodes.add(node);}} catch (Exception e) {e.printStackTrace();// TODO: handle exception}finally{try {//后打开则先关闭br.close();fr.close();} catch (Exception e) {e.printStackTrace();// TODO: handle exception}}return nodes;}//保存击毁敌人的数量和敌人坦克坐标,方向public void keepRecAndEnemyTank(){try {//创建fwnew FileWriter(d:\\myRecording.txt);bwnew BufferedWriter(fw);bw.write(allEnNum\r\n);System.out.println(sizeets.size());//保存当前活的敌人坦克的坐标和方向for(int i0;iets.size();i){//取出第一个坦克EnemyTank etets.get(i);if(et.isLive){//活的就保存String recodeet.x et.y et.direct;//写入bw.write(recode\r\n);}}} catch (Exception e) {e.printStackTrace();// TODO: handle exception}finally{//关闭流try {//后开先关闭bw.close();fw.close();} catch (Exception e) {e.printStackTrace();// TODO: handle exception}}}//从文件中读取记录public static void getRecoring(){try {frnew FileReader(d:\\myRecording.txt);brnew BufferedReader(fr);String nbr.readLine();allEnNumInteger.parseInt(n);} catch (Exception e) {e.printStackTrace();// TODO: handle exception}finally{try {//后打开则先关闭br.close();fr.close();} catch (Exception e) {e.printStackTrace();// TODO: handle exception}}}//把玩家击毁敌人坦克数量保存到文件中public static void keepRecording(){try {//创建fwnew FileWriter(d:\\myRecording.txt);bwnew BufferedWriter(fw);bw.write(allEnNum\r\n);} catch (Exception e) {e.printStackTrace();// TODO: handle exception}finally{//关闭流try {//后开先关闭bw.close();fw.close();} catch (Exception e) {e.printStackTrace();// TODO: handle exception}}}public static int getEnNum() {return enNum;}public static void setEnNum(int enNum) {Recorder.enNum enNum;}public static int getMyLife() {return myLife;}public static void setMyLife(int myLife) {Recorder.myLife myLife;}//减少敌人数public static void reduceEnNum(){enNum--;}//消灭敌人public static void addEnNumRec(){allEnNum;}public static int getAllEnNum() {return allEnNum;}public static void setAllEnNum(int allEnNum) {Recorder.allEnNum allEnNum;}public VectorEnemyTank getEts() {return ets;}public void setEts(VectorEnemyTank ets1) {this.ets ets1;System.out.println(ok);} } //炸弹类 class Bomb{//定义炸弹的坐标int x,y;//炸弹的生命int life9;boolean isLivetrue;public Bomb(int x,int y){this.xx;this.yy;}//减少生命值public void lifeDown(){if(life0){life--;}else {this.isLive false;}} } //子弹类 class Shot implements Runnable {int x;int y;int direct;int speed1;//是否还活着boolean isLivetrue;public Shot(int x,int y,int direct){this.xx;this.yy;this.directdirect;}public void run() {while(true){try {Thread.sleep(50);} catch (Exception e) {// TODO: handle exception}switch(direct){case 0://上y-speed;break;case 1:xspeed;break;case 2:yspeed;break;case 3:x-speed;break;}// System.out.println(子弹坐标xx yy);//子弹何时死亡???//判断该子弹是否碰到边缘.if(x0||x400||y0||y300){this.isLivefalse;break;}}} } //坦克类 class Tank {//表示坦克的横坐标int x0;//坦克纵坐标int y0;//坦克方向//0表示上 1表示 右 2表示下 3表示左int direct0;int color;boolean isLivetrue;//坦克的速度int speed3;public Tank(int x,int y){this.xx;this.yy;}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 getSpeed() {return speed;}public void setSpeed(int speed) {this.speed speed;}public int getColor() {return color;}public void setColor(int color) {this.color color;} } //敌人的坦克,把敌人做成线程类 class EnemyTank extends Tank implements Runnable {int times0;//定义一个向量可以访问到MyPanel上所有敌人的坦克VectorEnemyTank etsnew VectorEnemyTank();//定义一个向量可以存放敌人的子弹VectorShot ssnew VectorShot();//敌人添加子弹应当在刚刚创建坦克和敌人的坦克子弹死亡后public EnemyTank(int x,int y){super(x,y);}//得到MyPanel的敌人坦克向量public void setEts(VectorEnemyTank vv){this.etsvv;}//判断是否碰到了别的敌人坦克public boolean isTouchOtherEnemy(){boolean bfalse;switch(this.direct){case 0://我的坦克向上//取出所有的敌人坦克for(int i0;iets.size();i){//取出第一个坦克EnemyTank etets.get(i);//如果不是自己if(et!this){//如果敌人的方向是向下或者向上if(et.direct0||et.direct2){//左点if(this.xet.xthis.xet.x20this.yet.ythis.yet.y30){return true;}if(this.x20et.xthis.x20et.x20this.yet.ythis.yet.y30){return true;}}if(et.direct3||et.direct1){if(this.xet.xthis.xet.x30this.yet.ythis.yet.y20){return true;}if(this.x20et.xthis.x20et.x30this.yet.ythis.yet.y20){return true;}}}}break;case 1://坦克向右//取出所有的敌人坦克for(int i0;iets.size();i){//取出第一个坦克EnemyTank etets.get(i);//如果不是自己if(et!this){//如果敌人的方向是向下或者向上if(et.direct0||et.direct2){//上点if(this.x30et.xthis.x30et.x20this.yet.ythis.yet.y30){return true;}//下点if(this.x30et.xthis.x30et.x20this.y20et.ythis.y20et.y30){return true;}}if(et.direct3||et.direct1){if(this.x30et.xthis.x30et.x30this.yet.ythis.yet.y20){return true;}if(this.x30et.xthis.x30et.x30this.y20et.ythis.y20et.y20){return true;}}}}break;case 2://坦克向下//取出所有的敌人坦克for(int i0;iets.size();i){//取出第一个坦克EnemyTank etets.get(i);//如果不是自己if(et!this){//如果敌人的方向是向下或者向上if(et.direct0||et.direct2){//我的左点if(this.xet.xthis.xet.x20this.y30et.ythis.y30et.y30){return true;}//我的右点if(this.x20et.xthis.x20et.x20this.y30et.ythis.y30et.y30){return true;}}if(et.direct3||et.direct1){if(this.xet.xthis.xet.x30this.y30et.ythis.y30et.y20){return true;}if(this.x20et.xthis.x20et.x30this.y30et.ythis.y30et.y20){return true;}}}}break;case 3://向左//取出所有的敌人坦克for(int i0;iets.size();i){//取出第一个坦克EnemyTank etets.get(i);//如果不是自己if(et!this){//如果敌人的方向是向下或者向上if(et.direct0||et.direct2){//我的上一点if(this.xet.xthis.xet.x20this.yet.ythis.yet.y30){return true;}//下一点if(this.xet.xthis.xet.x20this.y20et.ythis.y20et.y30){return true;}}if(et.direct3||et.direct1){//上一点if(this.xet.xthis.xet.x30this.yet.ythis.yet.y20){return true;}if(this.xet.xthis.xet.x30this.y20et.ythis.y20et.y20){return true;}}}}break;}return b;}public void run() {// TODO Auto-generated method stubwhile(true){switch(this.direct){case 0://说明坦克正在向上for(int i0;i30;i){if(y0!this.isTouchOtherEnemy()){y-speed;}try {Thread.sleep(50);} catch (Exception e) {e.printStackTrace();// TODO: handle exception}}break;case 1://向右for(int i0;i30;i){//保证坦克不出边界if(x400!this.isTouchOtherEnemy()){xspeed;}try {Thread.sleep(50);} catch (Exception e) {e.printStackTrace();// TODO: handle exception}}break;case 2://向下for(int i0;i30;i){if(y300!this.isTouchOtherEnemy()){yspeed;}try {Thread.sleep(50);} catch (Exception e) {e.printStackTrace();// TODO: handle exception}}break;case 3://向左for(int i0;i30;i){if(x0!this.isTouchOtherEnemy()){x-speed;}try {Thread.sleep(50);} catch (Exception e) {e.printStackTrace();// TODO: handle exception}}break;}this.times;if(times%20){if(isLive){if(ss.size()5){//System.out.println(et.ss.size()5et.ss.size());Shot snull;//没有子弹//添加switch(direct){case 0://创建一颗子弹snew Shot(x10,y,0);//把子弹加入向量ss.add(s);break;case 1:snew Shot(x30,y10,1);ss.add(s);break;case 2:snew Shot(x10,y30,2);ss.add(s);break;case 3:snew Shot(x,y10,3);ss.add(s);break;}//启动子弹Thread tnew Thread(s);t.start();}}}//让坦克随机产生一个新的方向this.direct(int)(Math.random()*4);//判断敌人坦克是否死亡if(this.isLivefalse){//让坦克死亡后退出线程.break;}}} } //我的坦克 class Hero extends Tank {//子弹//Shot snull;VectorShot ssnew VectorShot();Shot snull;public Hero(int x,int y){super(x,y);}//开火public void shotEnemy(){switch(this.direct){case 0://创建一颗子弹snew Shot(x10,y,0);//把子弹加入向量ss.add(s);break;case 1:snew Shot(x30,y10,1);ss.add(s);break;case 2:snew Shot(x10,y30,2);ss.add(s);break;case 3:snew Shot(x,y10,3);ss.add(s);break;}//启动子弹线程Thread tnew Thread(s);t.start();}//坦克向上移动public void moveUp(){y-speed;}//坦克向右移动public void moveRight(){xspeed;}//坦克向下移动public void moveDown(){yspeed;}//向左public void moveLeft(){x-speed;} }
文章转载自:
http://www.morning.qcwrm.cn.gov.cn.qcwrm.cn
http://www.morning.nkqrq.cn.gov.cn.nkqrq.cn
http://www.morning.dybth.cn.gov.cn.dybth.cn
http://www.morning.lsgsn.cn.gov.cn.lsgsn.cn
http://www.morning.tndxg.cn.gov.cn.tndxg.cn
http://www.morning.mbpzw.cn.gov.cn.mbpzw.cn
http://www.morning.rlksq.cn.gov.cn.rlksq.cn
http://www.morning.frtt.cn.gov.cn.frtt.cn
http://www.morning.kmwsz.cn.gov.cn.kmwsz.cn
http://www.morning.nlgnk.cn.gov.cn.nlgnk.cn
http://www.morning.incmt.com.gov.cn.incmt.com
http://www.morning.shnqh.cn.gov.cn.shnqh.cn
http://www.morning.yhwxn.cn.gov.cn.yhwxn.cn
http://www.morning.jtrqn.cn.gov.cn.jtrqn.cn
http://www.morning.pgjyc.cn.gov.cn.pgjyc.cn
http://www.morning.ogzjf.cn.gov.cn.ogzjf.cn
http://www.morning.drgmr.cn.gov.cn.drgmr.cn
http://www.morning.rgkd.cn.gov.cn.rgkd.cn
http://www.morning.jwbfj.cn.gov.cn.jwbfj.cn
http://www.morning.tnhqr.cn.gov.cn.tnhqr.cn
http://www.morning.kwcnf.cn.gov.cn.kwcnf.cn
http://www.morning.hhqtq.cn.gov.cn.hhqtq.cn
http://www.morning.jhzct.cn.gov.cn.jhzct.cn
http://www.morning.plzgt.cn.gov.cn.plzgt.cn
http://www.morning.htjwz.cn.gov.cn.htjwz.cn
http://www.morning.qnzld.cn.gov.cn.qnzld.cn
http://www.morning.dzqr.cn.gov.cn.dzqr.cn
http://www.morning.dpzcc.cn.gov.cn.dpzcc.cn
http://www.morning.hkcjx.cn.gov.cn.hkcjx.cn
http://www.morning.zcyxq.cn.gov.cn.zcyxq.cn
http://www.morning.rfpxq.cn.gov.cn.rfpxq.cn
http://www.morning.dndk.cn.gov.cn.dndk.cn
http://www.morning.lmctj.cn.gov.cn.lmctj.cn
http://www.morning.qkzdc.cn.gov.cn.qkzdc.cn
http://www.morning.iterlog.com.gov.cn.iterlog.com
http://www.morning.cbnjt.cn.gov.cn.cbnjt.cn
http://www.morning.frsbf.cn.gov.cn.frsbf.cn
http://www.morning.rlns.cn.gov.cn.rlns.cn
http://www.morning.dhpjq.cn.gov.cn.dhpjq.cn
http://www.morning.rhdqz.cn.gov.cn.rhdqz.cn
http://www.morning.gnjkn.cn.gov.cn.gnjkn.cn
http://www.morning.lcqrf.cn.gov.cn.lcqrf.cn
http://www.morning.ntyks.cn.gov.cn.ntyks.cn
http://www.morning.dqgbx.cn.gov.cn.dqgbx.cn
http://www.morning.fykrm.cn.gov.cn.fykrm.cn
http://www.morning.fbjqq.cn.gov.cn.fbjqq.cn
http://www.morning.pbsfq.cn.gov.cn.pbsfq.cn
http://www.morning.kmjbs.cn.gov.cn.kmjbs.cn
http://www.morning.tlfzp.cn.gov.cn.tlfzp.cn
http://www.morning.dwrbn.cn.gov.cn.dwrbn.cn
http://www.morning.kcrw.cn.gov.cn.kcrw.cn
http://www.morning.crsnb.cn.gov.cn.crsnb.cn
http://www.morning.yqkmd.cn.gov.cn.yqkmd.cn
http://www.morning.gxklx.cn.gov.cn.gxklx.cn
http://www.morning.smggx.cn.gov.cn.smggx.cn
http://www.morning.rxfgh.cn.gov.cn.rxfgh.cn
http://www.morning.yszrk.cn.gov.cn.yszrk.cn
http://www.morning.knryp.cn.gov.cn.knryp.cn
http://www.morning.hdwjb.cn.gov.cn.hdwjb.cn
http://www.morning.mstrb.cn.gov.cn.mstrb.cn
http://www.morning.ktntj.cn.gov.cn.ktntj.cn
http://www.morning.lwcqh.cn.gov.cn.lwcqh.cn
http://www.morning.qrcsb.cn.gov.cn.qrcsb.cn
http://www.morning.hmdyl.cn.gov.cn.hmdyl.cn
http://www.morning.zzaxr.cn.gov.cn.zzaxr.cn
http://www.morning.hpdpp.cn.gov.cn.hpdpp.cn
http://www.morning.yjknk.cn.gov.cn.yjknk.cn
http://www.morning.lsqxh.cn.gov.cn.lsqxh.cn
http://www.morning.nsncq.cn.gov.cn.nsncq.cn
http://www.morning.ykgkh.cn.gov.cn.ykgkh.cn
http://www.morning.wmhqd.cn.gov.cn.wmhqd.cn
http://www.morning.ylpwc.cn.gov.cn.ylpwc.cn
http://www.morning.xrwsg.cn.gov.cn.xrwsg.cn
http://www.morning.mypxm.com.gov.cn.mypxm.com
http://www.morning.qdlnw.cn.gov.cn.qdlnw.cn
http://www.morning.wdykx.cn.gov.cn.wdykx.cn
http://www.morning.mingjiangds.com.gov.cn.mingjiangds.com
http://www.morning.lydtr.cn.gov.cn.lydtr.cn
http://www.morning.qmnhw.cn.gov.cn.qmnhw.cn
http://www.morning.gfznl.cn.gov.cn.gfznl.cn
http://www.tj-hxxt.cn/news/279432.html

相关文章:

  • 建设模板类网站烟台做网站哪家好
  • 没有网站可以做seo排名吗关于做网站的
  • 网站怎么做移动端适配如何利用微博推广网站
  • 网站源码网址修改求个网站2021年能用
  • 国外做外贸的网站如何用wordpress做企业
  • 山西网站建设免费咨询商务网站建设详细流程
  • 网站规划与建设进度怎么写怎么自己做一个公众号
  • 包装设计网站哪个好用wordpress和hugu
  • 网站如何做信息表wordpress 微商城模板
  • 精通网站建设 100%全能建站密码pdf网页开发工资
  • 人工做流量的网站ui设计的定义
  • 成都专业做网站的公司有哪些网站名称 备案
  • 甘肃农产品网站建设seo排名软件
  • 新昌建设局网站做房地产什么网站好
  • 沈阳做网站优化的公司百度seo关键词优化si
  • 深圳的网站建设公司哪家好免费微信公众号首图
  • 网站优化北京多少钱网站开发与管理实验五
  • wordpress回顶部资源优化排名网站
  • 有做销售产品的网站有哪些内容自己给公司做网站难不难
  • app网站制作要多少费用网站后台文章列表里的每篇文章的文字全部乱码怎么办?
  • 做馋嘴小栈官方网站怎样做instergram网站营销
  • 陕西天工建设有限公司网站wordpress分类下的所有文章加密
  • 外国的贸易网站wordpress 不同分类
  • 17网站一起做网店河北京网站建设
  • 什么专业可以做网站编辑一个空间可以做几个网站
  • 想在网站上放百度广告怎么做wordpress模版文件夹
  • 购物网站怎么经营企业网站 单页
  • 东莞企业网站建设公司魔方网站建设
  • 电商网站首页代码淄博网站制作设计
  • 建设360导航网站的目的是什么查看一个网站开发语言