日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術(shù)文章
文章詳情頁

java實現(xiàn)坦克大戰(zhàn)游戲

瀏覽:95日期:2022-08-24 09:38:22

本文實例為大家分享了java實現(xiàn)坦克大戰(zhàn)游戲的具體代碼,供大家參考,具體內(nèi)容如下

一、實現(xiàn)的功能

1、游戲玩法介紹2、自定義游戲(選擇游戲難度、關(guān)卡等)3、自定義玩家姓名4、數(shù)據(jù)的動態(tài)顯示

二、程序基本結(jié)構(gòu)

java實現(xiàn)坦克大戰(zhàn)游戲

三、主要的界面

1)游戲首頁

java實現(xiàn)坦克大戰(zhàn)游戲

2)自定義游戲頁面

java實現(xiàn)坦克大戰(zhàn)游戲

3)游戲介紹

java實現(xiàn)坦克大戰(zhàn)游戲

4)開始游戲,自定義玩家姓名

java實現(xiàn)坦克大戰(zhàn)游戲

5)游戲主頁面

java實現(xiàn)坦克大戰(zhàn)游戲

四、主要代碼

1)數(shù)據(jù)的初始化類

public class Data { public static boolean isRestart=false; public static boolean isGameOver=false; public static int start = 0;// 1為開始 0為還未開始 public static int levle = 1;//關(guān)卡 public static int pouse = 0;//0表示繼續(xù) 1表示暫停 public static String name = ''; public static int time = 0; public static int b = 0; public static int a = 1;//玩家的方向 1為上 2為下 3為左 4為右 public static int count; // 計算積分數(shù) public static int hit = 0; // 計算擊毀坦克的數(shù)量 public static Player player = new Player(200, 560, 3, 1);// 創(chuàng)建 玩家 public static home home = new home(280, 560, 1);// 創(chuàng)建碉堡 // 加載圖片 相對路徑 jpg png gif public static final Image IMG_ST = new ImageIcon('image/timg (2).jpg').getImage(); public static final Image IMG_buleUp = new ImageIcon('image/buleUp.gif').getImage(); public static final Image IMG_buledown = new ImageIcon('image/buledown.gif').getImage(); public static final Image IMG_buleLeft = new ImageIcon('image/buleLeft.gif').getImage(); public static final Image IMG_buleRight = new ImageIcon('image/buleRight.gif').getImage(); public static final Image IMG_pinkDown = new ImageIcon('image/pinkDown.gif').getImage(); public static final Image IMG_pinkLeft = new ImageIcon('image/pinkLeft.gif').getImage(); public static final Image IMG_pinkRight = new ImageIcon('image/pinkRight.gif').getImage(); public static final Image IMG_pinkUp = new ImageIcon('image/pinkUp.gif').getImage(); public static final Image IMG_yellowDown = new ImageIcon('image/yellowDown.gif').getImage(); public static final Image IMG_yellowLeft = new ImageIcon('image/yellowLeft.gif').getImage(); public static final Image IMG_yellowRight = new ImageIcon('image/yellowRight.gif').getImage(); public static final Image IMG_yellowUp = new ImageIcon('image/yellowUp.gif').getImage(); public static final Image IMG_tie = new ImageIcon('image/tie4.gif').getImage(); public static final Image IMG_warter = new ImageIcon('image/water.gif').getImage(); public static final Image IMG_grass = new ImageIcon('image/grass.gif').getImage(); public static final Image IMG_wall = new ImageIcon('image/walls.gif').getImage(); public static final Image IMG_smallwall = new ImageIcon('image/smallwalls.gif').getImage(); public static final Image IMG_PLAYER1 = new ImageIcon('image/player1.gif').getImage(); public static final Image IMG_PLAYER2 = new ImageIcon('image/player2.gif').getImage(); public static final Image IMG_PLAYER3 = new ImageIcon('image/player3.gif').getImage(); public static final Image IMG_PLAYER4 = new ImageIcon('image/player4.gif').getImage(); public static final Image IMG_home = new ImageIcon('image/symbol.gif').getImage(); public static final Image IMG_bullet = new ImageIcon('image/bullet.gif').getImage(); public static final Image IMG_over = new ImageIcon('image/gameOver.gif').getImage(); public static final Image IMG_win = new ImageIcon('image/gameWin.jpeg').getImage(); public static final Image IMG_hp = new ImageIcon('image/hp.png').getImage(); public static final Image IMG_speed = new ImageIcon('image/124.png').getImage(); public static final Image IMG_bomb = new ImageIcon('image/128.png').getImage(); public static final Image IMG_gia1 = new ImageIcon('image/i1.jpg').getImage(); public static final Image IMG_gia2 = new ImageIcon('image/i2.jpg').getImage(); public static final Image IMG_gia3 = new ImageIcon('image/i3.jpg').getImage(); // 子彈的集合 public static ArrayList<Bullet> zdList = new ArrayList<Bullet>(); public static ArrayList<EnBullet> enzdList = new ArrayList<EnBullet>(); // 界面敵人的集合 public static ArrayList<Enemy> enemyList = new ArrayList<Enemy>(); //后臺敵人的集合 public static ArrayList<Enemy> backlist = new ArrayList<Enemy>(); // 計算各個敵人的數(shù)量集合 public static ArrayList<Enemy> yellowcount = new ArrayList<Enemy>(); public static ArrayList<Enemy> bulecount = new ArrayList<Enemy>(); public static ArrayList<Enemy> pinkcount = new ArrayList<Enemy>(); //道具的集合 public static ArrayList<stage> stagelList = new ArrayList<stage>(); public static void initenemy(int num) { Random ran = new Random(); for (int i = 0; i < num; i++) { int key = ran.nextInt(3); Enemy en = null; if (key == 0) { en = new YellowEnemy(0, 0, 1, 0, 0,100); yellowcount.add(en); } else if (key == 1) { en = new BuleEnemy(560, 0, 1, 0, 0,100); bulecount.add(en); } else { en = new PinkEnemy(250, 0, 1, 0, 0,100); pinkcount.add(en); } backlist.add(en); } }}

2)開始游戲

