小游戏之小鸡快跑游戏设计.docx

上传人:b****8 文档编号:27672387 上传时间:2023-07-03 格式:DOCX 页数:19 大小:191.16KB
下载 相关 举报
小游戏之小鸡快跑游戏设计.docx_第1页
第1页 / 共19页
小游戏之小鸡快跑游戏设计.docx_第2页
第2页 / 共19页
小游戏之小鸡快跑游戏设计.docx_第3页
第3页 / 共19页
小游戏之小鸡快跑游戏设计.docx_第4页
第4页 / 共19页
小游戏之小鸡快跑游戏设计.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

小游戏之小鸡快跑游戏设计.docx

《小游戏之小鸡快跑游戏设计.docx》由会员分享,可在线阅读,更多相关《小游戏之小鸡快跑游戏设计.docx(19页珍藏版)》请在冰豆网上搜索。

小游戏之小鸡快跑游戏设计.docx

小游戏之小鸡快跑游戏设计

 

《嵌入式系统导论》课程设计

 

名称

小游戏之小鸡快跑

姓名

院系

电气工程系

班级

电子二班

学号

时间

2014年12月19日

 

目录

设计目的------------------------------------------------3

设计器件------------------------------------------------3

设计步骤------------------------------------------------3

仿真步骤与结果------------------------------------------3

1.小鸡行走------------------------------------------6

2.小鸡停止下坠---------------------------------------6

设计程序(部分)-----------------------------------------------7

1.计时器程序-------------------------------------------------7

2.操作程序---------------------------------------------------8

3.行走路径程序-----------------------------------------------9

4.主程序-----------------------------------------------------12

总结-----------------------------------------------------------15

 

设计目的:

通过过此次实验,让大家更熟visualstudio软件的使用。

同时通过小组讨论的方式,增强大家的沟通、合作能力。

学会在遇到问题时与他人协作的能力。

设计器件:

计算机一台visualstudio软件

设计步骤:

1.确立题目,选择方向

2.进行编写程序

3.打开visualstudio软件,加载程序

4.点击运行按钮,进行软件的仿真

5.根据仿真结果进行调试

 

仿真步骤与结果:

 

步骤一

步骤二

步骤三

步骤四

步骤五

 

小鸡行走:

 

小鸡停止下坠:

 

实验程序(部分)

 

计时器程序

namespaceChickRun

{

partialclassForm1

{

///

///

privateSystem.ComponentModel.IContainercomponents=null;

///

///

///protectedoverridevoidDispose(booldisposing)

{

if(disposing&&(components!

=null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#regionWindows

privatevoidInitializeComponent()

{

ponents=newSystem.ComponentModel.Container();

this.pictureBox1=newSystem.Windows.Forms.PictureBox();

this.timer1=newSystem.Windows.Forms.Timer(ponents);

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();

this.SuspendLayout();

//

//pictureBox1

//

this.pictureBox1.Dock=System.Windows.Forms.DockStyle.Fill;

this.pictureBox1.Location=newSystem.Drawing.Point(0,0);

this.pictureBox1.Name="pictureBox1";

this.pictureBox1.Size=newSystem.Drawing.Size(530,346);

this.pictureBox1.TabIndex=0;

this.pictureBox1.TabStop=false;

this.pictureBox1.MouseClick+=newSystem.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick);

this.pictureBox1.Paint+=newSystem.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);

//

//timer1

//

this.timer1.Tick+=newSystem.EventHandler(this.timer1_Tick);

//

//Form1

//

this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);

this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize=newSystem.Drawing.Size(530,346);

this.Controls.Add(this.pictureBox1);

this.Name="Form1";

this.Text="Form1";

this.Load+=newSystem.EventHandler(this.Form1_Load);

this.KeyUp+=newSystem.Windows.Forms.KeyEventHandler(this.Form1_KeyUp);

this.KeyDown+=newSystem.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

this.ResumeLayout(false);

}

#endregion

privateSystem.Windows.Forms.PictureBoxpictureBox1;

privateSystem.Windows.Forms.Timertimer1;

}

}

 

操作程序:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

usingSystem.Drawing;

namespaceChickRun

{

publicclassChick

{

publicfloatg=150.0f;

publicfloatspeedX;

publicfloatspeedY=100.0f;

publicfloatdt=0.1f;

publicboolIsRuning=false;

publicboolIsJumping=false;

publicboolIsSpeeding=false;

publicboolIsFalling=false;

publicBitmapbmp;

publicChick()

{

using(Bitmapbmpt=(Bitmap)Bitmap.FromFile("chick.png"))

{

bmp=bmpt.Clone()asBitmap;

}

}

publicvoidUpdate()

{

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);

}

}

publicPointpoint;

}

}

 

行走路径程序:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

usingSystem.Drawing;

namespaceChickRun

