C#面向?qū)ο笳n程設(shè)計(jì)報(bào)告-拼圖游戲_第1頁(yè)
C#面向?qū)ο笳n程設(shè)計(jì)報(bào)告-拼圖游戲_第2頁(yè)
C#面向?qū)ο笳n程設(shè)計(jì)報(bào)告-拼圖游戲_第3頁(yè)
C#面向?qū)ο笳n程設(shè)計(jì)報(bào)告-拼圖游戲_第4頁(yè)
C#面向?qū)ο笳n程設(shè)計(jì)報(bào)告-拼圖游戲_第5頁(yè)
已閱讀5頁(yè),還剩9頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

.z."C#程序設(shè)計(jì)"課程設(shè)計(jì)題目:拼圖游戲?qū)I(yè):計(jì)算機(jī)科學(xué)與技術(shù)學(xué)號(hào):姓名:指導(dǎo)教師:完成日期:2012/12/2"C#課程設(shè)計(jì)"評(píng)分標(biāo)準(zhǔn)題目:拼圖游戲?qū)I(yè):計(jì)算機(jī)科學(xué)與技術(shù)學(xué)號(hào):姓名:考察工程評(píng)分依據(jù)完成情況分?jǐn)?shù)報(bào)告〔40分〕標(biāo)準(zhǔn)完成設(shè)計(jì)報(bào)告,含光盤報(bào)告能夠反映設(shè)計(jì)思路,并介紹系統(tǒng)功能報(bào)告內(nèi)容比較完整,思路比較清晰,語(yǔ)句比較通順報(bào)告內(nèi)容完整,用語(yǔ)準(zhǔn)確,能夠反映系統(tǒng)開(kāi)發(fā)過(guò)程前臺(tái)開(kāi)發(fā)工具〔10分〕能夠使用開(kāi)發(fā)工具的根本操作完成系統(tǒng)的開(kāi)發(fā)能夠熟練地運(yùn)用開(kāi)發(fā)工具來(lái)實(shí)現(xiàn)較全面的功能對(duì)開(kāi)發(fā)工具熟悉,能夠靈活使用各類控件和語(yǔ)句完成系統(tǒng)開(kāi)發(fā)能夠熟練掌握多種開(kāi)發(fā)工具,并能夠獨(dú)立解決較復(fù)雜的編程問(wèn)題。應(yīng)用到多種數(shù)據(jù)庫(kù)對(duì)象。系統(tǒng)功能〔25分〕能夠完成數(shù)據(jù)的輸入輸出和根本查詢功能除了根本信息管理功能外,還可以完成比較復(fù)雜的數(shù)據(jù)查詢和數(shù)據(jù)編輯功能能夠方便地完成數(shù)據(jù)操作功能具有較復(fù)雜的數(shù)據(jù)管理功能系統(tǒng)界面設(shè)計(jì)〔20分〕具有一般的Window窗口界面功能比較全,操作也比較方便界面美觀,功能全面,操作方便界面美觀,功能設(shè)計(jì)有創(chuàng)新教師簽字:成績(jī):目錄TOC\o"1-2"\h\z\u1前言42需求分析42.1要求42.2任務(wù)42.3運(yùn)行環(huán)境42.4開(kāi)發(fā)工具43概要設(shè)計(jì)與詳細(xì)設(shè)計(jì)53.1系統(tǒng)流程圖53.2構(gòu)造功能圖54編碼與實(shí)現(xiàn)64.1編碼分析64.2具體代碼實(shí)現(xiàn)〔附源代碼〕95課程設(shè)計(jì)總結(jié)18參考文獻(xiàn)191.前言拼圖游戲一款非常經(jīng)典的小游戲,因?yàn)樗容^簡(jiǎn)單有趣,無(wú)論老少都比較適合。拼圖的設(shè)計(jì)對(duì)每一個(gè)C#語(yǔ)言設(shè)計(jì)者進(jìn)展語(yǔ)言提高和進(jìn)階都是一個(gè)很好的鍛煉時(shí)機(jī)。拼圖游戲的設(shè)計(jì)比較復(fù)雜,它涉及面廣、牽涉方面多,如果不好好考慮和設(shè)計(jì),將難以成功開(kāi)發(fā)出這個(gè)游戲。在這個(gè)游戲的設(shè)計(jì)中,牽涉到圖形界面的顯示與更新、數(shù)據(jù)的收集與更新,并且在這個(gè)游戲的開(kāi)發(fā)中,還要應(yīng)用類的繼承機(jī)制以及一些設(shè)計(jì)模式。因此,如何設(shè)計(jì)和開(kāi)發(fā)好這個(gè)拼圖游戲,對(duì)于提高C#開(kāi)發(fā)水平和系統(tǒng)的設(shè)計(jì)能力有極大的幫助。在設(shè)計(jì)開(kāi)發(fā)過(guò)程中,需要處理好各個(gè)類之間的繼承關(guān)系,還要處理各個(gè)類相應(yīng)的封裝,并且還要協(xié)調(diào)好各個(gè)模塊之間的邏輯依賴關(guān)系和數(shù)據(jù)通信關(guān)系。一個(gè)3×3的魔板,有一個(gè)格子是空的,其他格子內(nèi)隨機(jī)放置1-8共8個(gè)編號(hào)的方塊,通過(guò)單擊任意一個(gè)與空格子相鄰的方塊可以把該方塊移入空格子,不斷的移動(dòng)方塊,直到方塊按照?qǐng)D片的原來(lái)的順序排好。2需求分析2.1要求〔1〕用C#語(yǔ)言實(shí)現(xiàn)程序設(shè)計(jì);〔2〕利用PictureBo*控件來(lái)實(shí)現(xiàn)圖片的移動(dòng)〔3〕超過(guò)200步提示重新來(lái)〔4〕界面友好〔良好的人機(jī)互交〕,程序要有注釋。2.2任務(wù)〔1〕制作流程圖〔2〕編寫代碼;〔3〕程序分析與調(diào)試。2.3運(yùn)行環(huán)境〔1〕WINDOWS2000/*P/win7系統(tǒng)〔2〕TurboC2.0編譯環(huán)境2.4開(kāi)發(fā)工具C#語(yǔ)言3概要設(shè)計(jì)與詳細(xì)設(shè)計(jì)3.1系統(tǒng)流程圖如圖3.1所示。游戲開(kāi)場(chǎng)游戲開(kāi)場(chǎng)操作游戲200步內(nèi)完成游戲游戲完成圖3.1系統(tǒng)流程圖3.2功能構(gòu)造圖如圖3.2所示。拼圖游戲拼圖游戲游戲開(kāi)場(chǎng)游戲復(fù)位游戲完畢游戲退出圖3.2功能構(gòu)造圖這個(gè)游戲主要分為四個(gè)模塊,分別是游戲開(kāi)場(chǎng)、游戲復(fù)位、游戲完畢和游戲退出。這四個(gè)摸塊的功能各不一樣,游戲開(kāi)場(chǎng)的模塊就不用多介紹了,我們?cè)谶@里主要說(shuō)說(shuō)重新開(kāi)場(chǎng)的模塊,如果玩家對(duì)自己本次的成績(jī)不滿意,可以通過(guò)重新開(kāi)場(chǎng)模塊來(lái)重完游戲4編碼與實(shí)現(xiàn)4.1分析說(shuō)明游戲開(kāi)場(chǎng):界面如圖4-1圖4-1在程序開(kāi)頭定義變量,實(shí)例化數(shù)組;代碼如以下圖游戲進(jìn)展中:當(dāng)游戲運(yùn)行的時(shí)候,桌面上會(huì)出現(xiàn)圖上的圖形界面。有一個(gè)文本框和一個(gè)圖形界面。其中通過(guò)點(diǎn)擊鼠標(biāo)移動(dòng)圖片,游戲就正式開(kāi)場(chǎng),且此游戲是通過(guò)計(jì)算鼠標(biāo)點(diǎn)擊的次數(shù),而不是計(jì)算時(shí)間,所以玩游戲的人可以有充分的時(shí)間考慮。游戲中見(jiàn)圖4-2圖4-2左右圖片對(duì)照方便有游戲的進(jìn)展,左下角有顯示有戲進(jìn)展的步數(shù),復(fù)位時(shí)直接把右邊的圖相應(yīng)的賦給左邊,代碼實(shí)現(xiàn)如以下圖:這里從第一個(gè)到第九個(gè)PictureBo*都有相應(yīng)賦值和命令這里只截取Bo*1的圖片對(duì)應(yīng)的代碼游戲時(shí)本段代碼主要運(yùn)用的c#知識(shí)是二維數(shù)組和if`~else語(yǔ)句,通過(guò)判斷bo*1游戲復(fù)位:如果覺(jué)得自己的成績(jī)不夠好,可以選擇復(fù)位重新開(kāi)場(chǎng)。復(fù)位時(shí)直接把右邊的圖相應(yīng)的賦給左邊,復(fù)位后效果和剛開(kāi)場(chǎng)一樣。代碼實(shí)現(xiàn)如下游戲完成:當(dāng)玩家在200步以內(nèi)完成拼圖則提示"恭喜你已經(jīng)完成拼圖!"如圖4-3;否則將提玩家重新來(lái)過(guò)如圖4-4圖4-44.2具體代碼實(shí)現(xiàn)附源代碼usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Te*t;usingSystem.Windows.Forms;namespace拼圖游戲2{publicpartialclassForm1:Form{publicstaticintaa;publicstaticintbb;privateSystem.Windows.Forms.PictureBo*[,]t;publicForm1(){InitializeComponent();}//實(shí)例化數(shù)組privatevoidForm1_Load(objectsender,EventArgse){t=newPictureBo*[3,3]{{pictureBo*1,pictureBo*2,pictureBo*3},{pictureBo*4,pictureBo*5,pictureBo*6},{pictureBo*7,pictureBo*8,pictureBo*9}};for(inti=0;i<=2;i++){for(intj=0;j<=2;j++){t[i,j].Enabled=false;}}}//圖片的移動(dòng)privatevoidpictureBo*1_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*2.Image==null){pictureBo*2.Image=pictureBo*1.Image;pictureBo*1.Image=null;}elseif(pictureBo*4.Image==null){pictureBo*4.Image=pictureBo*1.Image;pictureBo*1.Image=null;}}privatevoidpictureBo*2_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*1.Image==null){pictureBo*1.Image=pictureBo*2.Image;pictureBo*2.Image=null;}elseif(pictureBo*3.Image==null){pictureBo*3.Image=pictureBo*2.Image;pictureBo*2.Image=null;}elseif(pictureBo*5.Image==null){pictureBo*5.Image=pictureBo*2.Image;pictureBo*2.Image=null;}}privatevoidpictureBo*3_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*2.Image==null){pictureBo*2.Image=pictureBo*3.Image;pictureBo*3.Image=null;}elseif(pictureBo*6.Image==null){pictureBo*6.Image=pictureBo*3.Image;pictureBo*3.Image=null;}}privatevoidpictureBo*4_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*1.Image==null){pictureBo*1.Image=pictureBo*4.Image;pictureBo*4.Image=null;}elseif(pictureBo*5.Image==null){pictureBo*5.Image=pictureBo*4.Image;pictureBo*4.Image=null;}elseif(pictureBo*7.Image==null){pictureBo*7.Image=pictureBo*4.Image;pictureBo*4.Image=null;}}privatevoidpictureBo*5_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*2.Image==null){pictureBo*2.Image=pictureBo*5.Image;pictureBo*5.Image=null;}elseif(pictureBo*4.Image==null){pictureBo*4.Image=pictureBo*5.Image;pictureBo*5.Image=null;}elseif(pictureBo*6.Image==null){pictureBo*6.Image=pictureBo*5.Image;pictureBo*5.Image=null;}elseif(pictureBo*8.Image==null){pictureBo*8.Image=pictureBo*5.Image;pictureBo*5.Image=null;}}privatevoidpictureBo*6_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*5.Image==null){pictureBo*5.Image=pictureBo*6.Image;pictureBo*6.Image=null;}elseif(pictureBo*3.Image==null){pictureBo*3.Image=pictureBo*6.Image;pictureBo*6.Image=null;}elseif(pictureBo*9.Image==null){pictureBo*9.Image=pictureBo*6.Image;pictureBo*6.Image=null;}}privatevoidpictureBo*7_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*4.Image==null){pictureBo*4.Image=pictureBo*7.Image;pictureBo*7.Image=null;}elseif(pictureBo*8.Image==null){pictureBo*8.Image=pictureBo*7.Image;pictureBo*7.Image=null;}}privatevoidpictureBo*8_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*5.Image==null){pictureBo*5.Image=pictureBo*8.Image;pictureBo*8.Image=null;}elseif(pictureBo*7.Image==null){pictureBo*7.Image=pictureBo*8.Image;pictureBo*8.Image=null;}elseif(pictureBo*9.Image==null){pictureBo*9.Image=pictureBo*8.Image;pictureBo*8.Image=null;}}privatevoidpictureBo*9_Click(objectsender,EventArgse){bb++;label2.Te*t=bb.ToString();if(pictureBo*6.Image==null){pictureBo*6.Image=pictureBo*9.Image;pictureBo*9.Image=null;}elseif(pictureBo*8.Image==null){pictureBo*8.Image=pictureBo*9.Image;pictureBo*9.Image=null;}}//設(shè)置游戲最大步數(shù)privatevoidlabel2_Te*tChanged(objectsender,EventArgse){try{if(int.Parse(label2.Te*t)>=200){MessageBo*.Show("你已經(jīng)超過(guò)了游戲所限定的最大步數(shù),歡迎再來(lái)!","注意",MessageBo*Buttons.OK,MessageBo*Icon.Information);}}catch{}}privatevoidbutton1_Click(objectsender,EventArgse){button2.Enabled=true;pictureBo*9.Image=null;aa=aa+1;for(intm=0;m<=2;m++){for(intn=0;n<=2;n++){t[m,n].Enabled=true;}}ss:switch(aa)//對(duì)圖片進(jìn)展隨機(jī)的分割{case1:{Clipboard.SetImage(pictureBo*1.Image);pictureBo*1.Image=pictureBo*5.Image;pictureBo*5.Image=Clipboard.GetImage();Clipboard.Clear();Clipboard.SetImage(pictureBo*2.Image);pictureBo*2.Image=pictureBo*4.Image;pictureBo*4.Image=Clipboard.GetImage();Clipboard.Clear();Clipboard.SetImage(pictureBo*3.Image);pictureBo*3.Image=pictureBo*8.Image;pictureBo*8.Image=Clipboard.GetImage();Clipboard.Clear();button1.Enabled=false;break;}case2:{Clipboard.SetImage(pictureBo*1.Image);pictureBo*1.Image=pictureBo*6.Image;pictureBo*6.Image=Clipboard.GetImage();Clipboard.Clear();Clipboard.SetImage(pictureBo*2.Image);pictureBo*2.Image=pictureBo*8.Image;pictureBo*8.Image=Clipboard.GetImage();Clipboard.Clear();Clipboard.SetImage(pictureBo*3.Image);pictureBo*3.Image=pictureBo*5.Image;pictureBo*5.Image=Clipboard.GetImage();Clipboard.Clear();button1.Enabled=false;break;}case3:{Clipboard.SetImage(pictureBo*2.Image);pictureBo*2.Image=pictureBo*5.Image;pictureBo*5.Image=Clipboard.GetImage();Clipboard.Clear();Clipboard.SetImage(pictureBo*4.Image);pictureBo*4.Image=pictureBo*6.Image;pictureBo*6.Image=Clipboard.GetImage();Clipboard.Clear();Clipboard.SetImage(pictureBo*3.Image);pictureBo*3.Image=pictureBo*8.Image;pictureBo*8.Image=Clipboard.GetImage();Clipboard.Clear();button1.Enabled=false;break;}case4:{Clipboard.SetImage(pictureBo*1.Image);pictureBo*1.Image=pictureBo*8.Image;pictureBo*8.Image=Clipboard.GetImage();Clipboard.Clear();Clipboard.SetImage(pictureBo*3.Image);pictureBo*3.Image=pictureBo*5.Image;pictureBo*5.Image=Clipboard.GetImage();Clipboard.Clear();Clipboard.SetImage(pictureBo*6.Image);pictureBo*6.Image=pictureBo*9.Image;pictureBo*9.Image=Clipboard.GetImage();Clipboard.Clear();button1.Enabled=false;break;}default:{aa=1;gotoss;}}}//對(duì)數(shù)組賦值privatevoidbutton2_Click(objectsender,EventArgse){pictureBo*1.Image=pictureBo*10.Image;pictureBo*2.Image=pictureBo*12.Image;pictureBo*3.Image=pictureBo*15.Image;pictureBo*4.Image=pictureBo*13.Image;pictureBo*5.Image=pictureBo*14.Image;pictureBo*6.Image=pictureBo*16.Image;pictureBo*7.Image=pictureBo*17.Image;pictureBo*8.Image=pictureBo*18.Image;pictureBo*9.Image=null;label2.Te*t="";bb=0;button2.Enabled=false;button1.Enabled=true;for(intm=0;m<=2;m++){for(intn=0;n<=2;n++){t[m,n].Enabled=false;}}}//對(duì)游戲完成進(jìn)展判斷privatevoidForm1_Activated(objectsender,EventArgse){if(pictureBo*1.Image==pictureBo*10.Image&&pictureBo*2.Image==pictureBo*12.Image&&pict

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論