public class StartAction implements ActionListener { private GameFrame f; private GameArea ga; public StartAction(GameFrame f) { super(); this.f = f; } public void actionPerformed(ActionEvent e) { String startaction = e.getActionCommand(); if (startaction.equals('start')) { String title = JOptionPane.showInputDialog(null, '請輸入姓名', '歡迎來到坦克大戰(zhàn)', JOptionPane.PLAIN_MESSAGE); Data.name = title; Data.start = 1; Data.initenemy(3); f.getGm().getStartgame().setEnabled(false); f.getGm().getRestart().setEnabled(true); } else if (startaction.equals('restart')) { Data.enemyList.clear(); Data.backlist.clear(); Data.yellowcount.clear(); Data.bulecount.clear(); Data.pinkcount.clear(); Data.stagelList.clear(); Data.player.setX(200); Data.player.setY(560); Data.initenemy(3); Data.b = 0; Player.setHP(3); Data.isGameOver = true; Data.isRestart =true; } else if (startaction.equals('exit')) { System.exit(0); } else if (startaction.equals('game')) { JOptionPane.showMessageDialog(null,'用 W S A D控制方向,J鍵盤發(fā)射,P為暫停,O為繼續(xù)。n道具: 炸彈----使敵人消失 星星-----加速 愛心----增加生命值!n制作不易請多多包含!!!', '提示!', JOptionPane.INFORMATION_MESSAGE); } else if (startaction.equals('self')) { new GameSelf(); } }}

3)監(jiān)聽按鍵類