{

publicclassRoad

{

staticRandomrand=newRandom();

publicintItemLen;

publicListlandbmp=newList();

publicRoad(intitemnum,intitemlen)

{

if(itemlen<2)

thrownewException();

this.ItemLen=itemlen;

RoadItemitem00=newRoadItem(0,this.ItemLen);

item00.imageIndex=0;

item00.type=1;

_roads.Add(item00);

for(inti=0;i

{

inttemp=rand.Next(0,3);

intindex=0;

intang=0;

if(temp==0)

{

ang=-20;

index=2;

}

elseif(temp==1)

{

ang=0;

index=0;

}

else

{

ang=20;

index=1;

}

RoadItemitem=newRoadItem(ang,this.ItemLen);

if(rand.Next(0,4)==1)

item.type=0;

else

item.type=1;

item.imageIndex=index;

_roads.Add(item);

}

RoadItemitem11=newRoadItem(0,this.ItemLen);

item11.imageIndex=0;

item11.type=1;

_roads.Add(item11);

for(inti=0;i<_roads.Count;i++)

{

RoadItemitem=_roads[i];

if(i==0)

item.start=newPoint(0,100);

else

item.start=_roads[i-1].end;

item.end=newPoint(item.start.X+item.length,item.start.Y+(int)(Math.Tan(item.angle*Math.PI/180)*item.length+0.9));

}

using(Imagebmp1=Image.FromFile("land0.png"))

{

landbmp.Add(bmp1.Clone()asImage);

}

using(Imagebmp2=Image.FromFile("land20.png"))

{

landbmp.Add(bmp2.Clone()asImage);

}

using(Imagebmp3=Image.FromFile("land-20.png"))

{

landbmp.Add(bmp3.Clone()asImage);

}

}

//publicintGetY(intx)

//{

//inti=x/ItemLen;

//inty=0;

//if(i+1

//{

//RoadItemitem=RoadItems[i];

//floatk=(x-item.start.X)/(float)(item.end.X-item.start.X);

//y=item.start.Y+(int)k*(item.end.Y-item.start.Y);

//}

//returny;

//}

RoadItems_roads=newRoadItems();

publicRoadItemsRoadItems

{

get

{

return_roads;

}

}

}

publicclassRoadItems:

List

{

}

publicclassRoadItem

{

publicintangle;

publicintlength;

publicinttype;//0为空,1为陆地

publicRoadItem(intangle,intlength)

{

this.angle=angle;

this.length=length;

}

publicPointstart;

publicPointend;

publicintGetY(intx)

{

RoadItemitem=this;//RoadItems[i];

floatk=(x-item.start.X)/(float)(item.end.X-item.start.X);

inty=item.start.Y+(int)(k*(item.end.Y-item.start.Y)+0.9);

returny;

}

publicintimageIndex=0;

}

}

 

主程序

usingSystem;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

usingSystem.Data;

usingSystem.Drawing;

usingSystem.Text;

usingSystem.Windows.Forms;

namespaceChickRun

{

publicpartialclassForm1:

Form

{

publicForm1()

{

InitializeComponent();

}

Scenesc;

privatevoidForm1_Load(objectsender,EventArgse)

{

sc=newScene(pictureBox1.Size);

sc.StateChange+=newStateChange(sc_StateChange);

sc.Refresh();

}

voidsc_StateChange(intv,floatp)

{

if(v==1)

this.Text="跳起";

elseif(v==2)

{

jumpNum=0;

this.Text="落到地面";

}

elseif(v==3)

this.Text="正在下落";

elseif(v==4)

this.Text="行走";

elseif(v==5)

this.Text="下坠";

elseif(v==6)

this.Text="停止下坠gameover";

elseif(v==7)

this.Text="停止,到达终点";

this.Text+="["+(int)(p*100)+"%]";

}

privatevoidpictureBox1_Paint(objectsender,PaintEventArgse)

{

if(sc==null)

return;

e.Graphics.DrawImage(sc.bitmap,newPoint(0,0));

}

privatevoidpictureBox1_MouseClick(objectsender,MouseEventArgse)

{

timer1.Enabled=!

timer1.Enabled;

if(timer1.Enabled)

sc.chick.IsRuning=true;

}

privatevoidtimer1_Tick(objectsender,EventArgse)

{

sc.Refresh();

pictureBox1.Refresh();

}

intjumpNum=0;

privatevoidForm1_KeyDown(objectsender,KeyEventArgse)

{

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;

}

elseif(e.KeyData==Keys.S)

{

if(sc.chick.IsRuning)

sc.chick.IsSpeeding=true;

}

}

//+5+1+a+s+p+x

privatevoidForm1_KeyUp(objectsender,KeyEventArgse)

{

if(e.KeyData==Keys.S)

{

if(sc.chick.IsRuning)

sc.chick.IsSpeeding=false;

}

}

}

}

 

总结:

众所周知,ARM微处理器功能特别的强大,与MC51单片机相比,它更适合做中高端数字系统的微处理器,ARM已经成了现代主流微处理器内核,目前,绝大多数码产品,如,手机,MP3,MP4,数码相机,他们的系统都嵌入了ARM系列内核,ARM微处理器更新换代很快,现在的诺基亚N系列智能手机如N78,N79已经采用了ARM11了,使得运行于塞班操作系统S60第三版的应用程序流畅自如,基于ARM的强大功能,我们没有理由不学ARM,而我们现在学的仅仅是ARM7或LPC2000系列的一点皮毛,有大把知识需要自学才能掌握,兴趣是最好的老师,只要你爱ARM,ARM也会爱你的,通过这次实验的设计,我们对ARM有了以下的了解:

1,初步了解了LPC2138系列的硬件结构;

2,了解了LPC2138引脚的大致功能;

3,掌握GPIO口;

4,相关寄存器的名称和使用功能;

5,熟悉基于C语言的ARM初始化程序和功能模块编程;

6,掌握PWM的初始化及歌曲简谱节拍和音乐输出实验程序的编写。

但是在完成这次实验的时候,由于对ADS软件不熟悉和对C语言掌握不够牢固,我们遇到了很多的困难,有时一个小问题都会让我们抓狂郁闷很久。

但正是这种经历,让我们更好地掌握了自学能力,也学会了运用团队的力量,在今后的学习中,我们会扬长避短,争取做得更好

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 电力水利

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1