基于ANDROID的简单扫雷小游戏.doc

上传人:b****9 文档编号:117113 上传时间:2022-10-03 格式:DOC 页数:33 大小:2.32MB
下载 相关 举报
基于ANDROID的简单扫雷小游戏.doc_第1页
第1页 / 共33页
基于ANDROID的简单扫雷小游戏.doc_第2页
第2页 / 共33页
基于ANDROID的简单扫雷小游戏.doc_第3页
第3页 / 共33页
基于ANDROID的简单扫雷小游戏.doc_第4页
第4页 / 共33页
基于ANDROID的简单扫雷小游戏.doc_第5页
第5页 / 共33页
点击查看更多>>
下载资源
资源描述

基于ANDROID的简单扫雷小游戏.doc

《基于ANDROID的简单扫雷小游戏.doc》由会员分享,可在线阅读,更多相关《基于ANDROID的简单扫雷小游戏.doc(33页珍藏版)》请在冰豆网上搜索。

基于ANDROID的简单扫雷小游戏.doc

大庆师范学院

《ANDROID应用设计》

课程设计报告

题目:

基于ANDROID的简单扫雷小游戏

专业班级:

计算机科学与技术(嵌入式方向)

设计者:

王珂:

201101041172

王盼盼:

201101041173

赵玉莹:

201101041183

刘阳:

201101041184

李若男:

201101041185

指导老师:

许有军

设计时间:

2013-2014

(1)

报告完成日期2013年12月20日

一.设计任务及要求(小三黑体)(段前0.5行,段后0.5行,下同)

1、设计任务

(1)系统会在雷区的某些小方框中随机布小若干个地雷。

安放地雷的小方块称之为雷方块,其他的称之为非雷方块。

部署完毕后,系统会在其他非雷方块中填充一些数字,某一个具体数字代表与其紧邻的8个方块中有多少个雷方块。

(2)游戏人可以根据

(1)中的信息去判断是否可以打开某些方块,并把认为是地雷的方块打上标识。

(3)游戏开始后,雷区上方有两个计数器。

左边的计数器显示用户扫雷所花的总时间,以秒为单位,

(4)当玩家将所有的地雷找出后,其余的地雷方块区都已打开,此时游戏结束。

(5)在游戏的过程中,一旦错误的打开了雷方块则立即失败,游戏结束。

2、设计要求

能够运用android语言设计出扫雷游戏的程序,会搭建android开发环境;

会创建自己的android项目生成的文件之间的关系和他们的作用,会使用各种控件;

能够对程序进行调试并学会修改其中的错误。

3、任务分配

王珂:

王盼盼;

赵玉莹:

刘阳:

李若男:

二.设计原理及总体框图

×××××××××(小4号宋体,1.5倍行距)××××××××××××××××××××………

1、实现原理:

扫雷是一个简单的单人游戏,游戏的目的实在没有触碰任何一个地雷的情形下清空一个雷区。

在扫雷游戏中,游戏者。

2、设计的总体框图:

包括在此说明设计的总体框图及实现原理

三.程序设计

1、程序分析

游戏界面设计:

在main.xml中加入三个TableRow,将整体界面划分为三个部分。

第一个TableRow中加入两个textview(Timer和MineCount),分别用来显示玩游戏话费的时间(以秒为单位)和雷方块的个数。

再加入一个button(Smiley),用来显示图片。

第二个TableRow中加入一个textview,用来将第一个部分和第二个部分分开。

第三个TableRow中加入一个TableLayout(MineField),用来显示扫雷区的框架。

程序的class类:

Blocked.Java和MinesweeperGame.java

程序的主要函数:

游戏开始函数:

startNewGame();

游戏显示函数:

showMineFiled();

创建新游戏函数:

createMineFiled();

完成游戏函数:

finishGame();

设置时间函数:

setmines();

玩家胜利函数:

winGame();

玩家失败函数:

endExistingGame();

2、程序详解

(1)游戏开始函数startNewGame

privatevoidstartNewGame()

{

//plantminesanddorestofthecalculations

createMineField();

//displayallblocksinUI

showMineField();

minesToFind=totalNumberOfMines;

isGameOver=false;

secondsPassed=0;

}

privatevoidshowMineField()

{

//rememberwewillnotshow0thandlastRowandColumns

//theyareusedforcalculationpurposesonly

for(introw=1;row

{

TableRowtableRow=newTableRow(this);

tableRow.setLayoutParams(newLayoutParams((blockDimension+2*blockPadding)*numberOfColumnsInMineField,blockDimension+2*blockPadding));

for(intcolumn=1;column

{

blocks[row][column].setLayoutParams(newLayoutParams(

blockDimension+2*blockPadding,

blockDimension+2*blockPadding));

blocks[row][column].setPadding(blockPadding,blockPadding,blockPadding,blockPadding);

tableRow.addView(blocks[row][column]);

}

mineField.addView(tableRow,newTableLayout.LayoutParams(

(blockDimension+2*blockPadding)*numberOfColumnsInMineField,blockDimension+2*blockPadding));

}

}

privatevoidendExistingGame()

{

stopTimer();//stopiftimerisrunning

txtTimer.setText("000");//revertalltext

txtMineCount.setText("010");//revertminescount

btnSmile.setBackgroundResource(R.drawable.smile);

//removeallrowsfrommineFieldTableLayout

mineField.removeAllViews();

//setallvariablestosupportendofgame

isTimerStarted=false;

areMinesSet=false;

isGameOver=false;

minesToFind=0;

}

privatevoidcreateMineField()

{

//wetakeonerowextrarowforeachside

//overalltwoextrarowsandtwoextracolumns

//firstandlastrow/columnareusedforcalculationspurposesonly

// x|xxxxxxxxxxxxxx|x

// ------------------

// x||x

// x||x

// ------------------

// x|xxxxxxxxxxxxxx|x

//therowandcolumnsmarkedasxarejustusedtokeepcountsofnearbymines

blocks=newBlock[numberOfRowsInMineField+2][numberOfColumnsInMineField+2];

for(introw=0;row

{

for(intcolumn=0;column

{

blocks[row][column]=newBlock(this);

blocks[row][column].setDefaults();

//passcurrentrowandcolumnnumberasfinalint'stoeventlisteners

//thiswaywecanensurethateacheventlistenerisassociatedto

//particularinstanceofblockonly

finalintcurrentRow=row;

finalintcurrentColumn=column;

//addClickListener

//thisistreatedasLeftMouseclick

blocks[row][column].setOnClickListener(newOnClickListener()

{

@Override

publicvoidonClick(Viewview)

{

//starttimeronfirstclick

if(!

isTimerStarted)

{

startTimer();

isTimerStarted=true;

}

//setminesonfirstclick

if(!

areMinesSet)

{

areMinesSet=true;

setMines(currentRow,currentColumn);

}

//thisisnotfirstclick

//checkifcurrentblockisflagged

//ifflaggedthedon'tdoanything

//asthatoperationishandledbyLongClick

//ifblockisnotflaggedthenuncovernearbyblocks

//tillwegetnumberedmines

if(!

blocks[currentRow][currentColumn].isFlagged())

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1