C编程结课设计说明书.docx

上传人:b****8 文档编号:9941904 上传时间:2023-05-22 格式:DOCX 页数:31 大小:202.14KB
下载 相关 举报
C编程结课设计说明书.docx_第1页
第1页 / 共31页
C编程结课设计说明书.docx_第2页
第2页 / 共31页
C编程结课设计说明书.docx_第3页
第3页 / 共31页
C编程结课设计说明书.docx_第4页
第4页 / 共31页
C编程结课设计说明书.docx_第5页
第5页 / 共31页
C编程结课设计说明书.docx_第6页
第6页 / 共31页
C编程结课设计说明书.docx_第7页
第7页 / 共31页
C编程结课设计说明书.docx_第8页
第8页 / 共31页
C编程结课设计说明书.docx_第9页
第9页 / 共31页
C编程结课设计说明书.docx_第10页
第10页 / 共31页
C编程结课设计说明书.docx_第11页
第11页 / 共31页
C编程结课设计说明书.docx_第12页
第12页 / 共31页
C编程结课设计说明书.docx_第13页
第13页 / 共31页
C编程结课设计说明书.docx_第14页
第14页 / 共31页
C编程结课设计说明书.docx_第15页
第15页 / 共31页
C编程结课设计说明书.docx_第16页
第16页 / 共31页
C编程结课设计说明书.docx_第17页
第17页 / 共31页
C编程结课设计说明书.docx_第18页
第18页 / 共31页
C编程结课设计说明书.docx_第19页
第19页 / 共31页
C编程结课设计说明书.docx_第20页
第20页 / 共31页
亲,该文档总共31页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

C编程结课设计说明书.docx

《C编程结课设计说明书.docx》由会员分享,可在线阅读,更多相关《C编程结课设计说明书.docx(31页珍藏版)》请在冰点文库上搜索。

C编程结课设计说明书.docx

C编程结课设计说明书

荆楚理工学院

<>结课设计说明书

 

学生姓名:

姚元美梁贵波杨爽

学号:

10EN11024810238

专业:

计算机科学与技术

班级:

计算机08-2

任课教师:

游明坤

 

1.游戏编程

1.1.概述

1.1.1.完成任务

(1)程序运行界面如图所示:

图计算机信息查看器主界面

1.2.分析

1.2.1.功能分析

新局:

单击左侧会出现连连看游戏运行界面,进入游戏。

提示:

用户可以在找不到一样的图案的时候点击提示,会出现两个可以撤销的类似图案。

重排:

左边图案会重新编排一次。

配置:

用户可以对游戏的相关选项进行设置。

退出:

退出游戏。

1.2.2.界面分析

运行界面如下:

如图所示,程序主体界面可分为三部分:

第一部分是以执行游戏的部分,第二部分是以游戏设置以及帮助的部分,第三部分就是游戏在运行时所剩时间提示。

第一部分含1个控件:

11个列表视图(listview)。

第二部分含8个控件:

6个按钮(button)2个标签(label)。

在2个label中,2个用于显示提示,1个复选项,分别用于显示相应的“详细信息”。

第三部分含3个控件:

1个label,1个显示提示,还有一个。

界面的详细布局如图所示。

1.2.3.程序分析

本程序的核心是游戏执行部分,所有的操作都围绕着该数据进行的。

游戏分为三关:

简单、一般和难。

为了用户在规定时间完成一关,设计了提示和重排。

其中新局是开始游戏的意思,退出也就意味着结束游戏。

1.3.实现步骤

1.3.1.建立工程

建立C#Windows窗体应用程序Game项目。

1.3.2.界面设计

根据图的样式,设计出查看器的窗体布局。

1.3.3.主程序功能实现

(1)定义主程序类对象GameMain。

(2)加载数据。

使用ComputerManager的Load方法从文件中加载信息,如果存在文件,则将文件中的计算机对象填充到ListView。

如果不存在,则创建不同类型的计算机,并添加到泛型集合中,填充到ListView中。

(3)窗体设计器生成的代码中的数据到Dispose:

privatevoidEndGame(),privatevoidWinGame()。

时间触发privatevoidtimeOutTimer_Tick(objectsender,EventArgse)。

(4)初始化集合泛型数据:

privatevoidInitGame()。

如果从本地文件加载泛型集合数据失败,则由程序初始化数据,填充到泛型集合。

(5)给下压式按钮添加事件处理。

1.4.核心代码

usingSystem;

using;

using;

using;

using;

using;

using;

namespaceLLK

