




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、荊楚理工學(xué)院結(jié)課設(shè)計(jì)說明書學(xué)生姓名:姚元美梁貴波楊爽學(xué)號(hào): 10EN1 10248 10238專業(yè):計(jì)算機(jī)科學(xué)與技術(shù)班級(jí):計(jì)算機(jī)08-2任課教師:游明坤1. 游戲編程1.1. 概述1.1.1.完成任務(wù)(1) 程序運(yùn)行界面如圖所示 :圖 計(jì)算機(jī)信息查看器主界面1.2. 分析1.2.1.功能分析新局:單擊左側(cè)會(huì)出現(xiàn)連連看游戲運(yùn)行界面,進(jìn)入游戲。提示:用戶可以在找不到一樣的圖案的時(shí)候點(diǎn)擊提示, 會(huì)出現(xiàn)兩個(gè)可以撤銷的類似圖案。重排:左邊圖案會(huì)重新編排一次。配置:用戶可以對(duì)游戲的相關(guān)選項(xiàng)進(jìn)行設(shè)置。退出:退出游戲。1.2.2.界面分析運(yùn)行界面如下:如圖所示,程序主體界面可分為三部分: 第一部分是以執(zhí)行游戲
2、的部分, 第二部分是以游戲設(shè)置以及幫助的部分,第三部分就是游戲在運(yùn)行時(shí)所剩時(shí)間提示。第一部分含 1 個(gè)控件: 11 個(gè)列表視圖( list view)。第二部分含 8 個(gè)控件: 6 個(gè)按鈕( button)2 個(gè)標(biāo)簽( label)。在 2 個(gè)label中,2 個(gè)用于顯示提示, 1 個(gè)復(fù)選項(xiàng),分別用于顯示相應(yīng)的“詳細(xì)信息” 。第三部分含 3 個(gè)控件: 1 個(gè) label,1個(gè)顯示提示,還有一個(gè)。界面的詳細(xì)布局如圖所示。1.2.3.程序分析本程序的核心是游戲執(zhí)行部分,所有的操作都圍繞著該數(shù)據(jù)進(jìn)行的。游戲分為三關(guān):簡單、一般和難。為了用戶在規(guī)定時(shí)間完成一關(guān),設(shè)計(jì)了提示和重排。其中新局是開始游戲的意
3、思,退出也就意味著結(jié)束游戲。1.3. 實(shí)現(xiàn)步驟1.3.1.建立工程建立 C# Windows窗體應(yīng)用程序 Game 項(xiàng)目。1.3.2.界面設(shè)計(jì)根據(jù)圖的樣式,設(shè)計(jì)出查看器的窗體布局。1.3.3.主程序功能實(shí)現(xiàn)(1) 定義主程序類對(duì)象 GameMain 。(2)加載數(shù)據(jù)。使用 ComputerManager的 Load 方法從文件中加載信息,如果存在文件,則將文件中的計(jì)算機(jī)對(duì)象填充到ListView。 如果不存在,則創(chuàng)建不同類型的計(jì)算機(jī),并添加到泛型集合中,填充到ListView中。(3)窗體設(shè)計(jì)器生成的代碼中的數(shù)據(jù)到Dispose:privatevoidEndGame(),private voi
4、d WinGame()。時(shí)間觸發(fā)privatevoidtimeOutTimer_Tick(object sender, EventArgs e)。(4) 初始化集合泛型數(shù)據(jù): private void InitGame()。如果從本地文件加載泛型集合數(shù)據(jù)失敗,則由程序初始化數(shù)據(jù),填充到泛型集合。(5) 給下壓式按鈕添加事件處理。1.4. 核心代碼using System;using ;using ;using ;using ;using ;using ;namespace LLKpublic class GameMain : Formprivate IContainer components;
5、private CheckBox AutoClear;private Timer lineTimer;private Button btnReset;private Button btnInfo;private Button btnRePlay;private Label lbP;private Label lbInfoCount;private Label label3;private Button btnExit;private ProgressBar pBar;private Timer timeOutTimer;private Label lbTimeOut;private Pictu
6、reBox pictureBox1;private Label label1;private Label lbCaption;private CheckBox AutoReset;private Button btnAbout;private Button btnConfig;private ScreenDraw SD = null;private Line search_p1 = null;private Line search_p2 = null;private bool isSearch = false;private int PointCount = 0;private int Inf
7、oCount = 5;private const int GameTimeSec = 60;private GameState gs = ;private Map oMap = null;private LineManager LM = null;private ScreenCursor cursor = null;private options = new ();private ScreenObject SO = null;private BombPoint bp1 = new BombPoint();private BombPoint bp2 = new BombPoint();priva
8、te SoundPlayList spl = new SoundPlayList();private string appPath = ;private SoundPlayer spBg;private SoundPlayer spBomb;private 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;pr
9、ivate Timer SplashTimer;private GameLoading GL = null;private enum GameStateStart,Play,End,Winpublic GameMain(GameLoading gameLoading)InitializeComponent();= gameLoading;protected override void Dispose(bool disposing)if (disposing)if (components != null)();(disposing);#region Windows窗體設(shè)計(jì)器生成的代碼privat
10、e void InitializeComponent()= new Container();= new Button();= new Button();= new CheckBox();= new Timer;= new Button();= new Label();= new Label();= new Label();= new Label();= new Button();= new ProgressBar();= new Label();= new Timer;= new PictureBox();= new Label();= new CheckBox();= new Button(
11、);= new Button();= new Timer;();=(Byte)(192),(Byte)(255),(Byte)(255);= new Point(672, 100);= btnReset;= 1;= 重排;+= new EventHandler;= (Byte)(192),(Byte)(255),(Byte)(255);= new Point(672, 68);= btnInfo;= 2;= 提示;+= new EventHandler;= ;= new Point(672, 136);= AutoClear;= new Size(80, 24);= 0;= 自動(dòng)清除 ;= 2
12、00;+= new EventHandler;=(Byte)(192),(Byte)(255),(Byte)(255);= new Point(672, 36);= btnRePlay;= 3;= 新局;+= new EventHandler;= true;= ;= new Point(672, 204);= label1;= new Size(35, 17);= 6;= 得分 :;= true;= ;= new Point(672, 228);= lbP;= new Size(11, 17);= 7;= 0;= true;= ;= new Point(672, 280);= lbInfoCo
13、unt;= new Size(11, 17);= 9;= 0;= true;= ;= new Point(672, 256);= label3;= new Size(60, 17);= 8;= 提示次數(shù) :;=(Byte)(192),(Byte)(255),(Byte)(255);= new Point(672, 376);= btnExit;= 10;= 退出;+= new EventHandler;= new Point(112, 400);= pBar;= new Size(416, 23);= 11;= 100;= true;= ;= new Point(8, 404);= lbTim
14、eOut;= new Size(97, 17);= 12;= 剩余時(shí)間 (60 秒 ):;= 1000;+= new EventHandler;= new Point(8, 40);= pictureBox1;= new Size(630, 330);= ;= 13;= false;= true;= ;= new Point(8, 8);= lbCaption;= new Size(116, 17);= 14;= 連連看 趕快開始吧 .;= ;= new Point(672, 168);= AutoReset;= new Size(80, 24);= 15;= 自動(dòng)重排 ;= false;=(
15、Byte)(192),(Byte)(255),(Byte)(255);= new Point(672, 344);= btnAbout;= 16;= 關(guān)于;+= new EventHandler;=(Byte)(192),(Byte)(255),(Byte)(255);= new Point(672, 312);= btnConfig;= 17;= 配置;+= new EventHandler;= true;= 500;+= new EventHandler;= new Size(6, 14);= ;= new Size(758, 431);= ;= ;= false;= GameMain;=
16、 ;= GameMain;+= new EventHandler;+= new MouseEventHandler;+= new PaintEventHandler;+= new MouseEventHandler;(false);#endregion.);oMap = new Map3;( 初始化地圖 . 完成 , 正在初始化連線管理 .); LM = new LineManager3;( 初始化連線管理.完成, 正在初始化光標(biāo)和配置檔案 .);cursor = new ScreenCursor();GameOption go = new GameOption;options = ();()
17、;( 初始化光標(biāo)和配置檔案.完成, 正在初始化素材數(shù)據(jù) .);SO = new ScreenObject();( 初始化素材數(shù)據(jù) .完成 , 正在分配元素 .);oMap0 = new Map(SO, 39, 0, 0);oMap1 = new Map(SO, 34, 0, 0);oMap2 = new Map(SO, 28, 0, 0);( 分配元素 .完成 , 正在計(jì)算路徑 .);LM0 = new LineManager(oMap0);LM1 = new LineManager(oMap1);LM2 = new LineManager(oMap2);SD = new ScreenDraw
18、(), *, *;search_p1 = new Line();search_p2 = new Line();= 連連看第一版 by .;try= (appPath + Images);catch( 缺少資源目錄 !, 請(qǐng)到安裝目錄內(nèi)運(yùn)行 !, , ; ();( 計(jì)算路徑 .完成 , 正在初始化聲音檔案 .);Sounds);Sounds);Sounds);Sounds);spBg = new SoundPlayer(), bg);( 初始化背景音樂完成 .);spBomb = new SoundPlayer(appPath + Sounds,bomb);( 初始化爆炸音效完成 .);spEa
19、rse= new SoundPlayer(appPath+ Sounds,earse);( 初始化連線音效完成 .);spRefresh = new SoundPlayer(appPath + Sounds, refresh);( 初始化刷新音效完成 .);spSelect= new SoundPlayer(appPath+ Sounds,select);(初始化選擇音效完成.);spHint= new SoundPlayer(appPath+ Sounds,hint);( 游戲初始化完畢! );evel = L - 1, i;if (gs =foreach (Map m in oMap)()
20、;();UpdateFrame();gs = ;= true;ifif (!= ();();else();if (GL != null)();();GL = null;private void EndGame()gs = ;= false;(0, 0);= GameTimeSec;= 0;= ;();();();private void WinGame()gs = ;EndGame();private void GameMain_MouseUp(object sender, MouseEventArgs e)if (gs != return;MapTile oMapTile = new Map
21、Tile3;for (int i = - 1; i = 0; i-)if (oMapi.GetCount() 0)oMapTilei=oMapi.TranPointToMapTile, ;if (oMapTilei != null)if(oMapTilei.XIndex=0|oMapTilei.YIndex= 0|oMapTilei.XIndex= -1|oMapTilei.YIndex =- 1 | oMapTilei.ID = 0)return;elseif (oMap - 1.GetCount() 0)if (i = 0; i-)if(LMi.TestLink(outfindPathPo
22、ints,outtrunCount)oMapi.DrawPathPoints(),findPathPoints);/* 繪制爆炸效果 */= oMapi;= oMapi;=new1).X, LMi.Items(LMi.Count - 1).Y);=newPoint(LMi.Items(LMi.Count Point(LMi.Items(LMi.Count-2).X, LMi.Items(LMi.Count - 2).Y);= ();= ();MapTile oMapTile1 =MapTile oMapTile2 =if(oMapTile1!=null)Bitmap b1 = 5, oMapT
23、ile1);().DrawImage(Image) b1, , );if (oMapTile2 != null)Bitmap b2 = 5, oMapTile2);().DrawImage(Image) b2, , );();();/* 爆炸效果完畢 */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);= true;LMi.Clear();r
24、eturn trunCount + 1;return 0;private void UpdateFrame()UpdateFrame(true);private void UpdateFrame(bool IsFlip)if (gs =if (! return;for (int i = 0; i ; i+)if (oMapi.GetCount() != 0)if (i 0)InfoCount -;= -1;= -1;= -1;= -1;ref search_p2); ref search_p2);if (oMap2.GetCount() != 0)isSearch= LM2.SearchLin
25、e(refelse if (oMap1.GetCount() != 0)isSearch= LM1.SearchLine(refelseisSearch= LM0.SearchLine(refsearch_p1,search_p1,search_p1,ref search_p2);UpdateFrame();privatevoidbtnReset_Click(objectsender,EventArgs e)if (gs != return;if();foreach (Map m in oMap)();UpdateFrame();privatevoidbtnRePlay_Click(objec
26、tsender,EventArgs e)if (gs =if (目前正在游戲,打算開新局嗎?, 提示, , =();elsereturn;();foreach (Map m in oMap)();();PointCount = 0;UpdateFrame();privatevoidbtnExit_Click(objectsender,EventArgse)();();privatevoidtimeOutTimer_Tick(objectsender,EventArgs e)if 0)= - 1;= ( 剩余時(shí)間 (0 秒 ):, ;if = 3)ifif (!();else= false; if (gs !=();(0, 0);( 時(shí)間到!請(qǐng)繼續(xù)努力! , 游戲結(jié)束! , , ;();EndGame();privatevoidbtnAbout_Click(objectsender,EventArgs e)GameAbout ga = new GameAbout();(this);();privatevoidGameMain_MouseMove(objectsender,MouseEventArgs e)=
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中國單梁起重機(jī)行業(yè)發(fā)展?jié)摿Ψ治黾巴顿Y戰(zhàn)略咨詢報(bào)告
- 2025屆昭通市重點(diǎn)中學(xué)化學(xué)高二下期末預(yù)測(cè)試題含解析
- 安全生產(chǎn)規(guī)章制度修訂時(shí)間
- 2025屆遼寧省大連市普蘭店區(qū)第二中學(xué)高一化學(xué)第二學(xué)期期末學(xué)業(yè)質(zhì)量監(jiān)測(cè)試題含解析
- 2025年中國媒介灰B行業(yè)市場發(fā)展前景及發(fā)展趨勢(shì)與投資戰(zhàn)略研究報(bào)告
- 2024-2030年中國制沙機(jī)行業(yè)發(fā)展監(jiān)測(cè)及投資戰(zhàn)略研究報(bào)告
- 生產(chǎn)三管三必須
- 加油站安全隱患排查治理總結(jié)
- 中國抗壞血酸行業(yè)發(fā)展監(jiān)測(cè)及市場發(fā)展?jié)摿︻A(yù)測(cè)報(bào)告
- 幼兒安全工作會(huì)議記錄
- 產(chǎn)房實(shí)習(xí)生帶教計(jì)劃修改版
- 生活中的立體圖形--完整版課件
- 企業(yè)安全生產(chǎn)自查臺(tái)賬(建筑施工)
- 實(shí)驗(yàn)室資質(zhì)認(rèn)定質(zhì)量技術(shù)負(fù)責(zé)人培訓(xùn)
- 綜合實(shí)踐活動(dòng)評(píng)價(jià)表完整
- GB∕T 16422.3-2022 塑料 實(shí)驗(yàn)室光源暴露試驗(yàn)方法 第3部分:熒光紫外燈
- 菲迪克(FIDIC)簡明合同格式-中英對(duì)照版
- 浙江省基礎(chǔ)教育地方課程(通用內(nèi)容)標(biāo)準(zhǔn)1-9年級(jí)
- 滿堂腳手架專項(xiàng)施工方案
- AVL燃燒分析及在標(biāo)定的應(yīng)用培訓(xùn)
- 線束裝配作業(yè)指導(dǎo)書
評(píng)論
0/150
提交評(píng)論