C#编程结课设计说明书_第1页
C#编程结课设计说明书_第2页
C#编程结课设计说明书_第3页
C#编程结课设计说明书_第4页
C#编程结课设计说明书_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

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

文档简介

1、荆楚理工学院结课设计说明书学生姓名:姚元美 梁贵波 杨爽学 号:10en404010261 2008404010248 2008404010238专 业:计算机科学与技术班 级:计算机08-2任课教师:游明坤1. 游戏编程1.1. 概述1.1.1. 完成任务(1) 程序运行界面如图1.1所示:图1.1 计算机信息查看器主界面1.2. 分析1.2.1. 功能分析新局:单击左侧会出现连连看游戏运行界面,进入游戏。提示:用户可以在找不到一样的图案的时候点击提示,会出现两个可以撤销的类似图案。重排:左边图案会重新编排一次。配置:用户可以对游戏的相关选项进行设置。退出:退出游戏。1.2.2. 界面分析运

2、行界面如下:如图1.1所示,程序主体界面可分为三部分:第一部分是以执行游戏的部分,第二部分是以游戏设置以及帮助的部分,第三部分就是游戏在运行时所剩时间提示。第一部分含1个控件:11个列表视图(list view)。第二部分含8个控件:6个按钮(button)2个标签(label)。在2个label中,2个用于显示提示,1个复选项,分别用于显示相应的“详细信息”。第三部分含3个控件:1个label,1个显示提示,还有一个。界面的详细布局如图1.1所示。1.2.3. 程序分析本程序的核心是游戏执行部分,所有的操作都围绕着该数据进行的。游戏分为三关:简单、一般和难。为了用户在规定时间完成一关,设计了

3、提示和重排。其中新局是开始游戏的意思,退出也就意味着结束游戏。1.3. 实现步骤1.3.1. 建立工程建立c# windows窗体应用程序game项目。1.3.2. 界面设计根据图1.1的样式,设计出查看器的窗体布局。1.3.3. 主程序功能实现 (1)定义主程序类对象gamemain。 (2)加载数据。使用computermanager的load方法从文件中加载信息,如果存在文件,则将文件中的计算机对象填充到listview。 如果不存在,则创建不同类型的计算机,并添加到泛型集合中,填充到listview中。 (3)窗体设计器生成的代码中的数据到dispose:private void en

4、dgame(),private void wingame()。时间触发private void timeouttimer_tick(object sender, eventargs e)。(4)初始化集合泛型数据:private void initgame()。如果从本地文件加载泛型集合数据失败,则由程序初始化数据,填充到泛型集合。(5)给下压式按钮添加事件处理。1.4. 核心代码using system;using system.collections;using system.componentmodel;using system.drawing;using system.io;using

5、 system.windows.forms;using llk.action;using llk.ui;namespace llkpublic class gamemain : formprivate icontainer components;private checkbox autoclear;private timer linetimer;private button btnreset;private button btninfo;private button btnreplay;private label lbp;private label lbinfocount;private la

6、bel label3;private button btnexit;private progressbar pbar;private timer timeouttimer;private label lbtimeout;private picturebox picturebox1;private label label1;private label lbcaption;private checkbox autoreset;private button btnabout;private button btnconfig;private screendraw sd = null;private l

7、ine search_p1 = null;private line search_p2 = null;private bool issearch = false;private int pointcount = 0;private int infocount = 5;private const int gametimesec = 60;private gamestate gs = gamestate.start;private map omap = null;private linemanager lm = null;private screencursor cursor = null;pri

8、vate gameoption.options options = new gameoption.options();private screenobject so = null;private bombpoint bp1 = new bombpoint();private bombpoint bp2 = new bombpoint();private soundplaylist spl = new soundplaylist();private string apppath = ;private soundplayer spbg;private soundplayer spbomb;priv

9、ate soundplayer spearse;private soundplayer sprefresh;private soundplayer spselect;private soundplayer sphint;private int, l = new int3,3 28, 22, 16, 34, 28, 22, 39, 34, 28;private timer splashtimer;private gameloading gl = null;private enum gamestatestart,play,end,winpublic gamemain(gameloading gam

10、eloading)initializecomponent();this.gl = gameloading;protected override void dispose(bool disposing)if (disposing)if (components != null)components.dispose();base.dispose(disposing);#region windows 窗体设计器生成的代码private void initializecomponent()ponents = new container();this.btnreset = new button();thi

