基于Android的2048游戏开发毕业设计(论文)由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“游戏开发毕业设计论文”。
毕业设计(论文)
基于Android平台2048游戏开发
教学单位:计算机学院
专业名称:软件工程(游戏与数字媒体)学 号:2012031201011 学生姓名:高振东
指导教师:宋喜佳(讲师)指导单位:计算机学院 完成时间:2016年4月30日
电子科技大学中山学院教务处制发
电子科技大学中山学院毕业设计(论文)
摘要
基于Android平台2048游戏开发
【摘要】在生活节奏不断加快的现代社会,轻松的益智游戏对缓解生活压力调节情绪具有重要的意义。《2048》这款小游戏是一款流行的数字游戏。第一款《2048》小游戏是由Gabriele Cirulli首度发布在GitHub上。《2048》是当时基于《1024》和《小三传奇》这两款的玩法而开发的新型数字游戏,而游戏设计初衷是一款益智类的游戏,其特点在于轻松,简单,因此,开发要求做到各项功能要完备、操作要简便、易学易用。现在开发出来的版本有普通版、六边形版、朝代版、3D版、后宫版等等。
本文采用 JAVA语言开发了 2048 小游戏,通过Android平台实现了 2048 的基本运行,本着简单,易于操作的原则和缓解生活压力、降低生活节奏的初衷,游戏中没有繁多的按钮,也不用特别复杂的操作,只需动动手指,即可操纵自如。
游戏经过图形界面的处理,以不同的颜色显示不同的数字,并拥有了最高成绩记录,撤销上一步,重置游戏的各项功能。对于游戏的逻辑实现部分进行测试,测试结果正常,目前没有发现异常。但是游戏界面可能有些简单,日后可以通过美化界面来获得更好的游戏体验。【关键词】游戏;益智;数字
I 电子科技大学中山学院毕业设计(论文)
Abstract Based on the Android platform 2048 game 【Abstract】In the accelerated pace of life in the modern society, easy puzzle game to ease the preure of life.Force, adjust the mood has important meaning “2048” this small game is a popular digital game.The first “2048” small game was released by Cirulli GitHub on Gabriele for the first time.“2048” was based on “1024” and “small three” Legend of the two gameplay and the development of a new type of digital games and game design original intention is a puzzle game, its characteristics is easy and simple, therefore, development.Seeking to achieve the function to complete, easy to operate, Yi Xueyi use.Now developed a version of the ordinary version, hexagonal version, Dynasty version, 3D version, the palace version, etc.The Java language to develop the 2048 small game, 2048, the basic operation is realized through the Android platform, the purpose of simple and easy operation principle and alleviate the preure of life, reduce the original intention of the rhythm of life, the game without different button, also need not particularly complex operations, only need to move a finger, you can maneuverability.Game through the proceing of the graphical interface to display different colors with different numbers, and have the highest score records, undo the last step, reset the function of the game.The logic of the game to achieve part of the test, the test results are normal, there is no abnormal.But the game interface may be a little simple, in the future can be used to beautify the interface to get a better gaming experience.【Key Words】game;puzzle;numbel
II 电子科技大学中山学院毕业设计(论文)
目录
目录
第1章 绪论.............................................................1 1.1 游戏开发背景....................................................1 1.2 国内外研究现状..................................................1 1.3 游戏开发意义....................................................2 1.4 论文结构........................................................2 第2章 相关技术和理论基础...............................................3 2.1 Java语言........................................................3 2.2 Android操作系统.................................................4 2.2.1 简介......................................................4 2.2.2 系统架构..................................................5 2.2.3 Android版本...............................................6 2.3 开发平台介绍....................................................6 2.3.1 Eclipse...................................................6 2.3.2 ADT.......................................................7 2.3.2 JDK.......................................................7 第3章 可行性分析.......................................................8 3.1 可行性研究目的..................................................8 3.1.1 技术可行性................................................8 3.1.2 经济可行性................................................8 3.1.3 操作可行性................................................8 第4章 游戏设计.........................................................9 4.1 游戏规则....................................................9 4.2 总体设计....................................................9 4.3 详细设计...................................................11 第5章 游戏测试........................................................18 5.1测试过程........................................................18 5.2测试内容........................................................18 5.3测试结果........................................................22 第6章 心得体会........................................................23 参考文献...............................................................24 附录 游戏实现代码.....................................................25 致谢...................................................................33
III 电子科技大学中山学院毕业设计(论文)
图目录
图目录
图2.1 Java Logo...................................................................................................3 图2.2 Android Logo.............................................................................................4 图2.3 Android系统架构......................................................................................5 图4.2.1 系统功能.................................................................................................9 图4.2.2 计分显示...............................................................................................10 图4.2.3 游戏内容...............................................................................................10 图4.2.4 游戏菜单...............................................................................................10 图4.2.5 游戏流程................................................................................................11 图4.3.1 游戏主界面...........................................................................................12 图4.3.2 数字合并前...........................................................................................14 图4.3.3 数字合并后...........................................................................................14 图4.3.4 游戏计分...............................................................................................15 图4.3.5 游戏计分...............................................................................................16 图4.3.6 游戏结束...............................................................................................17 图5.2.1 游戏开始...............................................................................................19 图5.2.2 向上滑动...............................................................................................19 图5.2.3 向左滑动...............................................................................................20 图5.2.4 向下滑动...............................................................................................20 图5.2.5 向右滑动...............................................................................................21 图5.2.6 撤销功能...............................................................................................21 图5.2.7 重置功能...............................................................................................22
IV 电子科技大学中山学院毕业设计(论文)
第1章 绪论
第1章 绪论
1.1 游戏开发背景
Android 智能手机功能非常强大,具有很高的性价比,非常深受人们的喜爱,可能正式因为如此,在2014年中,Android 智能手机在全世界占据着81.5%很夸张的市场份额,一举成为使用的人数最多,市场份额占据最大的Android 智能手机系统。
而Android 智能手机游戏的出现正是为了娱乐心神,并且随着智能移动终端和全球移动通信网络的不断进步,Android 智能手机游戏也正在经历从简单到复杂的进化过程。从全球来看,智能移动终端的娱乐服务一直被认为是带动移动数据业务加速并快速发展的重要力量。也是作为手机娱乐服务的重要内容之一。近年来,一直伴随着全球移动网络和移动终端性能不断的提高和完善。
由于近几年来,Android智能手机游戏的快速发展,游戏的分类也变得越来越丰富,目前手机游戏按内容可分为:角色扮演类(RPG)、冒险类(AVG)、格斗类(FTG)、棋牌类、电影改版类、益智类、体育竞技类、模拟类。手机游戏种类目前已成为人类线上娱乐生活的不可或缺的最主流的载体而存在,现代人对于移动终端的休闲娱乐功能所需求越来越强大,移动终端上的游戏或已以成为了现代人们娱乐生活中不可或缺的一部分了。
1.2 国内外研究现状
基于Android的游戏开发,国内国外的水平差距很大。在市场上成名的手机游戏基本上都是国外游戏公司开发的,而且很容易辨认。因为学习的关系,本人接触了很多Android开发者的游戏,发现国内开发者开发的Android手机游戏,不仅界面粗糙,而且设计简单,同质化严重,相同的创意往往被反复抄袭很多次。而国外开发者开发的游戏不同,大型游戏内容丰富,情节完整;小型游戏而从用户体验和创意上远胜国内的开发者。电子科技大学中山学院毕业设计(论文)
第1章 绪论
1.3 游戏开发意义
此次毕业设计的初衷就是想设计出一个能够在任何环境任何时间都能够放松心情和娱乐心身的单机游戏,只要通过简单和易操作的Android游戏帮助手机用户来打发他们闲暇的时间,并娱乐心身和放松心情。
如果你也是一个数字叠加的爱好者,或者是比较有天赋的数学天才,不过就算不是数学的天才,一般的玩家也能够玩转这款游戏,都会有很大的成功机会。当你体会过这款游戏,你就会被这游戏深深的吸引,根本停不下来。
1.4 论文结构
本论文主要从下面几章阐述对于Android 2048游戏的研究与应用:
第 1 章:绪论,介绍了课题的研究背景、国内外研究现状,课题研究目的和意义、以及本文的结构。
第 2 章:相关开发技术与理论基础,介绍了课题采用的Android操作系统等相关技术。
第 3 章:可行性分析,对Android 2048游戏进行可行性分析。总体介绍了程序的设计架构及所要实现的功能分析,并阐述了开发平台和环境的选择。
第 4 章:系统详细设计与实现,介绍了程序各个模块的功能分析以及设计思路并其相关实现代码。
第 5 章:系统应用实例和结果分析,介绍了应用平台,测试用例以及结果分析。
第 6 章:心得体会,总结本文工作成果,并对研究工作做反思和总结 电子科技大学中山学院毕业设计(论文)
第2章 相关技术和理论基础
第2章 相关技术和理论基础
2.1 Java语言
Java语言的前身是Sun Microsystems公司开发的一种用于智能化家电的名为Oak(橡树)的语言,它的基础是当时最流行的C和C++语言(Sun公司于2009年4月被Oracle公司收购)。但是,由于一些非技术上的原因,Oak语言并没有得到迅速的推广。知道1993年,www.daodoc.com/,2010-07-26 /2014-12-25.[10] zyq0335.activity之间的数据传递方法
.http://blog.csdn.net/zyq0335/ article/details/ s7636724,2012-06-06 /2014-12-25.电子科技大学中山学院毕业设计(论文)
附录
附录 游戏实现代码
/**
* 用于获取移动方向上下一个格子的位置
* @param index
当前格子的位置
* @param direction 滑动方向
* @return 如果在边界在返回-1 */ public int getNext(int index,int direction){
} /** * 用于获取移动方向上前一个格子的位置
* @param index
当前格子的位置
* @param direction 滑动方向
* @return 如果在边界在返回-1 */ public int getBefore(int index,int direction){
int y = index/4;int x = index%4;
if(x==3 && direction==RIGHT)
return-1;return-1;return-1;return-1;
if(x==0 && direction==LEFT)if(y==0 && direction==UP)if(y==3 && direction==DOWN)return index+direction;电子科技大学中山学院毕业设计(论文)
附录
} /**
int y = index/4;int x = index%4;
if(x==0 && direction==RIGHT)
return-1;return-1;return-1;return-1;
if(x==3 && direction==LEFT)if(y==3 && direction==UP)if(y==0 && direction==DOWN)return index-direction;* 该方法用来交换当前格与目标空白格的位置
* @param thisIdx 当前格子的坐标
* @param nextIdx 目标空白格的坐标
*/ public void replace(int thisIdx, int nextIdx){
moved = true;//获取当前格子的view,并将其置成空白格 View thisView = gridLayout.getChildAt(thisIdx);ImageView image =(ImageView)thisView.findViewById(R.id.image);image.setBackgroundResource(icons[0]);
//获取空白格的view,并将其背景置成当前格的背景 View nextView = gridLayout.getChildAt(nextIdx);ImageView
nextImage
=
(ImageView)nextView.findViewById(R.id.image);电子科技大学中山学院毕业设计(论文)
附录);nextImage.setBackgroundResource(icons[numberList.getNumberByIndex(thisIdx)]
} * 刚方法用于合并在移动方向上两个相同的格子
* @param thisIdx 当前格子的坐标
* @param nextIdx 目标格子的坐标
*/ public void levelup(int thisIdx, int nextIdx){
//在空白格列表中,去掉目标格,加上当前格 spaceList.remove(spaceList.indexOf(nextIdx));spaceList.add(thisIdx);
//在数字格列表中,当前格的坐标置换成目标格的坐标 numberList.changeIndex(thisIdx, nextIdx);/**
//一次移动中,每个格子最多只能升级一次 if(!changeList.contains(nextIdx)){
moved = true;//获取当前格子的view,并将其置成空白格 View thisView = gridLayout.getChildAt(thisIdx);ImageView
image
=
(ImageView)thisView.findViewById(R.id.image);image.setBackgroundResource(icons[0]);
//获取目标格的view,并将其背景置成当前格升级后的背景 View nextView = gridLayout.getChildAt(nextIdx);ImageView
nextImage
=
(ImageView)nextView.findViewById(R.id.image);
nextImage.setBackgroundResource(icons[numberList.getNumberByIndex(nextIdx)电子科技大学中山学院毕业设计(论文)
附录
+1]);
} * 该方法,为每个符合条件的格子执行变动的操作,如置换,升级等
* @param thisIdx
当前格子的坐标
* @param direction
滑动方向
*/ public void Change(int thisIdx,int direction){
if(numberList.contains(thisIdx)){
int nextIdx = getLast(thisIdx, direction);if(nextIdx == thisIdx){
//不能移动 return;//存在可以置换的空白格
//在空白格列表中加入当前格 spaceList.add(thisIdx);//在数字列中删掉第一个格子 numberList.remove(thisIdx);//将数字列表对应的内容升级 numberList.levelup(nextIdx);
changeList.add(nextIdx);
//更新分数
updateScore((int)Math.pow(2, numberList.getNumberByIndex(nextIdx)));} /** }else if(spaceList.contains(nextIdx)){ 电子科技大学中山学院毕业设计(论文)
附录
}
}
} replace(thisIdx,nextIdx);
== if(numberList.getNumberByIndex(thisIdx)
}
//可以合并
levelup(thisIdx, nextIdx);
int before = getBefore(nextIdx, direction);if(before!= thisIdx){
}
//存在可以置换的空白格 replace(thisIdx,before);}else{
numberList.getNumberByIndex(nextIdx)){ }else{ /**
* 用于获取移动方向上最后一个空白格之后的位置
* @param index
当前格子的坐标
* @param direction 移动方向
* @return */ public int getLast(int thisIdx, int direction){
int nextIdx = getNext(thisIdx, direction);if(nextIdx
return thisIdx;if(spaceList.contains(nextIdx))return getLast(nextIdx, direction);return nextIdx;else{ else } 电子科技大学中山学院毕业设计(论文)
附录
} /**
* 该方法为不同的滑动方向,执行不同的遍历顺序
* @param direction 滑动方向
*/ public void move(int direction){
moved = false;
changeList.clear();
switch(direction){ case RIGHT:
for(int y=0;y
} break;for(int y=0;y
} break;for(int x=0;x
for(int y=1;y
int thisIdx = 4*y +x;Change(thisIdx,direction);for(int x=2;x>=0;x--){
}
int thisIdx = 4*y +x;Change(thisIdx,direction);case LEFT: for(int x=1;x
}
int thisIdx = 4*y +x;Change(thisIdx,direction);case UP: 电子科技大学中山学院毕业设计(论文)
附录
}
} } } break;
for(int x=0;x
} break;for(int y=2;y>=0;y--){
}
int thisIdx = 4*y +x;Change(thisIdx,direction);case DOWN: //如果本次滑动有格子移动过,则随机填充新的格子 if(moved)
if(spaceList.size()==0){
} if(!numberList.hasChance())over();History history = new History(spaceList, numberList, score);historyStack.push(history);System.out.println(“历史轨迹压入栈中
”);history.printLog();addRandomItem();/**
* 根据参数重绘界面
* @param spaceList
空白格列表
* @param numberList
数字格列表
* @param score
当前分数
电子科技大学中山学院毕业设计(论文)
附录
score){
} */ public void drawViews(List spaceList, NumberList numberList, int
} else image.setBackgroundResource(icons[0]);gridLayout.addView(view);
if(numberList.contains(i))scoreText.setText(score+“”);gridLayout.removeAllViews();for(int i=0;i
View view = View.inflate(this, R.layout.item, null);ImageView image =(ImageView)view.findViewById(R.id.image);image.setBackgroundResource(icons[numberList.getNumberByIndex(i)]);
电子科技大学中山学院毕业设计(论文)
致谢
致谢
此论文能够顺利完成,离不开给予我无私帮助的老师、同学、家人,以及网上为我解答困惑的网友们。
感谢我的导师,宋喜佳老师,虽然接触的时间不是很长,但是在学习Android程序的路上给了我无私的关怀和指导。由于未接触过Java相关知识,在开发Android程序时处处碰壁,遇到需求,不能及时反应出解决方案,只有不断地求助于我的导师——宋喜佳老师,给了功能设计思路,让我成功地克服一个又一个的困难。在此,谨向送老师表示衷心的敬意和感谢。
同时,非常感谢我的室友李朗和刘雨坤,在论文编写和毕业设计的制作过程中,给予我鼓励和关怀,提出了许多宝贵意见和建议,再次深表感谢。
最后,特别感谢我的家人,感谢他们在精神上和物质上给予我无私的鼓励和支持,使我能够顺利完成论文,和学业,我将永记他们的付出并用一生来回报他们。