基于JavaAWT组件的推箱子游戏设计与实现
摘 要
社会在进步,人们生活质量也在日益提高。高强度的压力也接踵而来。社会中急需出现新的有效方式来缓解人们的压力。此次设计符合了社会需求,Java推箱子游戏可以让人们在闲暇之余,体验游戏的乐趣。具有操作简单,易于上手的特点。
推箱子游戏的玩法十分简单——控制人物绕过障碍物,到达目的地。此次毕业设计基于Java语言。将游戏地图做成通用的关卡设计,关卡用二维数组实现,在二维数组中设置值域来表示不同对象,运用二维数组的遍历算法来加载对应图片实现了游戏图片初始化状态。同时,通过初始化多个不同二维数组实现了游戏地图关卡的设计,方法巧妙且简单易行,有效的解决了图片排布问题。充分运用类和方法的调用来实现游戏关卡的初始化。用读取键值的方法判断游戏人物移动、停止、到达目的地。舒缓的音乐配合有趣的步骤,相信能引起很多人的兴趣。作为一个具有悠久历史的游戏,也能够引起人的怀念和共鸣。
关键词 Java 游戏 二维数组 算法 读取键值 栈
Sokoban based on Java
Abstract
Social progress, quality of life is also increasing. High-intensity pressure also follows. The emergence of new social urgently needed an effective way to relieve people's stress. This is designed to meet the needs of the community, Java Sokoban game allows people in her spare time, experience the fun of the game. With simple operation, easy to use features.
Sokoban game’s rule is very simple - control characters around obstructions, to arrive at the destination. The graduation project is based on Java language. Game map to make a generic level design, level with two-dimensional array implementation, set the domain in a two-dimensional array to represent different objects, using the two-dimensional array of times calendar calculation method is realized to load the corresponding picture game image initialized state. At the same time, through the initialization of several different two-dimensional arrays realized the design of the game map level, a method is clever and simple, easy to effectively solve the problem of the picture arrangement. Make full use of calling classes and methods to implement the initialization of the game levels with reading the key value method to judge the characters move, stop, or reaching its destination. Soothing music with interesting step, which will hopefully lead to a lot of people's interest. As a game with a long history, but also can cause people to miss and resonance.
Key Words: Java game; two-dimensional arrays; algorithm; key value method; stack;
目 录
摘 要 i
Abstract ii
引 言 1
1 系统分析 2
1.1 技术可行性分析 2
1.1.1 可行性目的 2
1.1.2 可行性研究前提 2
1.1.3 算法可行性分析 2
1.1.4 平台选择 6
1.2 需求分析 6
1.2.1 引言 6
1.2.2 游戏需求 6
1.2.3 软硬件需求 9
1.2.4 接口控制 10
1.3 方案论证 10
1.3.1 C++语言的优点 10
1.3.2 Java语言的优点 11
1.3.3 C语言的优点 13
1.3.4 方案选择 14
2 概要设计 16
2.1 游戏设计分析 16
2.1.1 地图文件的引用 18
2.1.2 程序运逻辑 19
2.1.3 绘图 20
2.1.4 显示平台 22
2.2 注意事项 24
2.3 游戏流程图 24
2.4 函数模型 25
3 详细设计 28
3.1 游戏总体结构与代码 28
3.2 选关模块 29
3.3 地图的绘制形成 30
3.4 小人与箱子移动的算法 31
3.5 小人上下移动模块 33
3.6 悔棋模块 34
3.7 音乐控制 35
4 游戏测试 38
4.1 软件测试 38
4.1.1 软件测试简介 38
4.2 测试方法 38
4.3 测试步骤 38
4.4 游戏系统性能分析 41
5 项目经验与总结 42
6 参考文献 44
7 致谢 45
8 外文原文及中文翻译 46