基于Android系统的连连看详细设计说明书.doc

上传人:土8路 文档编号:10274345 上传时间:2021-05-04 格式:DOC 页数:15 大小:727KB
返回 下载 相关 举报
基于Android系统的连连看详细设计说明书.doc_第1页
第1页 / 共15页
基于Android系统的连连看详细设计说明书.doc_第2页
第2页 / 共15页
基于Android系统的连连看详细设计说明书.doc_第3页
第3页 / 共15页
基于Android系统的连连看详细设计说明书.doc_第4页
第4页 / 共15页
基于Android系统的连连看详细设计说明书.doc_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《基于Android系统的连连看详细设计说明书.doc》由会员分享,可在线阅读,更多相关《基于Android系统的连连看详细设计说明书.doc(15页珍藏版)》请在三一文库上搜索。

1、基于Android系统的连连看详细设计说明书引言1.1、编写目的本文档用于说明本游戏开发的详细过程,使委托方了解软件的内部结构,从而对连连看有更深入的了解,便于后期的维护和修改工作。1.2、背景说明:a 待开发软件系统的名称:基于Android系统的连连看游戏设计b 本项目的任务提出者:学校开发者:游戏开发小组用户:喜欢玩游戏的人项目开发环境:eclipse、Android系统平台1.3、定义Android 连连看 详细设计1.4、参考资料 Android开发指南Eoeandroid开发论坛2、程序系统的结构 连连看游戏结构如下:连连看消息响应设计算法设计界面设计菜单设计绘图响应时间响应画线设

2、计消除算法设计鼠标响应进度条设计框架设计结束游戏规则说明游戏设置开始游戏主要有四个大类:class GameView /游戏视类,搭建游戏基框架Class BoardView /游戏视类 处理游戏中的情况,包括界面生成,算法,一部分消息响应。Class SoundPlay /用于处理游戏中的音乐播放class DotaActivity /用于处理游戏中的消息提示class GameSetDialog /用于菜单的设计,游戏难度的设定等Class DotaDialog /处理游戏结束对话框事件 3、菜单设计说明3.1、程序描述 主要功能:用于为玩家提供操作提示,便于玩家了解游戏的规则。 可扩展性

3、:能够适应应用要求的变化和修改,具有灵活的可扩充性。3.2、功能开始界面,有开始游戏,设置游戏难度功能游戏设置框3.3、性能 当用户选择菜单时能够快速反应,以满足用户的要求。3.4、输人项用户点击按钮3.5、输出项 4个菜单选项3.6、算法 /定义菜单类,接口为OnClickListener,用于接收用户的单击消息。public class GameSetDialog extends Dialog implements OnClickListenerprivate GameView gameview;private Context context;private RadioButton rad

4、ioButton_pt;private RadioButton radioButton_yg;private RadioButton radioButton_hs;private RadioButton radioButton_music;private Button button_ok;private Button button_cancle;private TextView textView;private boolean music_set = true;public GameSetDialog(Context context, GameView gameview) super(cont

5、ext);this.gameview = gameview;this.context = context;this.setContentView(R.layout.game_set);radioButton_pt = (RadioButton) findViewById(R.id.RadioButton_PT);/普通难度radioButton_yg = (RadioButton) findViewById(R.id.RadioButton_YG);/中等难度radioButton_hs = (RadioButton) findViewById(R.id.RadioButton_HS);/苦难

6、难度radioButton_music = (RadioButton) findViewById(R.id.RadioButton_Music);/音乐状态button_ok = (Button)findViewById(R.id.set_ok);button_cancle = (Button) findViewById(R.id.set_cancle);textView = (TextView)findViewById(R.id.text_message);radioButton_pt.setOnClickListener(this);radioButton_yg.setOnClickLis

