智能终端软件开发_课程设计报告
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
switch (mGameState)
{
case GS_GAME:
mGameMap = new int[CHESS_HEIGHT][CHESS_WIDTH];
mMapHeightLengh = mGameMap.length;
mMapWidthLengh = mGameMap[0].length;
mCampTurn = CAMP_HERO;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
//Download by http://www.codefans.net
import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Window;
private float mTitleSpace = 0;
private int mTitleHeight = 0;
private float mTitleIndex_x = 0;
private float mTitleIndex_y = 0;
Bitmap bitmapBg = null;
Bitmap mBlack = null;
import android.view.WindowManager;
public class FiveChessActivity extends Activity
{
GameView gameView = null;
@Override
public void onCreate(Bundle savedInstanceState)
private int mMapHeightLengh = 0;
private int mMapWidthLengh = 0;
private int mMapIndexX = 0;
private int mMapIndexY = 0;
public int mCampTurn = 0;
public int mCampWinner = 0;
mTitleIndex_x = (float) (mTitleSpace / 2);
mTitleIndex_y = (float) (mTitleSpace / 2);
setGameState(GS_GAME);
}
public void setGameState(int newState)
{
mGameState = newState;
if (CampID == CAMP_HERO)
{
DrawImage(mBlack, x, y, ALIGN_VCENTER | ALIGN_HCENTER);
}
else if (CampID == CAMP_ENEMY)
{
DrawImage(mWhite, x, y, ALIGN_VCENTER | ALIGN_HCENTER);
public static Resources sResources = null;
private int mGameState = 0;
private int mScreenWidth = 0;
private int mScreenHeight = 0;
public int[][] mGameMap = null;
mWhite = BitmapFactory.decodeResource(GameView.sResources, R.drawable.human);
mTitleSpace = (float) mScreenWidth / CHESS_WIDTH;
mTitleHeight = mScreenHeight / 3;
DrawString(Color.WHITE, sResources.getString(mCampWinner) + "胜利点击继续游戏", 50, 50);
break;
}
}
private void RenderMap()
{
int i, j;
DrawImage(bitmapBg, 0, 0, 0);
/**
* @author Administrator
*
*/
public class GameView extends SurfaceView implements Const, SurfaceHolder.Callback, Runnable
{
static GameView sInstance = null;
{
super.onCreate(savedInstanceState);
//隐藏标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
//全屏显示
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
mSurfaceHolder.addCallback(this);
setFocusable(true);
mbLoop = true;
bitmapBg = CreatMatrixBitmap(R.drawable.status, mScreenWidth, mScreenHeight);
mBlack = BitmapFactory.decodeResource(GameView.sResources, R.drawable.ai);
public static void init(Activity mActivity, int screenWidth, int screenHeight)
{
sInstance = new GameView(mActivity, screenWidth, screenHeight);
}
public static GameView getInstance()
一、
1、
按照象棋的表格图案绘制布局,在画布上设计表格,并标记红黑方位置。
2、
标明五子棋的颜色,记录分析棋子的位置,判断是否取胜。
3、
记录红黑双方输赢次数。
二、
1、
判断路径,数据结构算法。
2、
1
分析棋子连线是否可以取胜。
2
棋子之间有三种连线情况,横向连续连接、纵向连续连接、对角线连续连接。
3
将同类棋子之间,有位置关系的棋子进行进栈处理,如果在棋盘范围内,有连续的五个棋子则为取胜。
{
return sInstance;
}
//控制循环
boolean mbLoop = false;
//定义SurfaceHolder对象
SurfaceHolder mSurfaceHolder = null;
public static Paint sPaint = null;
public static Canvas sCanvas = null;
}
private void RenderGame()
{
switch (mGameState)
{
case GS_GAME:
DrawRect(Color.WHITE, 0, 0, mScreenWidth, mScreenHeight);
RenderMap();
break;
case GS_END:
DrawRect(Color.RED, 0, 0, mScreenWidth, mScreenHeight);
sPaint.setAntiAlias(true);
sResources = getResources();
mContext = activity;
mScreenWidth = screenWidth;
mScreenHeight = screenHeight;
mSurfaceHolder = this.getHolder();
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//获取屏幕宽高
Display display = getWindowManager().getDefaultDisplay();
//现实GameView
GameView.init(this, display.getWidth(), display.getHeight());
}
}
2、算法设计
package cn.m.xys;
//Download by http://www.codefans.net
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
Bitmap mWhite = null;
Context mContext = null;
public GameView(Activity activity, int screenWidth, int screenHeight)
{
super(activity);
sPaint = new Paint();
第二部分 设计
一、
软件环境:
Windows
AndroidSDK;
Eclipse(windows版)
环境配置:
Windows下AndroidSDK安装。
安装步骤:
1、下载SDK包,Android-SDK,下载地址:
http://developer.android.com/tools/sdk/ndk/index.html
}
}
}
}
private void DrawRect(int color, int x, int y, int width, int height)
{
sPaint.setColor(color);
for (i = 0; i < mMapHeightLengh; i++)
{
for (j = 0; j < mMapWidthLengh; j++)
{
int CampID = mGameMap[i][j];
float x = (j * mTitleSpace) + mTitleIndex_x;
float y = (i * mTitleSpace) + mTitleHeight + mTitleIndex_y;
gameView = GameView.getInstance();
setContentView(gameView);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
return super.onKeyDown(keyCode, event);
中国地质大Baidu Nhomakorabea(武汉)
智能终端软件开发
标题:智能终端课程设计
指导老师:徐战亚
班级:116101
学号:20101002130
学生:高亚兵
2014年1月13日
摘要
本次课程设计主要内容是双人五子棋游戏的开发。主要内容是界面布局、判断输赢,记录输赢次数。开发想法来源,纯属娱乐。
关键词:益智游戏Android
第一部分
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
break;
}
}
protected void Draw()
{
sCanvas = mSurfaceHolder.lockCanvas();
if (mSurfaceHolder == null || sCanvas == null)
{
return;
}
RenderGame();
mSurfaceHolder.unlockCanvasAndPost(sCanvas);
2、配置SDK
导入sdk文件
二、
1、
背景画布选择恰当,布局清晰,结构清晰,使用简单。
2、
方格大小,连线之间的距离适中,确保棋子在连线上,避免棋子在棋盘上混乱摆放。
3、
出现下棋位置不在棋盘内或者不在合法范围内是出现错误提示
当由一方取得胜利时,出现提示框。
三、
1、布局设计
package cn.m.xys;
{
case GS_GAME:
mGameMap = new int[CHESS_HEIGHT][CHESS_WIDTH];
mMapHeightLengh = mGameMap.length;
mMapWidthLengh = mGameMap[0].length;
mCampTurn = CAMP_HERO;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
//Download by http://www.codefans.net
import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Window;
private float mTitleSpace = 0;
private int mTitleHeight = 0;
private float mTitleIndex_x = 0;
private float mTitleIndex_y = 0;
Bitmap bitmapBg = null;
Bitmap mBlack = null;
import android.view.WindowManager;
public class FiveChessActivity extends Activity
{
GameView gameView = null;
@Override
public void onCreate(Bundle savedInstanceState)
private int mMapHeightLengh = 0;
private int mMapWidthLengh = 0;
private int mMapIndexX = 0;
private int mMapIndexY = 0;
public int mCampTurn = 0;
public int mCampWinner = 0;
mTitleIndex_x = (float) (mTitleSpace / 2);
mTitleIndex_y = (float) (mTitleSpace / 2);
setGameState(GS_GAME);
}
public void setGameState(int newState)
{
mGameState = newState;
if (CampID == CAMP_HERO)
{
DrawImage(mBlack, x, y, ALIGN_VCENTER | ALIGN_HCENTER);
}
else if (CampID == CAMP_ENEMY)
{
DrawImage(mWhite, x, y, ALIGN_VCENTER | ALIGN_HCENTER);
public static Resources sResources = null;
private int mGameState = 0;
private int mScreenWidth = 0;
private int mScreenHeight = 0;
public int[][] mGameMap = null;
mWhite = BitmapFactory.decodeResource(GameView.sResources, R.drawable.human);
mTitleSpace = (float) mScreenWidth / CHESS_WIDTH;
mTitleHeight = mScreenHeight / 3;
DrawString(Color.WHITE, sResources.getString(mCampWinner) + "胜利点击继续游戏", 50, 50);
break;
}
}
private void RenderMap()
{
int i, j;
DrawImage(bitmapBg, 0, 0, 0);
/**
* @author Administrator
*
*/
public class GameView extends SurfaceView implements Const, SurfaceHolder.Callback, Runnable
{
static GameView sInstance = null;
{
super.onCreate(savedInstanceState);
//隐藏标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
//全屏显示
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
mSurfaceHolder.addCallback(this);
setFocusable(true);
mbLoop = true;
bitmapBg = CreatMatrixBitmap(R.drawable.status, mScreenWidth, mScreenHeight);
mBlack = BitmapFactory.decodeResource(GameView.sResources, R.drawable.ai);
public static void init(Activity mActivity, int screenWidth, int screenHeight)
{
sInstance = new GameView(mActivity, screenWidth, screenHeight);
}
public static GameView getInstance()
一、
1、
按照象棋的表格图案绘制布局,在画布上设计表格,并标记红黑方位置。
2、
标明五子棋的颜色,记录分析棋子的位置,判断是否取胜。
3、
记录红黑双方输赢次数。
二、
1、
判断路径,数据结构算法。
2、
1
分析棋子连线是否可以取胜。
2
棋子之间有三种连线情况,横向连续连接、纵向连续连接、对角线连续连接。
3
将同类棋子之间,有位置关系的棋子进行进栈处理,如果在棋盘范围内,有连续的五个棋子则为取胜。
{
return sInstance;
}
//控制循环
boolean mbLoop = false;
//定义SurfaceHolder对象
SurfaceHolder mSurfaceHolder = null;
public static Paint sPaint = null;
public static Canvas sCanvas = null;
}
private void RenderGame()
{
switch (mGameState)
{
case GS_GAME:
DrawRect(Color.WHITE, 0, 0, mScreenWidth, mScreenHeight);
RenderMap();
break;
case GS_END:
DrawRect(Color.RED, 0, 0, mScreenWidth, mScreenHeight);
sPaint.setAntiAlias(true);
sResources = getResources();
mContext = activity;
mScreenWidth = screenWidth;
mScreenHeight = screenHeight;
mSurfaceHolder = this.getHolder();
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//获取屏幕宽高
Display display = getWindowManager().getDefaultDisplay();
//现实GameView
GameView.init(this, display.getWidth(), display.getHeight());
}
}
2、算法设计
package cn.m.xys;
//Download by http://www.codefans.net
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
Bitmap mWhite = null;
Context mContext = null;
public GameView(Activity activity, int screenWidth, int screenHeight)
{
super(activity);
sPaint = new Paint();
第二部分 设计
一、
软件环境:
Windows
AndroidSDK;
Eclipse(windows版)
环境配置:
Windows下AndroidSDK安装。
安装步骤:
1、下载SDK包,Android-SDK,下载地址:
http://developer.android.com/tools/sdk/ndk/index.html
}
}
}
}
private void DrawRect(int color, int x, int y, int width, int height)
{
sPaint.setColor(color);
for (i = 0; i < mMapHeightLengh; i++)
{
for (j = 0; j < mMapWidthLengh; j++)
{
int CampID = mGameMap[i][j];
float x = (j * mTitleSpace) + mTitleIndex_x;
float y = (i * mTitleSpace) + mTitleHeight + mTitleIndex_y;
gameView = GameView.getInstance();
setContentView(gameView);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
return super.onKeyDown(keyCode, event);
中国地质大Baidu Nhomakorabea(武汉)
智能终端软件开发
标题:智能终端课程设计
指导老师:徐战亚
班级:116101
学号:20101002130
学生:高亚兵
2014年1月13日
摘要
本次课程设计主要内容是双人五子棋游戏的开发。主要内容是界面布局、判断输赢,记录输赢次数。开发想法来源,纯属娱乐。
关键词:益智游戏Android
第一部分
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
break;
}
}
protected void Draw()
{
sCanvas = mSurfaceHolder.lockCanvas();
if (mSurfaceHolder == null || sCanvas == null)
{
return;
}
RenderGame();
mSurfaceHolder.unlockCanvasAndPost(sCanvas);
2、配置SDK
导入sdk文件
二、
1、
背景画布选择恰当,布局清晰,结构清晰,使用简单。
2、
方格大小,连线之间的距离适中,确保棋子在连线上,避免棋子在棋盘上混乱摆放。
3、
出现下棋位置不在棋盘内或者不在合法范围内是出现错误提示
当由一方取得胜利时,出现提示框。
三、
1、布局设计
package cn.m.xys;