《嵌入式系统导论》课程设计小游戏之小鸡快跑.doc
《《嵌入式系统导论》课程设计小游戏之小鸡快跑.doc》由会员分享,可在线阅读,更多相关《《嵌入式系统导论》课程设计小游戏之小鸡快跑.doc(15页珍藏版)》请在三一办公上搜索。
1、嵌入式系统导论课程设计名称 小游戏之小鸡快跑姓名院系电气工程系班级电子二班学号时间2014年12月19日目录设计目的-3设计器件-3设计步骤-3仿真步骤与结果-3 1.小鸡行走-62.小鸡停止下坠-6设计程序(部分)-71. 计时器程序-72. 操作程序-8 3. 行走路径程序-94.主程序-12总结-15设计目的:通过过此次实验,让大家更熟visual studio软件的使用。同时通过小组讨论的方式,增强大家的沟通、合作能力。学会在遇到问题时与他人协作的能力。设计器件:计算机一台 visual studio软件设计步骤:1. 确立题目,选择方向2. 进行编写程序3. 打开visual stu
2、dio软件,加载程序4. 点击运行按钮,进行软件的仿真5. 根据仿真结果进行调试仿真步骤与结果:步骤一步骤二步骤三步骤四步骤五 小鸡行走:小鸡停止下坠:实验程序(部分)计时器程序namespace ChickRun partial class Form1 / / private System.ComponentModel.IContainer components = null; / / / protected override void Dispose(bool disposing) if (disposing & (components != null) components.Dispos
3、e(); 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.pictureBo
4、x1).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
5、= 0; this.pictureBox1.TabStop = false; this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick); this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint); / / timer1 / this.timer1.Tick += new System.EventHandler(this.t
6、imer1_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
7、.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
8、 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 public float g = 150.0f; public float speedX; public float speedY = 100.0f; public
9、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) ret
10、urn; 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
11、System.Drawing;namespace ChickRun public class Road static Random rand = new Random(); public int ItemLen; public List landbmp = new List(); public Road(int itemnum, int itemlen) if (itemlen 2) throw new Exception(); this.ItemLen = itemlen; RoadItem item00 = new RoadItem(0,this.ItemLen); item00.imag
12、eIndex = 0; item00.type = 1; _roads.Add(item00); for (int i = 0; i itemnum-2; i+) int temp = rand.Next(0, 3); int index = 0; int ang = 0; if (temp = 0) ang = -20; index = 2; else if (temp = 1) ang = 0; index = 0; else ang = 20; index = 1; RoadItem item = new RoadItem(ang, this.ItemLen); if (rand.Nex
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 嵌入式系统导论 嵌入式 系统 导论 课程设计 小游戏 小鸡 快跑
链接地址:https://www.31ppt.com/p-2392526.html