-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ayajirin
committed
Jun 2, 2020
1 parent
b219def
commit be275ee
Showing
115 changed files
with
2,796 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_251"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>BubbleGame</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,44 @@ | ||
# BubbleGame | ||
Java实现的泡泡堂小游戏 | ||
## 运行环境 | ||
|
||
- 开发环境:Eclipse + OracleJDK 1.8 | ||
- 运行环境:OracleJRE 1.8 | ||
- 机器环境:Intel i7-8750H @ 2.20GHz,内存16G | ||
|
||
运行前需要确保bubblegame.jar文件、pic文件夹和sound文件夹在同一目录下。 | ||
注意,游戏分辨率固定为$ 1000\times800 $,运行前需确保窗口分辨率足够大。 | ||
|
||
## 基本功能实现 | ||
|
||
- 游戏基本功能:开始游戏、暂停/继续游戏,结束游戏。 | ||
- 游戏生成:游戏地图生成,游戏角色初始位置随机。 | ||
- 游戏规则:满足泡泡爆炸连锁规则,道具拾取与使用规则,人物移动与死亡规则(为方便AI实现,仅支持整数格子行走)。 | ||
- 难度选择:开始界面可以选择三种难度进行游戏。 | ||
- 美观度:使用PS设计UI。 | ||
- 用户交互:允许使用键盘和鼠标进行交互。 | ||
- 系统流畅性:通过双缓冲技术和多线程编程,在实机测试下无明显停顿,流畅运行。 | ||
- 系统稳定性:游戏稳定运行,不发生崩溃事件。 | ||
- 实验报告:无。 | ||
|
||
## 附加功能实现 | ||
|
||
- AI对战:本游戏每一局支持1个玩家与3个电脑玩家同时对战。电脑AI具有自动躲避炸弹,自动放炸弹,自动拾取道具的功能。使得游戏不再枯燥。 | ||
- 背景音乐:游戏增添了背景音乐。 | ||
- 简略动画:为了游戏体验的丰富性,游戏中的人物与道具都有最基本的动画变化。 | ||
|
||
其中,AI的实现思想如下: | ||
通过在每一个时刻,用BFS方法找寻人物可达的格点,并通过给予每个格点打分,来决定下一步的策略。目前的策略优先度是从大到小是: | ||
|
||
1. 若在炸弹范围内,逃命 | ||
2. 拾取道具,道具优先级分别为:生命药水>炸弹>威力药水 | ||
3. 炸箱子 | ||
4. 炸人 | ||
5. 无所事事 | ||
|
||
## 使用流程 | ||
|
||
双击Jar包运行游戏。在游戏界面选择难度。进入游戏过程后,通过WASD或者方向键来控制人物行走,使用空格键来放置炸弹。 | ||
|
||
若要使用道具,需将鼠标以至屏幕下方的道具处单击(双击)使用。单机左下角暂停键可暂停游戏,并选择返回标题或继续游戏。 | ||
|
||
当游戏胜利或失败时,切换至相应界面,并可返回标题界面重新开始。 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
package UI; | ||
|
||
import java.awt.Dimension; | ||
import java.awt.EventQueue; | ||
import java.awt.Graphics; | ||
import java.awt.Image; | ||
import java.awt.event.KeyAdapter; | ||
import java.awt.event.KeyEvent; | ||
import java.awt.event.MouseAdapter; | ||
import java.awt.event.MouseEvent; | ||
|
||
import javax.swing.JFrame; | ||
import javax.swing.JPanel; | ||
|
||
import game.SceneManager; | ||
import scene.Scene; | ||
import javax.swing.*; | ||
|
||
public class MainUI { | ||
|
||
private JFrame frame; | ||
private JPanel panel; | ||
//private BufferedImage buf_image = new BufferedImage(SceneManager.GAME_SOLUTION_X, SceneManager.GAME_SOLUTION_Y, BufferedImage.TYPE_4BYTE_ABGR); | ||
|
||
/** | ||
* Launch the application. | ||
*/ | ||
public static void main(String[] args) { | ||
EventQueue.invokeLater(new Runnable() { | ||
public void run() { | ||
try { | ||
MainUI window = new MainUI(); | ||
SceneManager sceneManager = SceneManager.getInstance(); | ||
window.frame.setVisible(true); | ||
(new Thread() { | ||
@Override | ||
public void run() { | ||
sceneManager.init(window.panel, 60); | ||
sceneManager.start(); | ||
} | ||
}).start(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Create the application. | ||
*/ | ||
public MainUI() { | ||
initialize(); | ||
} | ||
|
||
/** | ||
* Initialize the contents of the frame. | ||
*/ | ||
private void initialize() { | ||
frame = new JFrame(); | ||
frame.setTitle("泡泡堂小游戏"); | ||
frame.setResizable(false); | ||
|
||
frame.setBounds(100, 100, 1000, 792); | ||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
frame.getContentPane().setLayout(null); | ||
frame.getContentPane().setPreferredSize(new Dimension(SceneManager.GAME_SOLUTION_X, SceneManager.GAME_SOLUTION_Y)); | ||
frame.pack(); | ||
// System.out.println(frame.getContentPane().getSize()); | ||
|
||
panel = (new JPanel() { | ||
@Override | ||
public void paint(Graphics g) { | ||
// 双缓冲 | ||
Image buf_image = createImage(SceneManager.GAME_SOLUTION_X, SceneManager.GAME_SOLUTION_Y); | ||
Graphics g2 = buf_image.getGraphics(); | ||
// g2.clearRect(0, 0, SceneManager.GAME_SOLUTION_X, SceneManager.GAME_SOLUTION_Y); | ||
SceneManager.getInstance().paint(g2); | ||
g.drawImage(buf_image, 0, 0, SceneManager.GAME_SOLUTION_X, SceneManager.GAME_SOLUTION_Y, null); | ||
} | ||
}); | ||
frame.addKeyListener(new KeyAdapter() { | ||
@Override | ||
public void keyPressed(KeyEvent e) { | ||
switch (e.getKeyCode()) { | ||
case KeyEvent.VK_W: | ||
case KeyEvent.VK_UP: | ||
SceneManager.getInstance().getAttribute().setKeyPressed(Scene.KEY_UP); | ||
break; | ||
case KeyEvent.VK_S: | ||
case KeyEvent.VK_DOWN: | ||
SceneManager.getInstance().getAttribute().setKeyPressed(Scene.KEY_DOWN); | ||
break; | ||
case KeyEvent.VK_A: | ||
case KeyEvent.VK_LEFT: | ||
SceneManager.getInstance().getAttribute().setKeyPressed(Scene.KEY_LEFT); | ||
break; | ||
case KeyEvent.VK_D: | ||
case KeyEvent.VK_RIGHT: | ||
SceneManager.getInstance().getAttribute().setKeyPressed(Scene.KEY_RIGHT); | ||
break; | ||
case KeyEvent.VK_SPACE: | ||
SceneManager.getInstance().getAttribute().setKeyPressed(Scene.KEY_SPACE); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
@Override | ||
public void keyReleased(KeyEvent e) { | ||
switch (e.getKeyCode()) { | ||
case KeyEvent.VK_W: | ||
case KeyEvent.VK_UP: | ||
SceneManager.getInstance().getAttribute().setKeyReleased(Scene.KEY_UP); | ||
break; | ||
case KeyEvent.VK_S: | ||
case KeyEvent.VK_DOWN: | ||
SceneManager.getInstance().getAttribute().setKeyReleased(Scene.KEY_DOWN); | ||
break; | ||
case KeyEvent.VK_A: | ||
case KeyEvent.VK_LEFT: | ||
SceneManager.getInstance().getAttribute().setKeyReleased(Scene.KEY_LEFT); | ||
break; | ||
case KeyEvent.VK_D: | ||
case KeyEvent.VK_RIGHT: | ||
SceneManager.getInstance().getAttribute().setKeyReleased(Scene.KEY_RIGHT); | ||
break; | ||
case KeyEvent.VK_SPACE: | ||
SceneManager.getInstance().getAttribute().setKeyReleased(Scene.KEY_SPACE); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
}); | ||
panel.addMouseListener(new MouseAdapter() { | ||
@Override | ||
public void mouseClicked(MouseEvent e) { | ||
if (e.getButton() == MouseEvent.BUTTON1) { | ||
SceneManager.getInstance().getAttribute().setMouseClickEvent(e.getX(), e.getY()); | ||
} | ||
} | ||
}); | ||
panel.setBounds(0, 0, SceneManager.GAME_SOLUTION_X, SceneManager.GAME_SOLUTION_Y); | ||
frame.getContentPane().add(panel); | ||
} | ||
public JPanel getPanel() { | ||
return panel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package game; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.Image; | ||
import java.awt.image.BufferedImage; | ||
import java.awt.*; | ||
|
||
public class BgMap { | ||
|
||
private Image background; | ||
|
||
public Image getBackground() { | ||
return this.background; | ||
} | ||
|
||
public static BgMap createNewMap() { | ||
BgMap bgMap = new BgMap(); | ||
ResourceLoader rsc = SceneManager.getInstance().getResourceLoader(); | ||
Image bg1 = rsc.getResource("item_bg1"); | ||
BufferedImage bg = new BufferedImage(StuffManager.DRAWRECT.width, StuffManager.DRAWRECT.height, BufferedImage.TYPE_4BYTE_ABGR); | ||
Graphics g = bg.getGraphics(); | ||
for (int i = 0;i < StuffManager.GRID_COUNT_X;++i) { | ||
int offset_x = i * StuffManager.GRID_WIDTH; | ||
for (int j = 0;j < StuffManager.GRID_COUNT_Y;++j) { | ||
g.drawImage(bg1, offset_x, j * StuffManager.GRID_HEIGHT, StuffManager.GRID_WIDTH, StuffManager.GRID_HEIGHT, null); | ||
} | ||
} | ||
bgMap.background = bg; | ||
return bgMap; | ||
} | ||
|
||
} |
Oops, something went wrong.