11、s.btninfo = new button();this.autoclear = new checkbox();this.linetimer = new timer(ponents);this.btnreplay = new button();this.label1 = new label();this.lbp = new label();this.lbinfocount = new label();this.label3 = new label();this.btnexit = new button();this.pbar = new progressbar();this.lbtimeou

12、t = new label();this.timeouttimer = new timer(ponents);this.picturebox1 = new picturebox();this.lbcaption = new label();this.autoreset = new checkbox();this.btnabout = new button();this.btnconfig = new button();this.splashtimer = new timer(ponents);this.suspendlayout();this.btnreset.forecolor = colo

13、r.fromargb(byte) (192), (byte) (255), (byte) (255);this.btnreset.location = new point(672, 100);this.btnreset.name = btnreset;this.btnreset.tabindex = 1;this.btnreset.text = 重排;this.btnreset.click += new eventhandler(this.btnreset_click);this.btninfo.forecolor = color.fromargb(byte) (192), (byte) (2

14、55), (byte) (255);this.btninfo.location = new point(672, 68);this.btninfo.name = btninfo;this.btninfo.tabindex = 2;this.btninfo.text = 提示;this.btninfo.click += new eventhandler(this.btninfo_click);this.autoclear.forecolor = color.goldenrod;this.autoclear.location = new point(672, 136);this.autoclear

15、.name = autoclear;this.autoclear.size = new size(80, 24);this.autoclear.tabindex = 0;this.autoclear.text = 自动清除;this.linetimer.interval = 200;this.linetimer.tick += new eventhandler(this.linetimer_tick);this.btnreplay.forecolor = color.fromargb(byte) (192), (byte) (255), (byte) (255);this.btnreplay.

16、location = new point(672, 36);this.btnreplay.name = btnreplay;this.btnreplay.tabindex = 3;this.btnreplay.text = 新局;this.btnreplay.click += new eventhandler(this.btnreplay_click);this.label1.autosize = true;this.label1.forecolor = color.goldenrod;this.label1.location = new point(672, 204);this.label1

17、.name = label1;this.label1.size = new size(35, 17);this.label1.tabindex = 6;this.label1.text = 得分:;this.lbp.autosize = true;this.lbp.forecolor = color.red;this.lbp.location = new point(672, 228);this.lbp.name = lbp;this.lbp.size = new size(11, 17);this.lbp.tabindex = 7;this.lbp.text = 0; this.lbinfo

18、count.autosize = true;this.lbinfocount.forecolor = color.red;this.lbinfocount.location = new point(672, 280);this.lbinfocount.name = lbinfocount;this.lbinfocount.size = new size(11, 17);this.lbinfocount.tabindex = 9;this.lbinfocount.text = 0;this.label3.autosize = true;this.label3.forecolor = color.

19、goldenrod;this.label3.location = new point(672, 256);this.label3.name = label3;this.label3.size = new size(60, 17);this.label3.tabindex = 8;this.label3.text = 提示次数:;this.btnexit.forecolor = color.fromargb(byte) (192), (byte) (255), (byte) (255);this.btnexit.location = new point(672, 376);this.btnexi

20、t.name = btnexit;this.btnexit.tabindex = 10;this.btnexit.text = 退出;this.btnexit.click += new eventhandler(this.btnexit_click);this.pbar.location = new point(112, 400);this.pbar.name = pbar;this.pbar.size = new size(416, 23);this.pbar.tabindex = 11;this.pbar.value = 100;this.lbtimeout.autosize = true

21、;this.lbtimeout.forecolor = color.goldenrod;this.lbtimeout.location = new point(8, 404);this.lbtimeout.name = lbtimeout;this.lbtimeout.size = new size(97, 17);this.lbtimeout.tabindex = 12;this.lbtimeout.text = 剩余时间(60秒):; this.timeouttimer.interval = 1000;this.timeouttimer.tick += new eventhandler(t

22、his.timeouttimer_tick);this.picturebox1.location = new point(8, 40);this.picturebox1.name = picturebox1;this.picturebox1.size = new size(630, 330);this.picturebox1.sizemode = pictureboxsizemode.stretchimage;this.picturebox1.tabindex = 13;this.picturebox1.tabstop = false;this.lbcaption.autosize = tru