7、tener(this);radioButton_hs.setOnClickListener(this);radioButton_music.setOnClickListener(this);button_ok.setOnClickListener(this);button_cancle.setOnClickListener(this);this.setCancelable(false);Overridepublic void onClick(View v) / this.dismiss();switch(v.getId()case R.id.RadioButton_PT:if (radioBu

8、tton_pt.isChecked() textView.setText(当前难度你有3次帮助机会);break;case R.id.RadioButton_YG:if (radioButton_yg.isChecked() textView.setText(当前难度你有1次帮助机会);break;case R.id.RadioButton_HS:if (radioButton_hs.isChecked() textView.setText(当前难度你有0次帮助机会);break;case R.id.RadioButton_Music:if (radioButton_music.isCheck

9、ed() & music_set = true) radioButton_music.setText(音乐状态(关闭));music_set = false; else if (music_set = false & radioButton_music.isChecked() radioButton_music.setText(音乐状态(开启));music_set = true;break;case R.id.set_cancle:this.dismiss();return;case R.id.set_ok:if (radioButton_pt.isChecked() /Toast.make

10、Text(context, pt, Toast.LENGTH_SHORT).show();gameview.setHelpTimes(3); else if (radioButton_yg.isChecked()/Toast.makeText(context, yao, Toast.LENGTH_SHORT).show();gameview.setHelpTimes(1); else if (radioButton_hs.isChecked() gameview.setHelpTimes(0);Toast.makeText(context, hs, Toast.LENGTH_SHORT).sh

11、ow(); gameview.setMusicOpen(music_set);this.dismiss();break;3.7、接口API函数3.8、限制条件无明显限制条件4、界面设计说明4.1、程序描述 主要功能:用于为玩家提供可视化的游戏界面,增加了游戏的可玩性。 可扩展性:能够适应应用要求的变化和修改,具有灵活的可扩充性。4.2、功能生成游戏界面,生成进度条。如下图:4.3、性能 能够快速的随机生成符合用户需要的界面4.4、输人项无输入4.5、输出项 游戏界面4.6、算法 /* * 产生随机的图片下标,用于每次产生随机的图片 */private void RandomNum() rand

12、om = new Random();int i = 0;int t;int j;int flag = 0;for (j = 0; j tmp.length; j+) tmpj = 1000000;while (true) t = random.nextInt(totalIcon);for (j = 0; j tmp.length; j+) if (t != tmpj) continue; else flag = 1;if (flag = 1) flag = 0;continue;tmpi = t;i+;if (i = (iconCounts)break;public BoardView(Con

13、text context, AttributeSet atts) super(context, atts);calIconSize();int i;Resources r = getResources();for (i = 0; i totalIcon; i+) myIconi = R.drawable.dota_face1 + i;RandomNum();for (i = 0; i iconCounts; i+) / loadBitmaps(i, r.getDrawable(reArraytmpi);loadBitmaps(i, r.getDrawable(myIcontmpi);/* *

14、* 重新排列 */public void reSetBoardView() Resources r = getResources();RandomNum();int i;for (i = 1; i iconCounts; i+) loadBitmaps(i, r.getDrawable(myIcontmpi);/* * * 计算图标的长宽 */private void calIconSize() DisplayMetrics dm = new DisplayMetrics();(Activity) this.getContext().getWindowManager().getDefaultD

15、isplay().getMetrics(dm);iconSize = dm.widthPixels / (xCount);4.7、接口API函数4.8、限制条件无明显限制条件5、主要算法设计说明5.1、程序描述 主要功能:完成图片的消除功能,消除时画线功能,重新排列功能。 可扩展性:能够适应应用要求的变化和修改,具有灵活的可扩充性。5.2、功能完成连连看游戏的核心算法。5.3、性能 能够快速判断两图片是否能消除,并能在消除时进行画线操作。隔一段时间,能够打乱顺序进行重新排列。5.4、输人项用户点击、时间条5.5、输出项 消除匹配的图片5.6、算法 List p1E = new ArrayLis

16、t();List p2E = new ArrayList();private boolean link(Point p1, Point p2) if (p1.equals(p2) return false;path.clear();if (mapp1.xp1.y = mapp2.xp2.y) if (linkD(p1, p2) path.add(p1);path.add(p2);return true;Point p = new Point(p1.x, p2.y);if (mapp.xp.y = 0) if (linkD(p1, p) & linkD(p, p2) path.add(p1);p

17、ath.add(p);path.add(p2);return true;p = new Point(p2.x, p1.y);if (mapp.xp.y = 0) if (linkD(p1, p) & linkD(p, p2) path.add(p1);path.add(p);path.add(p2);return true;expandX(p1, p1E);expandX(p2, p2E);for (Point pt1 : p1E) for (Point pt2 : p2E) if (pt1.x = pt2.x) if (linkD(pt1, pt2) path.add(p1);path.ad

18、d(pt1);path.add(pt2);path.add(p2);return true;expandY(p1, p1E);expandY(p2, p2E);for (Point pt1 : p1E) for (Point pt2 : p2E) if (pt1.y = pt2.y) if (linkD(pt1, pt2) path.add(p1);path.add(pt1);path.add(pt2);path.add(p2);return true;return false;return false;private boolean linkD(Point p1, Point p2) if

19、(p1.x = p2.x) int y1 = Math.min(p1.y, p2.y);int y2 = Math.max(p1.y, p2.y);boolean flag = true;for (int y = y1 + 1; y y2; y+) if (mapp1.xy != 0) flag = false;break;if (flag) return true;if (p1.y = p2.y) int x1 = Math.min(p1.x, p2.x);int x2 = Math.max(p1.x, p2.x);boolean flag = true;for (int x = x1 +

20、1; x x2; x+) if (mapxp1.y != 0) flag = false;break;if (flag) return true;return false;private void expandX(Point p, List l) l.clear();for (int x = p.x + 1; x = 0; x-) if (mapxp.y != 0) break;l.add(new Point(x, p.y);private void expandY(Point p, List l) l.clear();for (int y = p.y + 1; y = 0; y-) if (

21、mapp.xy != 0) break;l.add(new Point(p.x, y);5.6.2、图片消除的画线Overrideprotected void onDraw(Canvas canvas) /* * 绘制连通路径,然后将路径以及两个图标清除 */if (path != null & path.length = 2) for (int i = 0; i path.length - 1; i+) Paint paint = new Paint();paint.setColor(Color.CYAN);paint.setStyle(Paint.Style.STROKE);paint.s

22、etStrokeWidth(3);Point p1 = indextoScreen(pathi.x, pathi.y);Point p2 = indextoScreen(pathi + 1.x, pathi + 1.y);canvas.drawLine(p1.x + iconSize / 2, p1.y + iconSize / 2, p2.x+ iconSize / 2, p2.y + iconSize / 2, paint);Point p = path0;mapp.xp.y = 0;p = pathpath.length - 1;mapp.xp.y = 0;selected.clear(

23、);path = null;/* * 绘制棋盘的所有图标 当这个坐标内的值大于0时绘制 */for (int x = 1; x map.length; x += 1) for (int y = 0; y 0) Point p = indextoScreen(x, y);canvas.drawBitmap(iconsmapxy, p.x, p.y, null);/* * 绘制选中图标,当选中时图标放大显示 */for (Point position : selected) Point p = indextoScreen(position.x, position.y);if (mappositio

24、n.xposition.y = 1) canvas.drawBitmap(iconsmapposition.xposition.y, null,new Rect(p.x - 5, p.y - 5, p.x + iconSize + 5, p.y+ iconSize + 5), null);5.6.3、重新排列隔一段时间后,将原有的排列随机打乱,进行重新排列/* * 产生随机的图片下标,用于每次产生随机的图片 */private void RandomNum() random = new Random();int i = 0;int t;int j;int flag = 0;for (j = 0

25、; j tmp.length; j+) tmpj = 1000000;while (true) t = random.nextInt(totalIcon);for (j = 0; j tmp.length; j+) if (t != tmpj) continue; else flag = 1;if (flag = 1) flag = 0;continue;tmpi = t;i+;if (i = (iconCounts)break;/* * * 重新排列 */public void reSetBoardView() Resources r = getResources();RandomNum();int i;for (i = 1; i iconCounts; i+) loadBitmaps(i, r.getDrawable(myIcontmpi);5.7、接口API函数5.8、限制条件无明显限制条件 5.9、尚未解决的问题不能进行死锁判断,但是有重新排列的功能,可以很大程度上避免死锁。没有加分功能。没有提示功能。

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

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1