安卓课程设计报告

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

安卓课程设计报告

设计题目:五子棋

目录

一.需求分析 (2)

二.功能模块 (2)

三. 界面设计 (3)

四. 分工说明 (5)

五. 所遇到的问题 (5)

六.代码注释 (6)

一.需求分析

网络技术的日新月异让世界惊叹,高速发展的网络技术和日渐成熟的3G网络,让越来越多的用户沉浸在手机的世界而无限欢快。不管是逛街、乘地铁,还是吃饭,排队,跟随潮流的时尚一群都利用拇指掌控着周围的一切,似乎只有手机才能让他们真正体验娱乐的极致。手机已然成为本世纪最有作为、最受欢迎的发明。而手机的流行更成就了相关应用和网站,让他们在移动互联网大放异彩的当下备受用户关注。

二.功能模块

三. 界面设计

3.1开始界面

3.2游戏界面

3.3点击认输界面

四. 分工说明

张哲:编辑main代码

刘凯:获取MainAct

丁章华:写报告

黄思淳:程序注释

叶浩:编辑MyView代码

五. 所遇到的问题

1 登录界面的部分功能没有实现。

2 界面的布局没有很清晰。

3 部分代码不够简洁。

六.代码注释

public MyView(Context context,float width,float height) {

super(context);

// TODO Auto-generated constructor stub

this.width=(float) (width);

this.height=(float) (height);

flag=true;

holder=this.getHolder();

this.setFocusable(true);

holder.addCallback(this);

bitmap=BitmapFactory.decodeStream(getResources().openRawResource(R.drawable .chess_2));

chess=new int[9][9];

msg="点击开始";

}

public void myDraw()

{

//获得画布

Canvas canvas=holder.lockCanvas();

//获得画笔

Paint paint=new Paint();

//绘画

paint.setAntiAlias(true);

Matrix matrix=new Matrix();

int ww = bitmap.getWidth();//获取资源位图的宽

int hh = bitmap.getHeight();//获取资源位图的高

float w = (width/(float)ww);

float h = (float) ((height/(float)hh)/1.1);

matrix.postScale(w, h);//获取缩放比例

Bitmap bmp = Bitmap.createBitmap(bitmap, 0, 0, ww, hh, matrix, true);//根据缩放比例获取新的位图

canvas.drawBitmap(bmp, 0, 0, paint); //在屏幕上画出位图

int sx=(int) width;

int sy=(int) (height/1.1);

paint.setColor(Color.BLACK);

//适应屏幕画横线竖线

tempy=(float) ((0.6*sy-(0.6*sy)%8-16)/8);

ax=(sx-tempy*8)/2;

ay=(float) (((0.6*sy)%8)/2)+8;

bx=sx-(sx-tempy*8)/2;

cy=(float) (0.6*sy-((0.6*sy)%8)/2-8);

// System.out.println("MyView:==========="+tempy);

for(int i=0;i<9;i++)

{

canvas.drawLine(ax, ay+tempy*i, bx, ay+tempy*i, paint);

canvas.drawLine(ax+tempy*i, ay, ax+tempy*i, cy, paint);

}

//画棋盘下方现实信息

paint.setColor(Color.BLACK);

paint.setTextSize(30);

// float tx=3*sx/8;

// float ty=(float) (0.75*sy);

canvas.drawText(msg, 3*sx/8-25, (float) (0.72*sy), paint);

canvas.drawText("开始", (float) (0.175*sx), (float) (0.92*sy), paint);

canvas.drawText("认输", (float) (0.425*sx), (float) (0.92*sy), paint);

canvas.drawText("退出", (float) (0.675*sx), (float) (0.92*sy), paint);

//画棋子

int qx,qy;

for(int i=0;i<9;i++)

{

for(int j=0;j<9;j++)

{

//画黑棋

if(chess[i][j]==1)

{

qx=(int) (ax+i*tempy);

qy=(int) (ay+j*tempy);

paint.setColor(Color.BLACK);

canvas.drawCircle(qx, qy, tempy/3, paint);

}

//画白棋

else if(chess[i][j]==2)

{

qx=(int) (ax+i*tempy);

qy=(int) (ay+j*tempy);

paint.setColor(Color.WHITE);

canvas.drawCircle(qx, qy, tempy/3, paint);

}

相关文档
最新文档