public class PlayerKeyListener extends KeyAdapter { private Player player; @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); int key = e.getKeyCode(); if (key == KeyEvent.VK_W) { if (Data.pouse == 0 && Data.player.getY() > 0) { Data.player.up(); Data.a = 1; } } if (key == KeyEvent.VK_S) { if (Data.pouse == 0 && Data.player.getY() < 560) { Data.player.down(); Data.a = 2; } } if (key == KeyEvent.VK_A) { if (Data.pouse == 0 && Data.player.getX() > 0) { Data.player.left(); Data.a = 3; } } if (key == KeyEvent.VK_D) { if (Data.pouse == 0 && Data.player.getX() < 560) { Data.player.right(); Data.a = 4; } } if (key == KeyEvent.VK_P) { Data.pouse = 1; } if (key == KeyEvent.VK_O) { Data.pouse = 0; } } @Override public void keyReleased(KeyEvent e) { super.keyReleased(e); int key = e.getKeyCode(); if (key == KeyEvent.VK_J) { if (Data.pouse == 0 && Data.a == 1) { int x = Data.player.getX() + 16; int y = Data.player.getY() - 5; Bullet bullet = new Bullet(x, y, Data.a); Data.zdList.add(bullet); return; } if (Data.pouse == 0 && Data.a == 2) { int x = Data.player.getX() + 16; int y = Data.player.getY() + 32; Bullet bullet = new Bullet(x, y, Data.a); Data.zdList.add(bullet); return; } if (Data.pouse == 0 && Data.a == 3) { int x = Data.player.getX() - 10; int y = Data.player.getY() + 15; Bullet bullet = new Bullet(x, y, Data.a); Data.zdList.add(bullet); return; } if (Data.pouse == 0 && Data.a == 4) { int x = Data.player.getX() + 38; int y = Data.player.getY() + 15; Bullet bullet = new Bullet(x, y, Data.a); Data.zdList.add(bullet); return; } } }}