23、e;this.lbcaption.forecolor = color.lime;this.lbcaption.location = new point(8, 8);this.lbcaption.name = lbcaption;this.lbcaption.size = new size(116, 17);this.lbcaption.tabindex = 14;this.lbcaption.text = 连连看 赶快开始吧.;this.autoreset.forecolor = color.goldenrod;this.autoreset.location = new point(672,

24、168);this.autoreset.name = autoreset;this.autoreset.size = new size(80, 24);this.autoreset.tabindex = 15;this.autoreset.text = 自动重排;this.autoreset.visible = false;this.btnabout.forecolor = color.fromargb(byte) (192), (byte) (255), (byte) (255);this.btnabout.location = new point(672, 344);this.btnabo

25、ut.name = btnabout;this.btnabout.tabindex = 16;this.btnabout.text = 关于;this.btnabout.click += new eventhandler(this.btnabout_click);this.btnconfig.forecolor = color.fromargb(byte) (192), (byte) (255), (byte) (255);this.btnconfig.location = new point(672, 312);this.btnconfig.name = btnconfig;this.btn

26、config.tabindex = 17;this.btnconfig.text = 配置;this.btnconfig.click += new eventhandler(this.btnconfig_click);this.splashtimer.enabled = true;this.splashtimer.interval = 500;this.splashtimer.tick += new eventhandler(this.splashtimer_tick);this.autoscalebasesize = new size(6, 14);this.backcolor = colo

27、r.black;this.clientsize = new size(758, 431);this.controls.add(this.btnconfig);this.controls.add(this.btnabout);this.controls.add(this.autoreset);this.controls.add(this.lbcaption);this.controls.add(this.lbtimeout);this.controls.add(this.lbinfocount);this.controls.add(this.label3);this.controls.add(t

28、his.lbp);this.controls.add(this.label1);this.controls.add(this.pbar);this.controls.add(this.btnexit);this.controls.add(this.btnreplay);this.controls.add(this.autoclear);this.controls.add(this.btninfo);this.controls.add(this.btnreset);this.controls.add(this.picturebox1);this.cursor = cursors.default;

29、this.formborderstyle = formborderstyle.fixeddialog;this.maximizebox = false;this.name = gamemain;this.startposition = formstartposition.centerscreen;this.text = gamemain;this.load += new eventhandler(this.gamemain_load);this.mouseup += new mouseeventhandler(this.gamemain_mouseup);this.paint += new p

30、ainteventhandler(this.gamemain_paint);this.mousemove += new mouseeventhandler(this.gamemain_mousemove);this.resumelayout(false);#endregion/ / 应用程序的主入口点。/ stathreadprivate static void main()gameloading gl = new gameloading();gl.show();application.run(new gamemain(gl);private void gamemain_load(object

