基于Android的五子棋游戏设计

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
<ImageView android:id="@+id/menu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/menu" android:layout_x="55px" android:layout_y="10px"
1
1 开发概述
在手机游戏的早期,大多数开发者都是想要玩转设备、学习技巧和快速攻关 的狂热分子。但是,随着更多的开发者加入这个行业,手机游戏已经进化成涉及 到专业设计师、构造师、开发者、产品经销商、律师、和艺术家在内的主导产品。 这是行业走向成熟的必然趋势。尽管在某人的业余时间内要开发和推销简单的游 戏更加困难,但是更多的专业商店将为许多人提供更多的就业机会。
2 相关技术概念
本章节主要介绍一下此论文中用到了的 Android 的布局文件,可视化控件 以及它们的具体实现。
2.1 坐标布局(Absoluteຫໍສະໝຸດ Baiduayout)
坐标布局(AbsoluteLayout)的子控件需要指定相对与此坐标布局的横、纵 坐标的值,将会想 FrameLayout 那样被排在左上角。
项目中进入游戏的布局文件代码如下:
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:color/black">
2.1 坐标布局(AbsoluteLayout) ...........................................................................................2 2.2 相关的算法研究................................................................................................................3
} 以数组形式画棋盘: 画棋盘 private List<Line> lines = new ArrayList<Line>(); private void drawChssboardLines(Canvas canvas){ for (Line line : lines) {
canvas.drawLine(line.xStart, line.yStart, line.xStop, line.yStop, paint);
2.2 相关的算法研究
2.2.1 相关的数据结构
关于盘面情况的表示,首先得到屏幕的大小,然后根据所画棋子的大小来确定下一条棋 盘的画线。
产生棋盘上所有的线 private void createLines(){ for (int i = 0; i <= maxX; i++) {//竖线
lines.add(new Line(xOffset+i*pointSize-pointSize/2, yOffset, xOffset+i*pointSize-pointSize/2, yOffset+maxY*pointSize));
} }
2.2.2 分析规则
判断各个四个方向的棋子:
在某个方向(八个中的一个)可下多少棋子,这个方法是第一分析中的核心方法 private void countPoint(List<Point> myPoints, List<Point> enemyPoints, Point point, FirstAnalysisResult fr,int direction,boolean forward) {
/> <Button
android:id="@+id/b1"
2
android:layout_width="110px" android:layout_height="40px" android:layout_x="100px" android:layout_y="150px" android:text="新游戏" /> <Button android:id="@+id/b3" android:layout_width="110px" android:layout_height="40px" android:layout_x="100px" android:layout_y="200px" android:text="帮助" /> <Button android:id="@+id/b4" android:layout_width="110px" android:layout_height="40px" android:layout_x="100px" android:layout_y="250px" android:text="关于" /> <Button android:id="@+id/b5" android:layout_width="110px" android:layout_height="40px" android:layout_x="100px" android:layout_y="300px" android:text="退出" /></AbsoluteLayout>
} 3
for (int i = 0; i <= maxY; i++) {//横线 lines.add(new Line(xOffset, yOffset+i*pointSize-pointSize/2,
xOffset+maxX*pointSize, yOffset+i*pointSize-pointSize/2)); }
五子棋手机游戏开发
专 业:软件工程 班 级:1221808 姓 名:曾庆鹏 学 号: 201220180806
2015 年 5 月 16 日
目录
1 开发概述.......................................................................................................................................2 2 相关技术概念................................................................................................................................2
2.2.1 相关的数据结构......................................................................................................3 2.2.2 分析规则..................................................................................................................4 2.2.3 胜负判断..................................................................................................................6 2.2.4 算法实现描述..........................................................................................................6 3.各个模块的截图 ............................................................................................................................ 9 3.1 游戏主界面........................................................................................................................9 3.2 新游戏界面.......................................................................................................................10 3.3 帮助界面..........................................................................................................................10 3.4 关于五子棋介绍界面...................................................................................................... 11 3.5 五子棋的退出..................................................................................................................12 4 总结 .............................................................................................................................................12 参考文献......................................................................................................................................... 13 附录 ................................................................................................................................................14
if(myPoints.contains(pointToNext(point,direction,forward))){ fr.count ++;
}else if(enemyPoints.contains(point) || isOutSideOfWall(point,direction)){
fr.aliveState=HALF_ALIVE; } }else if(enemyPoints.contains(point) || isOutSideOfWall(point,direction)){ fr.aliveState=HALF_ALIVE; } }else if(enemyPoints.contains(point) || isOutSideOfWall(point,direction)){ fr.aliveState=HALF_ALIVE; } }else if(enemyPoints.contains(point) || isOutSideOfWall(point,direction)){ fr.aliveState=HALF_ALIVE; 4
if(myPoints.contains(pointToNext(point,direction,forward))){ fr.count ++; if(myPoints.contains(pointToNext(point,direction,forward))){ fr.count ++; if(myPoints.contains(pointToNext(point,direction,forward))){ fr.count ++;
相关文档
最新文档