{

publicclassGameMain:

Form

{

privateIContainercomponents;

privateCheckBoxAutoClear;

privateTimerlineTimer;

privateButtonbtnReset;

privateButtonbtnInfo;

privateButtonbtnRePlay;

privateLabellbP;

privateLabellbInfoCount;

privateLabellabel3;

privateButtonbtnExit;

privateProgressBarpBar;

privateTimertimeOutTimer;

privateLabellbTimeOut;

privatePictureBoxpictureBox1;

privateLabellabel1;

privateLabellbCaption;

privateCheckBoxAutoReset;

privateButtonbtnAbout;

privateButtonbtnConfig;

privateScreenDrawSD=null;

privateLinesearch_p1=null;

privateLinesearch_p2=null;

privateboolisSearch=false;

privateintPointCount=0;

privateintInfoCount=5;

privateconstintGameTimeSec=60;

privateGameStategs=;

privateMap[]oMap=null;

privateLineManager[]LM=null;

privateScreenCursorcursor=null;

privateoptions=new();

privateScreenObjectSO=null;

privateBombPointbp1=newBombPoint();

privateBombPointbp2=newBombPoint();

privateSoundPlayListspl=newSoundPlayList();

privatestringappPath="";

privateSoundPlayerspBg;

privateSoundPlayerspBomb;

privateSoundPlayerspEarse;

privateSoundPlayerspRefresh;

privateSoundPlayerspSelect;

privateSoundPlayerspHint;

privateint[,]L=newint[3,3]{{28,22,16},{34,28,22},{39,34,28}};

privateTimerSplashTimer;

privateGameLoadingGL=null;

privateenumGameState

{

Start,

Play,

End,

Win

}

publicGameMain(GameLoadinggameLoading)

{

InitializeComponent();

=gameLoading;

}

protectedoverridevoidDispose(booldisposing)

{

if(disposing)

{

if(components!

=null)

{

();

}

}

(disposing);

}

#regionWindows窗体设计器生成的代码

privatevoidInitializeComponent()

{

=newContainer();

=newButton();

=newButton();

=newCheckBox();

=newTimer;

=newButton();

=newLabel();

=newLabel();

=newLabel();

=newLabel();

=newButton();

=newProgressBar();

=newLabel();

=newTimer;

=newPictureBox();

=newLabel();

=newCheckBox();

=newButton();

=newButton();

=newTimer;

();

=(((Byte)(192)),((Byte)(255)),((Byte)(255)));

=newPoint(672,100);

="btnReset";

=1;

="重排";

+=newEventHandler;

=(((Byte)(192)),((Byte)(255)),((Byte)(255)));

=newPoint(672,68);

="btnInfo";

=2;

="提示";

+=newEventHandler;

=;

=newPoint(672,136);

="AutoClear";

=newSize(80,24);

=0;

="自动清除";

=200;

+=newEventHandler;

=(((Byte)(192)),((Byte)(255)),((Byte)(255)));

=newPoint(672,36);

="btnRePlay";

=3;

="新局";

+=newEventHandler;

=true;

=;

=newPoint(672,204);

="label1";

=newSize(35,17);

=6;

="得分:

";

=true;

=;

=newPoint(672,228);

="lbP";

=newSize(11,17);

=7;

="0";

=true;

=;

=newPoint(672,280);

="lbInfoCount";

=newSize(11,17);

=9;

="0";

=true;

=;

=newPoint(672,256);

="label3";

=newSize(60,17);

=8;

="提示次数:

";

=(((Byte)(192)),((Byte)(255)),((Byte)(255)));

=newPoint(672,376);

="btnExit";

=10;

="退出";

+=newEventHandler;

=newPoint(112,400);

="pBar";

=newSize(416,23);

=11;

=100;

=true;

=;

=newPoint(8,404);

="lbTimeOut";

=newSize(97,17);

=12;

="剩余时间(60秒):

";

=1000;

+=newEventHandler;

=newPoint(8,40);

="pictureBox1";

=newSize(630,330);

=;

=13;

=false;

=true;

=;

=newPoint(8,8);

="lbCaption";

=newSize(116,17);

=14;

="连连看赶快开始吧.";

=;

=newPoint(672,168);

="AutoReset";

=newSize(80,24);

=15;

="自动重排";

=false;

=(((Byte)(192)),((Byte)(255)),((Byte)(255)));

=newPoint(672,344);

="btnAbout";

=16;

="关于";

+=newEventHandler;

=(((Byte)(192)),((Byte)(255)),((Byte)(255)));

=newPoint(672,312);

="btnConfig";

=17;

="配置";

+=newEventHandler;

=true;

=500;

+=newEventHandler;

=newSize(6,14);

=;

=newSize(758,431);

=;

=;

=false;

="GameMain";

=;

="GameMain";

+=newEventHandler;

+=newMouseEventHandler;

+=newPaintEventHandler;

+=newMouseEventHandler;

(false);

}

#endregion

.");

oMap=newMap[3];

("初始化地图...完成,正在初始化连线管理...");

LM=newLineManager[3];

("初始化连线管理...完成,正在初始化光标和配置档案...");

cursor=newScreenCursor();

GameOptiongo=newGameOption;

options=();

();

("初始化光标和配置档案...完成,正在初始化素材数据...");

SO=newScreenObject();

("初始化素材数据...完成,正在分配元素...");

oMap[0]=newMap(SO,39,0,0);

oMap[1]=newMap(SO,34,0,0);

oMap[2]=newMap(SO,28,0,0);

("分配元素...完成,正在计算路径...");

LM[0]=newLineManager(oMap[0]);

LM[1]=newLineManager(oMap[1]);

LM[2]=newLineManager(oMap[2]);

SD=newScreenDraw(),*,*;

search_p1=newLine();

search_p2=newLine();

="连连看第一版by.";

try

{

=(appPath+"\\Images\\");

}

catch

{

("缺少资源目录!

!

","请到安装目录内运行!

",,;

();

}

("计算路径...完成,正在初始化声音档案...");

Sounds\");

Sounds\");

Sounds\");

Sounds\");

spBg=newSoundPlayer(),"bg");

("初始化背景音乐完成...");

spBomb=newSoundPlayer(appPath+@"\Sounds\","bomb");

("初始化爆炸音效完成...");

spEarse=newSoundPlayer(appPath+@"\Sounds\","earse");

("初始化连线音效完成...");

spRefresh=newSoundPlayer(appPath+@"\Sounds\","refresh");

("初始化刷新音效完成...");

spSelect=newSoundPlayer(appPath+@"\Sounds\","select");

("初始化选择音效完成...");

spHint=newSoundPlayer(appPath+@"\Sounds\","hint");

("游戏初始化完毕!

");

evel=L[-1,i];

}

if(gs==

{

foreach(MapminoMap)

{

();

();

}

UpdateFrame();

}

gs=;

=true;

if

{

if(!

{

=();

();

}

}

else

{

();

}

if(GL!

=null)

{

();

();

GL=null;

}

}

privatevoidEndGame()

{

gs=;

=false;

;

(0,0);

=GameTimeSec;

=0;

=;

();

();

();

}

privatevoidWinGame()

{

gs=;

EndGame();

}

privatevoidGameMain_MouseUp(objectsender,MouseEventArgse)

{

if(gs!

=return;

MapTile[]oMapTile=newMapTile[3];

for(inti=-1;i>=0;i--)

{

if(oMap[i].GetCount()>0)

{

oMapTile[i]=oMap[i].TranPointToMapTile,;

if(oMapTile[i]!

=null)

{

if(oMapTile[i].XIndex==0||oMapTile[i].YIndex==0||oMapTile[i].XIndex==-1||oMapTile[i].YIndex==-1||oMapTile[i].ID==0)

{

return;

}

else

{

if(oMap[-1].GetCount()>0)

{

if(i<-1)break;

}

Graphicsg=();

(newPen,oMapTile[i].X,oMapTile[i].Y,oMapTile[i].Width,oMapTile[i].Height);

LM[i].Add(oMapTile[i].XIndex,oMapTile[i].YIndex,oMapTile[i].ID);

(g);

if();

isSearch=false;

if(LM[i].CanStartLink())

{

UpdateFrame();

}

break;

}

}

}

}

}

privatevoidGameMain_Paint(objectsender,PaintEventArgse)

{

if(gs==UpdateFrame();

}

privateintShowLineAndClear()

{

ArrayListfindPathPoints=null;

inttrunCount=0;

();

();

for(inti=-1;i>=0;i--)

{

if(LM[i].TestLink(outfindPathPoints,outtrunCount))

{

oMap[i].DrawPathPoints(),findPathPoints);

/*绘制爆炸效果*/

=oMap[i];

=oMap[i];

=newPoint(LM[i].Items(LM[i].Count-1).X,LM[i].Items(LM[i].Count-1).Y);

=newPoint(LM[i].Items(LM[i].Count-2).X,LM[i].Items(LM[i].Count-2).Y);

=();

=();

 

MapTileoMapTile1=MapTileoMapTile2=if(oMapTile1!

=null)

{

Bitmapb1=5,oMapTile1);

().DrawImage((Image)b1,,);

}

if(oMapTile2!

=null)

{

Bitmapb2=5,oMapTile2);

().DrawImage((Image)b2,,);

}

();

();

/*爆炸效果完毕*/

oMap[i].DestroyObject(LM[i].Items(LM[i].Count-1).X,LM[i].Items(LM[i].Count-1).Y);

oMap[

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

当前位置:首页 > 成人教育 > 远程网络教育

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2