31、 sender, eventargs e)apppath = application.executablepath.substring(0, application.executablepath.lastindexof();this.hide();gl.refresh();gl.updateloadinginfo(正在初始化地图.);omap = new map3;gl.updateloadinginfo(初始化地图.完成,正在初始化连线管理.);lm = new linemanager3;gl.updateloadinginfo(初始化连线管理.完成,正在初始化光标和配置档案.);curso

32、r = new screencursor();gameoption go = new gameoption(this.spl);options = go.readoption();go.dispose();gl.updateloadinginfo(初始化光标和配置档案.完成,正在初始化素材数据.);so = new screenobject();gl.updateloadinginfo(初始化素材数据.完成,正在分配元素.);omap0 = new map(so, 39, 0, 0);omap1 = new map(so, 34, 0, 0);omap2 = new map(so, 28, 0

33、, 0);gl.updateloadinginfo(分配元素.完成,正在计算路径.);lm0 = new linemanager(omap0);lm1 = new linemanager(omap1);lm2 = new linemanager(omap2);sd = new screendraw(this.creategraphics(), map.tilerowcount*map.tilewidth, map.tilecolcount*map.tileheight);search_p1 = new line();search_p2 = new line();this.text = 连连看

34、第一版 by s.f.;trythis.picturebox1.image = image.fromfile(apppath + imageswelcome.jpg);catchmessagebox.show(缺少资源目录!, 请到安装目录内运行!, messageboxbuttons.ok, messageboxicon.information);this.close();gl.updateloadinginfo(计算路径.完成,正在初始化声音档案.);/spl.add(.soundsbg-01.mid);/spl.add(.soundsbg-02.mid);/spl.add(.sounds

35、bg-03.mid);/spl.add(.soundsbg-04.mp3);spbg = new soundplayer(spl.currentmusic(), bg);gl.updateloadinginfo(初始化背景音乐完成.);spbomb = new soundplayer(apppath + soundsbomb.wav, bomb);gl.updateloadinginfo(初始化爆炸音效完成.);spearse = new soundplayer(apppath + soundsearse.wav, earse);gl.updateloadinginfo(初始化连线音效完成.)

36、;sprefresh = new soundplayer(apppath + soundsrefresh.wav, refresh);gl.updateloadinginfo(初始化刷新音效完成.);spselect = new soundplayer(apppath + soundsselect.wav, select);gl.updateloadinginfo(初始化选择音效完成.);sphint = new soundplayer(apppath + soundshint.wav, hint);gl.updateloadinginfo(游戏初始化完毕!);/gl.close();/gl.

37、dispose();/gl =null;private void initgame()/3分钟pbar.maximum = gametimesec;pbar.minimum = 0;pbar.value = pbar.maximum;this.infocount = 5;this.pointcount = 0;if (file.exists(apppath + chinasf)this.infocount = 5000;picturebox1.hide();lbcaption.hide();for (int i = 0; i = 0; i-)if (omapi.getcount() 0)oma

38、ptilei = omapi.tranpointtomaptile(e.x, e.y);if (omaptilei != null)if (omaptilei.xindex = 0 | omaptilei.yindex = 0 | omaptilei.xindex = map.tilerowcount - 1 | omaptilei.yindex = map.tilecolcount - 1 | omaptilei.id = 0)return;elseif (omapomap.length - 1.getcount() 0)if (i = 0; i-)if (lmi.testlink(out

39、findpathpoints, out truncount)omapi.drawpathpoints(sd.surface(), findpathpoints);/*绘制爆炸效果*/bp1.currentmap = omapi;bp2.currentmap = omapi;bp1.currentpoint = new point(lmi.items(lmi.count - 1).x, lmi.items(lmi.count - 1).y);bp2.currentpoint = new point(lmi.items(lmi.count - 2).x, lmi.items(lmi.count -

40、 2).y);bp1.currentsurface = sd.image();bp2.currentsurface = sd.image();maptile omaptile1 = bp1.currentmap.mapviewbp1.currentpoint.x, bp1.currentpoint.y;maptile omaptile2 = bp2.currentmap.mapviewbp2.currentpoint.x, bp2.currentpoint.y;if (omaptile1 != null)bitmap b1 = bp1.currentmap.drawbombeff(bp1.cu

41、rrentsurface, 5, omaptile1);sd.surface().drawimage(image) b1, bp1.transoffsetx(omaptile1.x), bp1.transoffsety(omaptile1.y);if (omaptile2 != null)bitmap b2 = bp2.currentmap.drawbombeff(bp2.currentsurface, 5, omaptile2);sd.surface().drawimage(image) b2, bp2.transoffsetx(omaptile2.x), bp2.transoffsety(

42、omaptile2.y);bp1.setempty();bp2.setempty();/*爆炸效果完毕*/omapi.destroyobject(lmi.items(lmi.count - 1).x, lmi.items(lmi.count - 1).y);omapi.destroyobject(lmi.items(lmi.count - 2).x, lmi.items(lmi.count - 2).y);linetimer.enabled = true;lmi.clear();return truncount + 1;return 0;private void updateframe()updateframe(true);private void updateframe(bool isflip)if (gs = gamestate.play)if (!this.visible) return;sd.fill(color.black);for (int i = 0; i omap.length; i+)if (omapi.getcount() != 0)if (i 2)if (omapi + 1.getcount() != 0)if (i = 0)omapi.draw(sd.surface(), true, 1);elseomapi.draw(sd.surface

温馨提示

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

评论

0/150

提交评论