《嵌入式系统导论》课程设计-小游戏之小鸡快跑.doc_第1页
《嵌入式系统导论》课程设计-小游戏之小鸡快跑.doc_第2页
《嵌入式系统导论》课程设计-小游戏之小鸡快跑.doc_第3页
《嵌入式系统导论》课程设计-小游戏之小鸡快跑.doc_第4页
《嵌入式系统导论》课程设计-小游戏之小鸡快跑.doc_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

嵌入式系统导论嵌入式系统导论课程设课程设 计计 名称 小游戏之小鸡快跑 姓名 院系电气工程系 班级电子二班 学号 时间2014 年 12 月 19 日 1 目录目录 设计目的-3 设计器件-3 设计步骤-3 仿真步骤与结果-3 1.小鸡行走-6 2.小鸡停止下坠-6 设计程序(部分)-7 1. 计时器程序-7 2. 操作程序-8 3. 行走路径程序-9 4.主程序-12 总结-15 2 设计目的:设计目的: 通过过此次实验,让大家更熟 visual studio 软件的使用。同时通过小组 讨论的方式,增强大家的沟通、合作能力。学会在遇到问题时与他人协作的能 力。 设计设计器件:器件: 计算机一台 visual studio 软件 设计设计步骤:步骤: 1. 确立题目,选择方向 2. 进行编写程序 3. 打开 visual studio 软件,加载程序 4. 点击运行按钮,进行软件的仿真 5. 根据仿真结果进行调试 仿真步骤与结果:仿真步骤与结果: 步骤一 3 步骤二 步骤三 4 步骤四 步骤五 5 小鸡行走: 6 小鸡停止下坠: 7 实验程序(部分) 计时器程序 namespace chickrun partial class form1 / / private system.componentmodel.icontainer components = null; / / / protected override void dispose(bool disposing) if (disposing base.dispose(disposing); #region windows private void initializecomponent() ponents = new system.componentmodel.container(); this.picturebox1 = new system.windows.forms.picturebox(); this.timer1 = new system.windows.forms.timer(ponents); (system.componentmodel.isupportinitialize)(this.picturebox1).begininit(); this.suspendlayout(); / / picturebox1 / this.picturebox1.dock = system.windows.forms.dockstyle.fill; this.picturebox1.location = new system.drawing.point(0, 0); this.picturebox1.name = “picturebox1“; this.picturebox1.size = new system.drawing.size(530, 346); this.picturebox1.tabindex = 0; this.picturebox1.tabstop = false; this.picturebox1.mouseclick += new system.windows.forms.mouseeventhandler(this.picturebox1_mouseclick); 8 this.picturebox1.paint += new system.windows.forms.painteventhandler(this.picturebox1_paint); / / timer1 / this.timer1.tick += new system.eventhandler(this.timer1_tick); / / form1 / this.autoscaledimensions = new system.drawing.sizef(6f, 12f); this.autoscalemode = system.windows.forms.autoscalemode.font; this.clientsize = new system.drawing.size(530, 346); this.controls.add(this.picturebox1); this.name = “form1“; this.text = “form1“; this.load += new system.eventhandler(this.form1_load); this.keyup += new system.windows.forms.keyeventhandler(this.form1_keyup); this.keydown += new system.windows.forms.keyeventhandler(this.form1_keydown); (system.componentmodel.isupportinitialize)(this.picturebox1).endinit(); this.resumelayout(false); #endregion private system.windows.forms.picturebox picturebox1; private system.windows.forms.timer timer1; 操作程序: using system; using system.collections.generic; using system.text; using system.drawing; namespace chickrun public class chick 9 public float g = 150.0f; public float speedx; public float speedy = 100.0f; public float dt = 0.1f; public bool isruning = false; public bool isjumping = false; public bool isspeeding = false; public bool isfalling = false; public bitmap bmp; public chick() using (bitmap bmpt = (bitmap)bitmap.fromfile(“chick.png“) bmp = bmpt.clone() as bitmap; public void update() if (!isruning) return; if (isspeeding) this.point.x += (int)(speedx *2) * dt+0.9); else this.point.x += (int)(speedx * dt+0.9); if (isjumping | isfalling) this.point.y += (int)(-speedy * dt+0.9); speedy -= (int)(g * dt); public point point; 行走路径程序: using system; using system.collections.generic; using system.text; using system.drawing; namespace chickrun 10 public class road static random rand = new random(); public int itemlen; public list landbmp = new list(); public road(int itemnum, int itemlen) if (itemlen public class roaditem public int angle; public int length; public int type;/0为空,1为陆地 public roaditem(int angle, int length) this.angle = angle; this.length = length; public point start; public point end; public int gety(int x) roaditem item = this;/ roaditemsi; float k = (x - item.start.x) / (float)(item.end.x - item.start.x); int y = item.start.y + (int)(k * (item.end.y - item.start.y)+0.9); return y; public int imageindex = 0; 主程序 using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; 13 namespace chickrun public partial class form1 : form public form1() initializecomponent(); scene sc; private void form1_load(object sender, eventargs e) sc = new scene(picturebox1 .size); sc.statechange += new statechange(sc_statechange); sc.refresh(); void sc_statechange(int v,float p) if (v = 1) this.text=“跳起“; else if (v = 2) jumpnum = 0; this.text = “落到地面“; else if (v = 3) this.text = “正在下落“; else if (v = 4) this.text = “行走“; else if (v = 5) this.text = “下坠“; else if (v = 6) this.text = “停止下坠game over“; else if (v = 7) this.text = “停止,到达终点“; this.text+=“+(int)(p*100)+“%“; private void picturebox1_paint(object sender, painteventargs e) if (sc = null) return; e.graphics.drawimage(sc.bitmap, new point(0, 0); 14 private void picturebox1_mouseclick(object sender, mouseeventargs e) timer1.enabled = !timer1.enabled; if (timer1.enabled) sc.chick.isruning = true; private void timer1_tick(object sender, eventargs e) sc.refresh(); picturebox1.refresh(); int jumpnum = 0; private void form1_keydown(object sender, keyeventargs e) if (e.keydata = keys.space) if (sc.currentroadsindex + 1 = sc.road.roaditems.count) return; jumpnum+; if (jumpnum 2) return; sc.chick.speedy = 150; sc.chick.isjumping = true; else if (e.keydata = keys.s) if (sc.chick.isruning) sc.chick.isspeeding = true; /+5+1+a+s+p+x private void form1_keyup(object sender, keyeventargs e) if (e.keydata = keys.s) if (sc.chick.isruning) sc.chick.isspeeding = false; 15 总结:总结: 众所周知,arm 微处理器功能特别的强大,与 mc51 单片机相比,它更适合做中高端数字 系统的微处理器,arm 已经成了现代主流微处理器内核,目前,绝大多数码产品,如,手机, mp3,mp4,数码相机,他们的系统都嵌 入了 arm系列内核, arm 微处理器更新换代很快, 现在的诺基亚 n 系列智 能手机如 n78,n79 已经采用了 arm11 了,使得运行于塞班操作 系统 s60 第 三版的应用程序流畅自如,基于 arm的强大功能,我们没有理由不学 arm,而 我们现在学的仅仅是 arm7 或 lpc2000 系列的一点皮毛,有大把知识需 要自学才能掌握, 兴趣是最好的老师,只要你爱 arm,arm 也会爱你

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论