logo资料库

Android开发期末报告.doc

第1页 / 共10页
第2页 / 共10页
第3页 / 共10页
第4页 / 共10页
第5页 / 共10页
第6页 / 共10页
第7页 / 共10页
第8页 / 共10页
资料共10页,剩余部分请下载后查看
《Java 及手机 APP 开发》期末考核报告 《Java 及手机 APP 开发》期末考核报告 年级、专业、班级 2017 级 材加 2 班 学号 20172813 姓名 陈梓欣 软件名称 flyingball 提交时间 2018.12.7 成绩 学年学期 2018-2019(1) 软件类型 游戏 期末考核报告目的 1. 通过开发一个小软件考核学生是否掌握本课程的教学内容,即主要的 Android 开发技术,包括常用组件的使用。要求程序要有必要的注释。能 够正常执行,没有大错误。 2. 通过撰写文档考核学生是否能够介绍和阐述所开发的软件。 (提交的时候把所开发的程序源代码进行压缩成 ZIP 格式。命名为:学号 姓名.zip, 和报告分别进行提交。) 报告内容 一、软件设计意图与功能介绍、特色 此软件为游戏,通过点击屏幕控制小球上下移动来障碍物。 二、运行结果截图
《Java 及手机 APP 开发》期末考核报告
《Java 及手机 APP 开发》期末考核报告
《Java 及手机 APP 开发》期末考核报告 三、运行环境(SDK 版本,Graddle 版本,Android Studio 版本和其他辅助 Sdk:28 gradle:4.4 as:3.1.2
《Java 及手机 APP 开发》期末考核报告 四、程序组织结构说明(说明软件有哪些 Activity 或者其他组件,哪些辅助 类,哪些资源文件构成,各有什么作用或者相互关系。) 两个 activity,一个 button MainActivety:游戏开始前的界面,有一个 button 控件,点击 button 跳转 到 StarGame activity,此 activity 为游戏见面 五、源代码罗列(包括 AndroidManifest.xml, 主要的 Activity 源代码(有注 释),资源文件) AndroidManifest.xml:
《Java 及手机 APP 开发》期末考核报告 主要的 Activity 源代码: public class MainActivity extends AppCompatActivity { Button bnt; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bnt = findViewById(R.id.button); bnt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setClass(MainActivity.this,StarGame.class); startActivity(intent); } }); } } public class StarGame extends AppCompatActivity { private int iWindowHeight;//桌面高度 int iWindowWidth;//桌面宽度 //小球的变量 float fBallSize = 16;//小球大小 float fBallSpeed = 3;//小球速度 float fBallRise = 120;//小球上升的像素 float fBallX;//小球的 X 坐标 float fBallY;//小球的 Y 坐标 //柱子的变量,两根柱子 float fPillarHeight ;//高 float fPillarHeight2 ;//高 2 float fPillarWidth = 80;//宽为 80 float fPillarWidth2 = 80; float fPillarX;//柱子的 X 坐标 float fPillarY;//柱子的 Y 坐标 float fPillarX2;//柱子的 X 坐标 float fPillarY2;//柱子的 Y 坐标 float fPillarSpeed;//柱子的速度 int iScore = 0;//分数,即小球通过的柱子数 boolean flag = false;//游戏结束的一个旗标 MyGameView myGameView;
《Java 及手机 APP 开发》期末考核报告 @Override protected void onCreate(Bundle savedInstanceState) { Intent intent = getIntent(); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //程序全屏运行 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutPar ams.FLAG_FULLSCREEN); //获取游戏视图的实例 myGameView = new MyGameView(this); setContentView(myGameView); //获取窗口的一个管理器 WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); //获取屏幕的宽和高 iWindowWidth = metrics.widthPixels; iWindowHeight = metrics.heightPixels; Play(); } @SuppressLint("ClickableViewAccessibility") public void Play(){ flag = false; //设置两根柱子的初始位置 fPillarX = iWindowWidth - fPillarWidth; fPillarY = 0; fPillarX2 = iWindowWidth - fPillarWidth2; fPillarY2 = iWindowHeight; fPillarHeight = iWindowHeight/2 - 200; fPillarHeight2 = iWindowHeight - fPillarHeight - 200; iScore = 0; fPillarSpeed = 5; myGameView.setOnTouchListener(gesture); fBallX = 50; fBallY = iWindowHeight/2; fBallSpeed = 3f; fBallRise = 90; handler.sendEmptyMessage(0x123); Timer timer = new Timer(); timer.schedule(new TimerTask() {
《Java 及手机 APP 开发》期末考核报告 @Override public void run() { //设置小球跟柱子的坐标 fBallY = fBallY + fBallSpeed; fPillarX = fPillarX - fPillarSpeed; fPillarX2 = fPillarX2 - fPillarSpeed; //如果柱子碰到屏幕边缘 if(fPillarX<=0){ fPillarX = iWindowWidth - fPillarWidth; fPillarX2 = iWindowWidth - fPillarWidth2; iScore++; } //判断小球是否碰到屏幕边缘 if((fBallY-iWindowHeight)>=0||fBallY<=0){ flag = true; } else if(fBallX>=fPillarX){ if(fBallYfPillarHeight2){ flag = true; } } handler.sendEmptyMessage(0x123); } },0,15); } View.OnTouchListener gesture = new View.OnTouchListener(){ @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event){ switch (event.getAction()){ case MotionEvent.ACTION_DOWN: fBallY = fBallY - fBallRise; handler.sendEmptyMessage(0x123); break; } return true; } }; @SuppressLint("HandlerLeak") Handler handler = new Handler(){ @Override public void handleMessage(Message msg){ super.handleMessage(msg);
分享到:
收藏