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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

JAVA版超级玛丽

發(fā)布時間:2023/12/29 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JAVA版超级玛丽 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

這是一篇關(guān)于JAVA的超級瑪麗游戲,源代碼的部分在下面正文中介紹,圖片和音頻的部分都放在百度云盤,需要的自行下載。

文章目錄

  • 開發(fā)環(huán)境
  • 一、下載方法
  • 二、運(yùn)行效果展示
  • 三、項(xiàng)目結(jié)構(gòu)以及主程序入口
    • 1.項(xiàng)目結(jié)構(gòu)
    • 2.主程序入口
  • 四、代碼部分
    • 1.代碼如下
    • 2.引入額外的JAR包
  • 總結(jié)


開發(fā)環(huán)境

開發(fā)工具:eclipse2021-12
JDK版本:JDK15.0.1

需要引入額外的JAR包,不然程序會報錯,主要是音樂加不進(jìn)來。
jl-1.0.1.jar


一、下載方法

百度云盤
鏈接:https://pan.baidu.com/s/1Nc28_UKsBV3QHGXfOjSAMg
提取碼:uqz9
編碼格式:UTF-8

二、運(yùn)行效果展示

啟動程序以后,直接進(jìn)入游戲,游戲運(yùn)行時的畫面


三、項(xiàng)目結(jié)構(gòu)以及主程序入口

1.項(xiàng)目結(jié)構(gòu)

2.主程序入口

入口程序在MyFrame.java類中。

四、代碼部分

1.代碼如下

代碼如下:

MyFrame.java類