源碼下載:坦克游戲

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標簽: Java
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
美女国产精品久久久| 中文字幕av一区二区三区人| 亚洲精品动态| 91日韩欧美| 亚州国产精品| 国产亚洲一级| 亚洲免费观看| 欧美特黄一级| 久久三级福利| 日韩高清欧美| 精品国产乱码久久久| 亚洲精品亚洲人成在线观看| 国产综合视频| 麻豆视频在线观看免费网站黄| 日韩一区二区三区高清在线观看| 国产精一区二区| 日韩精品成人| 日韩一区精品视频| 午夜精品成人av| 亚洲美女久久精品| 波多野结衣一区| 日韩高清不卡在线| bbw在线视频| 三级精品视频| 国产精品试看| 久久国产视频网| 国产一区丝袜| 在线亚洲免费| 久久香蕉网站| 91久久久久| 欧美久久香蕉| 久久蜜桃精品| 欧美三区不卡| 国产欧美一区二区三区精品酒店| 今天的高清视频免费播放成人| 一区二区三区网站| 桃色一区二区| 日本va欧美va瓶| 99久精品视频在线观看视频| 中文字幕日韩高清在线| 国内在线观看一区二区三区| 亚洲精品123区| 理论片午夜视频在线观看| 国产精品久久久久av蜜臀 | 亚洲深夜福利在线观看| 麻豆免费精品视频| 国产精品日本一区二区三区在线 | 亚洲毛片视频| 欧美日韩国产一区二区三区不卡 | 久久精品99久久久| 国产韩日影视精品| 亚洲综合欧美| 久久亚洲欧美| 国产黄色一区| 欧美日韩色图| 日本a级不卡| 在线观看精品| 日韩 欧美一区二区三区| 精品国产18久久久久久二百| 亚洲欧美日韩一区在线观看| 免费亚洲婷婷| 免费久久99精品国产自在现线| 国产精品黄色片| 久久精选视频| 国产免费av国片精品草莓男男| 日韩av首页| 久久激情五月婷婷| 红桃视频欧美| 成人午夜毛片| 日韩高清不卡一区二区| 成人看片网站| 国产欧美日韩影院| 天堂日韩电影| 国产欧美日本| 丝袜亚洲另类欧美| www.51av欧美视频| 欧美在线看片| 亚洲在线成人| 福利片在线一区二区| 蜜桃视频一区二区三区在线观看| 日韩中文影院| 久久av网站| 欧美天堂在线| 国产精品.xx视频.xxtv| 亚洲精品系列| 亚洲色诱最新| av资源中文在线| 久久免费精品| 久久国产精品免费精品3p| 亚洲尤物在线| 欧美福利一区| 欧美天堂视频| 精品一区二区三区免费看| 亚洲人成亚洲精品| 国产精品7m凸凹视频分类| 日本久久成人网| www在线观看黄色| 久久一区国产| 国产精品极品国产中出| 久久精品超碰| 91精品国产经典在线观看| 爽爽淫人综合网网站| 伊人久久大香线蕉av超碰演员| 伊人久久高清| 成人免费电影网址| 欧美日韩国产观看视频| 风间由美中文字幕在线看视频国产欧美| 久久国产尿小便嘘嘘| 四虎精品永久免费| 9色精品在线| 一区视频在线| 欧美日韩精品一本二本三本| 麻豆精品蜜桃| 久久久精品五月天| 免费在线小视频| 日韩精品麻豆| 99视频精品全国免费| 亚洲一级少妇| 日韩精品一区二区三区免费观影 | 日韩精品中文字幕第1页| 你懂的国产精品| 欧美激情一区| 久久中文在线| 黄色网一区二区| 在线中文字幕播放| 日韩成人高清| 久久一级电影| 亚洲激情另类| 免费国产亚洲视频| 亚洲人成精品久久久| 午夜精品影视国产一区在线麻豆| 日韩在线观看一区二区三区| 日韩精品中文字幕吗一区二区| 久久精品97| 国产精品美女在线观看直播| 国产精品白丝久久av网站| 国产精品theporn| 精品无人区麻豆乱码久久久| 黄色精品视频| 亚洲高清av| 日韩一区二区久久| 久久www成人_看片免费不卡| 美国三级日本三级久久99| 亚洲精品看片| 国产私拍福利精品视频二区| 国产精品一区二区99| 激情黄产视频在线免费观看| 久久亚洲国产| 蜜臀久久99精品久久久画质超高清| 中文不卡在线| 国产日韩欧美| 久久uomeier| 中国女人久久久| 久久国产精品免费精品3p| sm捆绑调教国产免费网站在线观看| 美女网站一区| 亚洲ab电影| 麻豆91精品91久久久的内涵| 中文另类视频| 亚洲专区视频| 久久这里只有精品一区二区| 欧美不卡高清一区二区三区| 视频一区欧美精品| 国产精品一区二区三区四区在线观看 | 青青草国产精品亚洲专区无| 九九九精品视频| 亚洲夜间福利| 日韩综合一区二区| 激情国产在线| 日av在线不卡| 精品三区视频| 中文日韩欧美| 久久的色偷偷| 在线精品小视频| 国产精品久久久久久模特| 久久九九99| 亚洲精品在线a| 精品国产99| 首页国产欧美久久| 高清av一区| 男人的天堂亚洲一区| 麻豆成人av在线| 久久av一区| 国产成人精品一区二区三区视频| 亚洲少妇一区| 91免费精品| 7m精品国产导航在线| 欧美高清不卡| 欧美91在线|欧美| 国产农村妇女精品一二区| 精品久久久网| 国产精品毛片在线看| 麻豆91在线播放| 蜜臀91精品一区二区三区| bbw在线视频| 久久精品99国产精品| 在线视频免费在线观看一区二区| 国产一区二区三区久久| 日韩精品欧美大片| 婷婷激情久久|