package com.sxt;import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Image; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List;import javax.swing.JFrame; import javax.swing.JOptionPane;import javazoom.jl.decoder.JavaLayerException;public class MyFrame extends JFrame implements KeyListener,Runnable {//用于存儲所有的背景private List<BackGround> allBg = new ArrayList<>();//用于存儲當(dāng)前的背景private BackGround nowBg = new BackGround();//用于雙緩存private Image offScreenImage = null;//馬里奧對象private Mario mario = new Mario();//定義一個線程對象,用于實(shí)現(xiàn)馬里奧的運(yùn)動private Thread thread = new Thread(this);public MyFrame() {//設(shè)置窗口的大小為800 * 600this.setSize(800,600);//設(shè)置窗口居中顯示this.setLocationRelativeTo(null);//設(shè)置窗口的可見性this.setVisible(true);//設(shè)置點(diǎn)擊窗口上的關(guān)閉鍵,結(jié)束程序this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設(shè)置窗口大小不可變this.setResizable(false);//向窗口對象添加鍵盤監(jiān)聽器this.addKeyListener(this);//設(shè)置窗口名稱this.setTitle("超級瑪麗");//初始化圖片StaticValue.init();//初始化馬里奧mario = new Mario(10,355);//創(chuàng)建全部的場景for (int i = 1;i <= 3;i++) {allBg.add(new BackGround(i, i == 3 ? true : false));}//將第一個場景設(shè)置為當(dāng)前場景nowBg = allBg.get(0);mario.setBackGround(nowBg);//繪制圖像repaint();thread.start();try {new Music();} catch (FileNotFoundException e) {e.printStackTrace();} catch (JavaLayerException e) {e.printStackTrace();}}@Overridepublic void paint(Graphics g) {if (offScreenImage == null) {offScreenImage = createImage(800,600);}Graphics graphics = offScreenImage.getGraphics();graphics.fillRect(0,0,800,600);//繪制背景graphics.drawImage(nowBg.getBgImage(),0,0,this);//繪制敵人for (Enemy e : nowBg.getEnemyList()) {graphics.drawImage(e.getShow(),e.getX(),e.getY(),this);}//繪制障礙物for (Obstacle ob : nowBg.getObstacleList()) {graphics.drawImage(ob.getShow(),ob.getX(),ob.getY(),this);}//繪制城堡graphics.drawImage(nowBg.getTower(),620,270,this);//繪制旗桿graphics.drawImage(nowBg.getGan(),500,220,this);//繪制馬里奧graphics.drawImage(mario.getShow(),mario.getX(),mario.getY(),this);//添加分?jǐn)?shù)Color c = graphics.getColor();graphics.setColor(Color.BLACK);graphics.setFont(new Font("黑體",Font.BOLD,25));graphics.drawString("當(dāng)前的分?jǐn)?shù)為: " + mario.getScore(),300,100);graphics.setColor(c);//將圖像繪制到窗口中g.drawImage(offScreenImage,0,0,this);}public static void main(String[] args) {MyFrame myFrame = new MyFrame();}@Overridepublic void keyTyped(KeyEvent e) {}//當(dāng)鍵盤按下按鍵時調(diào)用@Overridepublic void keyPressed(KeyEvent e) {//向右移動if (e.getKeyCode() == 39) {mario.rightMove();}//向左移動if (e.getKeyCode() == 37) {mario.leftMove();}//跳躍if (e.getKeyCode() == 38) {mario.jump();}}//當(dāng)鍵盤松開按鍵時調(diào)用@Overridepublic void keyReleased(KeyEvent e) {//想左停止if (e.getKeyCode() == 37) {mario.leftStop();}//向右停止if (e.getKeyCode() == 39) {mario.rightStop();}}@Overridepublic void run() {while (true) {repaint();try {Thread.sleep(50);if (mario.getX() >= 775) {nowBg = allBg.get(nowBg.getSort());mario.setBackGround(nowBg);mario.setX(10);mario.setY(355);}//判斷馬里奧是否死亡if (mario.isDeath()) {JOptionPane.showMessageDialog(this,"馬里奧死亡!!!");System.exit(0);}//判斷游戲是否結(jié)束if (mario.isOK()) {JOptionPane.showMessageDialog(this,"恭喜你!成功通關(guān)了");System.exit(0);}} catch (InterruptedException e) {e.printStackTrace();}}}}

StaticValue.java類

package com.sxt;import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List;public class StaticValue {//背景public static BufferedImage bg = null;public static BufferedImage bg2 = null;//馬里奧向左跳躍public static BufferedImage jump_L = null;//馬里奧向右跳躍public static BufferedImage jump_R = null;//馬里奧向左站立public static BufferedImage stand_L = null;//馬里奧向右站立public static BufferedImage stand_R = null;//城堡public static BufferedImage tower = null;//旗桿public static BufferedImage gan = null;//障礙物public static List<BufferedImage> obstacle = new ArrayList<>();//馬里奧向左跑public static List<BufferedImage> run_L = new ArrayList<>();//馬里奧向右跑public static List<BufferedImage> run_R = new ArrayList<>();//蘑菇敵人public static List<BufferedImage> mogu = new ArrayList<>();//食人花敵人public static List<BufferedImage> flower = new ArrayList<>();//路徑的前綴,方便后續(xù)調(diào)用public static String path = System.getProperty("user.dir") + "/src/images/";//初始化方法public static void init() {try {//加載背景圖片bg = ImageIO.read(new File(path + "bg.png"));bg2 = ImageIO.read(new File(path + "bg2.png"));//加載馬里奧向左站立stand_L = ImageIO.read(new File(path + "s_mario_stand_L.png"));//加載馬里奧向右站立stand_R = ImageIO.read(new File(path + "s_mario_stand_R.png"));//加載城堡tower = ImageIO.read(new File(path + "tower.png"));//加載旗桿gan = ImageIO.read(new File(path + "gan.png"));//加載馬里奧向左跳躍jump_L = ImageIO.read(new File(path + "s_mario_jump1_L.png"));//加載馬里奧向右跳躍jump_R = ImageIO.read(new File(path + "s_mario_jump1_R.png"));} catch (IOException e) {e.printStackTrace();}//加載馬里奧向左跑for (int i = 1;i <= 2;i++) {try {run_L.add(ImageIO.read(new File(path + "s_mario_run"+ i +"_L.png")));} catch (IOException e) {e.printStackTrace();}}//加載馬里奧向右跑for (int i = 1;i <= 2;i++) {try {run_R.add(ImageIO.read(new File(path + "s_mario_run"+ i +"_R.png")));} catch (IOException e) {e.printStackTrace();}}try {//加載障礙物obstacle.add(ImageIO.read(new File(path + "brick.png")));obstacle.add(ImageIO.read(new File(path + "soil_up.png")));obstacle.add(ImageIO.read(new File(path + "soil_base.png")));} catch (IOException e) {e.printStackTrace();}//加載水管for (int i = 1;i <= 4;i++) {try {obstacle.add(ImageIO.read(new File(path + "pipe"+ i +".png")));} catch (IOException e) {e.printStackTrace();}}//加載不可破壞的磚塊和旗子try {obstacle.add(ImageIO.read(new File(path + "brick2.png")));obstacle.add(ImageIO.read(new File(path + "flag.png")));} catch (IOException e) {e.printStackTrace();}//加載蘑菇敵人for (int i = 1;i <= 3;i++) {try {mogu.add(ImageIO.read(new File(path + "fungus"+i+".png")));} catch (IOException e) {e.printStackTrace();}}//加載食人花敵人for (int i = 1;i <= 2;i++) {try {flower.add(ImageIO.read(new File(path + "flower1."+i+".png")));} catch (IOException e) {e.printStackTrace();}}} }

Obstacle.java類

package com.sxt;import java.awt.image.BufferedImage;public class Obstacle implements Runnable{//用于表示坐標(biāo)private int x;private int y;//用于記錄障礙物類型private int type;//用于顯示圖像private BufferedImage show = null;//定義當(dāng)前的場景對象private BackGround bg = null;//定義一個線程對象private Thread thread = new Thread(this);public Obstacle(int x,int y,int type,BackGround bg) {this.x = x;this.y = y;this.type = type;this.bg = bg;show = StaticValue.obstacle.get(type);//如果是旗子的話,啟動線程if (type == 8) {thread.start();}}public int getX() {return x;}public int getY() {return y;}public int getType() {return type;}public BufferedImage getShow() {return show;}@Overridepublic void run() {while (true) {if (this.bg.isReach()) {if (this.y < 374) {this.y += 5;}else {this.bg.setBase(true);}}try {Thread.sleep(50);} catch (InterruptedException e) {e.printStackTrace();}}} }

Music.java

package com.sxt;import javazoom.jl.decoder.JavaLayerException; import javazoom.jl.player.Player;import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException;public class Music {public Music() throws FileNotFoundException, JavaLayerException {Player player;String str = System.getProperty("user.dir") + "/src/Music/music.wav";BufferedInputStream name = new BufferedInputStream(new FileInputStream(str));player = new Player(name);player.play();} }

Mario.java

package com.sxt;import java.awt.image.BufferedImage;public class Mario implements Runnable{//用于表示橫縱坐標(biāo)private int x;private int y;//用于表示當(dāng)前的狀態(tài)private String status;//用于顯示當(dāng)前狀態(tài)對應(yīng)的圖像private BufferedImage show = null;//定義一個BackGround對象,用來獲取障礙物的信息private BackGround backGround = new BackGround();//用來實(shí)現(xiàn)馬里奧的動作private Thread thread = null;//馬里奧的移動速度private int xSpeed;//馬里奧的跳躍速度private int ySpeed;//定義一個索引private int index;//表示馬里奧上升的時間private int upTime = 0;//用于判斷馬里奧是否走到了城堡的門口private boolean isOK;//用于判斷馬里奧是否死亡private boolean isDeath = false;//表示分?jǐn)?shù)private int score = 0;public Mario() {}public Mario (int x,int y) {this.x = x;this.y = y;show = StaticValue.stand_R;this.status = "stand--right";thread = new Thread(this);thread.start();}//馬里奧的死亡方法public void death() {isDeath = true;}//馬里奧向左移動public void leftMove() {//改變速度xSpeed = -5;//判斷馬里奧是否碰到旗子if (backGround.isReach()) {xSpeed = 0;}//判斷馬里奧是否處于空中if (status.indexOf("jump") != -1) {status = "jump--left";}else {status = "move--left";}}//馬里奧向右移動public void rightMove() {xSpeed = 5;//判斷馬里奧是否碰到旗子if (backGround.isReach()) {xSpeed = 0;}if (status.indexOf("jump") != -1) {status = "jump--right";}else {status = "move--right";}}//馬里奧向左停止public void leftStop() {xSpeed = 0;if (status.indexOf("jump") != -1) {status = "jump--left";}else {status = "stop--left";}}//馬里奧向右停止public void rightStop() {xSpeed = 0;if (status.indexOf("jump") != -1) {status = "jump--right";}else {status = "stop--right";}}//馬里奧跳躍public void jump() {if (status.indexOf("jump") == -1) {if (status.indexOf("left") != -1) {status = "jump--left";}else {status = "jump--right";}ySpeed = -10;upTime = 7;}//判斷馬里奧是否碰到旗子if (backGround.isReach()) {ySpeed = 0;}}//馬里奧下落public void fall() {if (status.indexOf("left") != -1) {status = "jump--left";}else {status = "jump--right";}ySpeed = 10;}@Overridepublic void run() {while (true) {//判斷是否處于障礙物上boolean onObstacle = false;//判斷是否可以往右走boolean canRight = true;//判斷是否可以往左走boolean canLeft = true;//判斷馬里奧是否到達(dá)旗桿位置if (backGround.isFlag() && this.x >= 500) {this.backGround.setReach(true);//判斷旗子是否下落完成if (this.backGround.isBase()) {status = "move--right";if (x < 690) {x += 5;}else {isOK = true;}}else {if (y < 395) {xSpeed = 0;this.y += 5;status = "jump--right";}if (y > 395) {this.y = 395;status = "stop--right";}}}else {//遍歷當(dāng)前場景里所有的障礙物for (int i = 0; i < backGround.getObstacleList().size(); i++) {Obstacle ob = backGround.getObstacleList().get(i);//判斷馬里奧是否位于障礙物上if (ob.getY() == this.y + 25 && (ob.getX() > this.x - 30 && ob.getX() < this.x + 25)) {onObstacle = true;}//判斷是否跳起來頂?shù)酱u塊if ((ob.getY() >= this.y - 30 && ob.getY() <= this.y - 20) && (ob.getX() > this.x - 30 && ob.getX() < this.x + 25)) {if (ob.getType() == 0) {backGround.getObstacleList().remove(ob);score += 1;}upTime = 0;}//判斷是否可以往右走if (ob.getX() == this.x + 25 && (ob.getY() > this.y - 30 && ob.getY() < this.y + 25)) {canRight = false;}//判斷是否可以往左走if (ob.getX() == this.x - 30 && (ob.getY() > this.y - 30 && ob.getY() < this.y + 25)) {canLeft = false;}}//判斷馬里奧是否碰到敵人死亡或者踩死蘑菇敵人for (int i = 0;i < backGround.getEnemyList().size();i++) {Enemy e = backGround.getEnemyList().get(i);if (e.getY() == this.y + 20 && (e.getX() - 25 <= this.x && e.getX() + 35 >= this.x)) {if (e.getType() == 1) {e.death();score += 2;upTime = 3;ySpeed = -10;}else if (e.getType() == 2) {//馬里奧死亡death();}}if ((e.getX() + 35 > this.x && e.getX() - 25 < this.x) && (e.getY() + 35 > this.y && e.getY() - 20 < this.y)) {//馬里奧死亡death();}}//進(jìn)行馬里奧跳躍的操作if (onObstacle && upTime == 0) {if (status.indexOf("left") != -1) {if (xSpeed != 0) {status = "move--left";} else {status = "stop--left";}} else {if (xSpeed != 0) {status = "move--right";} else {status = "stop--right";}}} else {if (upTime != 0) {upTime--;} else {fall();}y += ySpeed;}}if ((canLeft && xSpeed < 0) || (canRight && xSpeed > 0)) {x += xSpeed;//判斷馬里奧是否到了最左邊if (x < 0) {x = 0;}}//判斷當(dāng)前是否是移動狀態(tài)if (status.contains("move")) {index = index == 0 ? 1 : 0;}//判斷是否向左移動if ("move--left".equals(status)) {show = StaticValue.run_L.get(index);}//判斷是否向右移動if ("move--right".equals(status)) {show = StaticValue.run_R.get(index);}//判斷是否向左停止if ("stop--left".equals(status)) {show = StaticValue.stand_L;}//判斷是否向右停止if ("stop--right".equals(status)) {show = StaticValue.stand_R;}//判斷是否向左跳躍if ("jump--left".equals(status)) {show = StaticValue.jump_L;}//判斷是否向右跳躍if ("jump--right".equals(status)) {show = StaticValue.jump_R;}try {Thread.sleep(50);} catch (InterruptedException e) {e.printStackTrace();}}}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 BufferedImage getShow() {return show;}public void setShow(BufferedImage show) {this.show = show;}public void setBackGround(BackGround backGround) {this.backGround = backGround;}public boolean isOK() {return isOK;}public boolean isDeath() {return isDeath;}public int getScore() {return score;} }

Enemy.java

package com.sxt;import java.awt.image.BufferedImage;public class Enemy implements Runnable{//存儲當(dāng)前坐標(biāo)private int x;private int y;//存儲敵人類型private int type;//判斷敵人運(yùn)動的方向private boolean face_to = true;//用于顯示敵人的當(dāng)前圖像private BufferedImage show;//定義一個背景對象private BackGround bg;//食人花運(yùn)動的極限范圍private int max_up = 0;private int max_down = 0;//定義線程對象private Thread thread = new Thread(this);//定義當(dāng)前的圖片的狀態(tài)private int image_type = 0;//蘑菇敵人的構(gòu)造函數(shù)public Enemy(int x,int y,boolean face_to,int type,BackGround bg) {this.x = x;this.y = y;this.face_to = face_to;this.type = type;this.bg = bg;show = StaticValue.mogu.get(0);thread.start();}//食人花敵人的構(gòu)造函數(shù)public Enemy(int x,int y,boolean face_to,int type,int max_up,int max_down,BackGround bg) {this.x = x;this.y = y;this.face_to = face_to;this.type = type;this.max_up = max_up;this.max_down = max_down;this.bg = bg;show = StaticValue.flower.get(0);thread.start();}//死亡方法public void death() {show = StaticValue.mogu.get(2);this.bg.getEnemyList().remove(this);}public int getX() {return x;}public int getY() {return y;}public BufferedImage getShow() {return show;}public int getType() {return type;}@Overridepublic void run() {while (true) {//判斷是否是蘑菇敵人if (type == 1) {if (face_to) {this.x -= 2;}else {this.x += 2;}image_type = image_type == 1 ? 0 : 1;show = StaticValue.mogu.get(image_type);}//定義兩個布爾變量boolean canLeft = true;boolean canRight = true;for (int i = 0;i < bg.getObstacleList().size();i++) {Obstacle ob1 = bg.getObstacleList().get(i);//判斷是否可以右走if (ob1.getX() == this.x + 36 && (ob1.getY() + 65 > this.y && ob1.getY() - 35 < this.y)) {canRight = false;}//判斷是否可以左走if (ob1.getX() == this.x - 36 && (ob1.getY() + 65 > this.y && ob1.getY() - 35 < this.y)) {canLeft = false;}}if (face_to && !canLeft || this.x == 0) {face_to = false;}else if ((!face_to) && (!canRight) || this.x == 764) {face_to = true;}//判斷是否是食人花敵人if (type == 2) {if (face_to) {this.y -= 2;}else {this.y += 2;}image_type = image_type == 1 ? 0 : 1;//食人花是否到達(dá)極限位置if (face_to && (this.y == max_up)) {face_to = false;}if ((!face_to) && (this.y == max_down)) {face_to = true;}show = StaticValue.flower.get(image_type);}try {Thread.sleep(50);} catch (InterruptedException e) {e.printStackTrace();}}} }

BackGround.java

package com.sxt;import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List;public class BackGround {//當(dāng)前場景要顯示的圖像private BufferedImage bgImage = null;//記錄當(dāng)前是第幾個場景private int sort;//判斷是否是最后一個場景private boolean flag;//用于存放我們的所有障礙物private List<Obstacle> obstacleList = new ArrayList<>();//用于存放我們的所有敵人private List<Enemy> enemyList = new ArrayList<>();//用于顯示旗桿private BufferedImage gan = null;//用于顯示城堡private BufferedImage tower = null;//判斷馬里奧是否到達(dá)旗桿位置private boolean isReach = false;//判斷旗子是否落地private boolean isBase = false;public BackGround() {}public BackGround(int sort,boolean flag) {this.sort = sort;this.flag = flag;if (flag) {bgImage = StaticValue.bg2;}else {bgImage = StaticValue.bg;}//判斷是否是第一關(guān)if (sort == 1) {//繪制第一關(guān)的地面,上地面type=1,下地面type=2for (int i = 0;i < 27;i++) {obstacleList.add(new Obstacle(i*30,420,1,this));}for (int j = 0;j <= 120;j += 30) {for (int i = 0;i < 27;i++) {obstacleList.add(new Obstacle(i*30,570-j,2,this));}}//繪制磚塊Afor (int i = 120;i <= 150;i += 30) {obstacleList.add(new Obstacle(i,300,7,this));}//繪制磚塊B-Ffor (int i = 300;i <= 570;i += 30) {if (i == 360 || i == 390 || i == 480 || i == 510 || i == 540) {obstacleList.add(new Obstacle(i,300,7,this));} else {obstacleList.add(new Obstacle(i,300,0,this));}}//繪制磚塊Gfor (int i = 420;i <= 450;i += 30) {obstacleList.add(new Obstacle(i,240,7,this));}//繪制水管for (int i = 360;i <= 600;i += 25) {if (i == 360) {obstacleList.add(new Obstacle(620,i,3,this));obstacleList.add(new Obstacle(645,i,4,this));}else {obstacleList.add(new Obstacle(620,i,5,this));obstacleList.add(new Obstacle(645,i,6,this));}}//繪制第一關(guān)的蘑菇敵人enemyList.add(new Enemy(580,385,true,1,this));//繪制第一關(guān)的食人花敵人enemyList.add(new Enemy(635,420,true,2,328,428,this));}//判斷是否是第二關(guān)if (sort == 2) {//繪制第二關(guān)的地面,上地面type=1,下地面type=2for (int i = 0;i < 27;i++) {obstacleList.add(new Obstacle(i*30,420,1,this));}for (int j = 0;j <= 120;j += 30) {for (int i = 0;i < 27;i++) {obstacleList.add(new Obstacle(i*30,570-j,2,this));}}//繪制第一個水管for (int i = 360;i <= 600;i += 25) {if (i == 360) {obstacleList.add(new Obstacle(60,i,3,this));obstacleList.add(new Obstacle(85,i,4,this));}else {obstacleList.add(new Obstacle(60,i,5,this));obstacleList.add(new Obstacle(85,i,6,this));}}//繪制第二個水管for (int i = 330;i <= 600;i += 25) {if (i == 330) {obstacleList.add(new Obstacle(620,i,3,this));obstacleList.add(new Obstacle(645,i,4,this));}else {obstacleList.add(new Obstacle(620,i,5,this));obstacleList.add(new Obstacle(645,i,6,this));}}//繪制磚塊CobstacleList.add(new Obstacle(300,330,0,this));//繪制磚塊B,E,Gfor (int i = 270;i <= 330;i += 30) {if (i == 270 || i == 330) {obstacleList.add(new Obstacle(i,360,0,this));}else {obstacleList.add(new Obstacle(i,360,7,this));}}//繪制磚塊A,D,F,H,Ifor (int i = 240;i <= 360;i += 30) {if (i == 240 || i == 360) {obstacleList.add(new Obstacle(i,390,0,this));}else {obstacleList.add(new Obstacle(i,390,7,this));}}//繪制妨礙1磚塊obstacleList.add(new Obstacle(240,300,0,this));//繪制空1-4磚塊for (int i = 360;i <= 540;i += 60) {obstacleList.add(new Obstacle(i,270,7,this));}//繪制第二關(guān)的第一個食人花敵人enemyList.add(new Enemy(75,420,true,2,328,418,this));//繪制第二關(guān)的第二個食人花敵人enemyList.add(new Enemy(635,420,true,2,298,388,this));//繪制第二關(guān)的第一個蘑菇敵人enemyList.add(new Enemy(200,385,true,1,this));//繪制第二關(guān)的第二個蘑菇敵人enemyList.add(new Enemy(500,385,true,1,this));}//判斷是否是第三關(guān)if (sort == 3) {//繪制第三關(guān)的地面,上地面type=1,下地面type=2for (int i = 0;i < 27;i++) {obstacleList.add(new Obstacle(i*30,420,1,this));}for (int j = 0;j <= 120;j += 30) {for (int i = 0;i < 27;i++) {obstacleList.add(new Obstacle(i*30,570-j,2,this));}}//繪制第三個背景的A-O磚塊int temp = 290;for (int i = 390;i >= 270;i -= 30) {for (int j = temp;j <= 410;j += 30) {obstacleList.add(new Obstacle(j,i,7,this));}temp += 30;}//繪制第三個背景的P-R磚塊temp = 60;for (int i = 390;i >= 360;i -= 30) {for (int j = temp;j <= 90;j += 30) {obstacleList.add(new Obstacle(j,i,7,this));}temp += 30;}//繪制旗桿gan = StaticValue.gan;//繪制城堡tower = StaticValue.tower;//添加旗子到旗桿上obstacleList.add(new Obstacle(515,220,8,this));//繪制第三關(guān)的蘑菇敵人enemyList.add(new Enemy(150,385,true,1,this));}}public BufferedImage getBgImage() {return bgImage;}public int getSort() {return sort;}public boolean isFlag() {return flag;}public List<Obstacle> getObstacleList() {return obstacleList;}public BufferedImage getGan() {return gan;}public BufferedImage getTower() {return tower;}public boolean isReach() {return isReach;}public void setReach(boolean reach) {isReach = reach;}public boolean isBase() {return isBase;}public void setBase(boolean base) {isBase = base;}public List<Enemy> getEnemyList() {return enemyList;} }

2.引入額外的JAR包

創(chuàng)建lib文件夾,統(tǒng)一存放需要導(dǎo)入的jar包(若已有l(wèi)ib文件,則直接可以進(jìn)行第二步)

將jar復(fù)制粘貼到lib文件夾內(nèi)

選中jar,右鍵-----》Build Path-----》Add to Build Path


導(dǎo)入JAR包后的樣子,因?yàn)槲业腏AR包已經(jīng)導(dǎo)入過了,所以上面的也有同樣的目錄。


總結(jié)

游戲挺好玩,還原度也夠。
鏈接:https://pan.baidu.com/s/1Nc28_UKsBV3QHGXfOjSAMg
提取碼:uqz9
歡迎交流,共同進(jìn)步。

總結(jié)

以上是生活随笔為你收集整理的JAVA版超级玛丽的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 欧美在线一卡 | 99热国产精品 | 九九少妇| 无码人妻丰满熟妇区五十路百度 | 国产成人精品综合在线观看 | 欧美日韩精品在线播放 | 午夜精品久久久久久久99黑人 | 欧美国产在线观看 | av2014天堂 | 肥熟女一区二区三肥熟女 | 国内自拍青青草 | 美女穴穴| 国产人妻精品久久久久野外 | 在线激情小视频 | 免费视频污 | 新版天堂资源中文8在线 | 亚洲aa在线观看 | 国产一级高清视频 | 色图插插插 | 免费麻豆国产一区二区三区四区 | 久久综合久久综合久久 | 777米奇影视第四色 五月丁香久久婷婷 | 国产精品视频免费看 | 亚洲一一在线 | 亚洲中文字幕无码一区二区三区 | 亚洲成人精 | 国产中文网 | 一区二区三区四区不卡 | 人人爱人人艹 | 亚洲av男人的天堂在线观看 | 在线成人免费观看 | 国产精品一区二区av白丝下载 | 青青操影院 | 亚洲精品资源在线 | 欧美精品第二页 | 台湾佬中文字幕 | 一女被多男玩喷潮视频 | 日本视频免费在线播放 | 我的公把我弄高潮了视频 | 中文无码日韩欧 | 久久成年网 | 午夜视频在线观看视频 | 久久国产精品久久久久久电车 | 奇米777狠狠 | 炕上如狼似虎的呻吟声 | 极品少妇视频 | 欧美日韩不卡在线 | 51精产品一区一区三区 | av在线免播放器 | 丰满双乳秘书被老板狂揉捏 | 精品亚洲一区二区三区四区五区高 | 嫩草网站在线观看 | 一级毛毛片 | 欧美激情15p| 欧美日韩欧美日韩在线观看视频 | 亚洲视频色 | 天海翼av在线 | 九月婷婷色| 人人澡人人干 | 日韩成人在线视频 | 久久精品久久国产 | 国产精品国色综合久久 | 欧美日韩黄色一区二区 | 好吊妞无缓冲视频观看 | 绿帽在线| 欧美激情视频在线 | 欧美日本综合 | 亚洲欧美日本国产 | 蜜桃av噜噜一区二区三区小说 | 欧美性猛交xxx乱大交3蜜桃 | 黄色免费在线视频 | 久久精品国产久精国产 | 日啪 | 国产乱子伦农村叉叉叉 | 亚欧美视频 | 国产精品白浆一区二小说 | 久久六六 | 伊人影院中文字幕 | 牛牛影视一区二区三区 | 黄91在线观看| 国产一区二区中文字幕 | 在线观看亚洲国产 | 欧美成人播放 | 中文字幕在线观看日韩 | 国产精品麻豆视频 | 色日韩 | 天天操网站 | 黑帮大佬和我的365日第二部 | 男女久久久 | 欧洲av无码放荡人妇网站 | 在线观看二区 | 国产日韩一区二区三区 | 色就是色欧美 | 黄色av片三级三级三级免费看 | 99在线免费观看 | 亚洲福利网 | 东京久久| 国产日本视频 | 精品国产一区二区三区久久久蜜月 |