版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、題 目:拼圖游戲?qū)?業(yè): 計算機(jī)科學(xué)與技術(shù)學(xué) 號:姓 名:指導(dǎo)老師:完成日期:2012/12/26C#課程設(shè)計評分標(biāo)準(zhǔn)題 目:拼圖游戲 專 業(yè):計算機(jī)科學(xué)與技術(shù) 學(xué) 號:姓 名:考察項目評分依據(jù)完成情況分?jǐn)?shù)報告(40分)規(guī)范完成設(shè)計報告,含光盤報告能夠反映設(shè)計思路,并介紹系統(tǒng)功能報告內(nèi)容比較完整,思路比較清晰,語句比較通順報告內(nèi)容完整,用語準(zhǔn)確,能夠反映系統(tǒng)開發(fā)過程前臺開發(fā)工具(10分)能夠使用開發(fā)工具的基本操作完成系統(tǒng)的開發(fā)能夠熟練地運(yùn)用開發(fā)工具來實(shí)現(xiàn)較全面的功能對開發(fā)工具熟悉,能夠靈活使用各類控件和語句完成系統(tǒng)開發(fā)能夠熟練掌握多種開發(fā)工具,并能夠獨(dú)立解決較復(fù)雜的編程問題。應(yīng)用到多種數(shù)據(jù)庫對
2、象。系統(tǒng)功能(25分)能夠完成數(shù)據(jù)的輸入輸出和基本查詢功能除了基本信息管理功能外,還可以完成比較復(fù)雜的數(shù)據(jù)查詢和數(shù)據(jù)編輯功能能夠方便地完成數(shù)據(jù)操作功能具有較復(fù)雜的數(shù)據(jù)管理功能系統(tǒng)界面設(shè)計(20分)具有一般的Window窗口界面功能比較全,操作也比較方便界面美觀,功能全面,操作方便界面美觀,功能設(shè)計有創(chuàng)新教師簽字:成績:目 錄1 前言42 需求分析43 概要設(shè)計與詳細(xì)設(shè)計54 編碼與實(shí)現(xiàn)64.2具體代碼實(shí)現(xiàn)(附源代碼)95 課程設(shè)計總結(jié)18參考文獻(xiàn)191.前言拼圖游戲一款非常經(jīng)典的小游戲,因?yàn)樗容^簡單有趣,無論老少都比較適合。拼圖的設(shè)計對每一個C#語言設(shè)計者進(jìn)行語言提高和進(jìn)階都是一個很好的鍛煉
3、機(jī)會。 拼圖游戲的設(shè)計比較復(fù)雜,它涉及面廣、牽涉方面多,如果不好好考慮和設(shè)計,將難以成功開發(fā)出這個游戲。在這個游戲的設(shè)計中,牽涉到圖形界面的顯示與更新、數(shù)據(jù)的收集與更新,并且在這個游戲的開發(fā)中,還要應(yīng)用類的繼承機(jī)制以及一些設(shè)計模式。因此,如何設(shè)計和開發(fā)好這個拼圖游戲,對于提高C#開發(fā)水平和系統(tǒng)的設(shè)計能力有極大的幫助。在設(shè)計開發(fā)過程中,需要處理好各個類之間的繼承關(guān)系,還要處理各個類相應(yīng)的封裝,并且還要協(xié)調(diào)好各個模塊之間的邏輯依賴關(guān)系和數(shù)據(jù)通信關(guān)系。一個3×3的魔板,有一個格子是空的,其他格子內(nèi)隨機(jī)放置1-8共8個編號的方塊,通過單擊任意一個與空格子相鄰的方塊可以把該方塊移入空格子,不斷
4、的移動方塊,直到方塊按照圖片的原來的順序排好。2 需求分析2.1要求(1)用C#語言實(shí)現(xiàn)程序設(shè)計;(2)利用PictureBox控件來實(shí)現(xiàn)圖片的移動(3)超過200步提示重新來(4)界面友好(良好的人機(jī)互交),程序要有注釋。2.2任務(wù)(1)制作流程圖(2)編寫代碼;(3)程序分析與調(diào)試。2.3運(yùn)行環(huán)境(1)WINDOWS2000/XP/win7系統(tǒng)(2)TurboC編譯環(huán)境2.4開發(fā)工具C#語言3 概要設(shè)計與詳細(xì)設(shè)計3.1系統(tǒng)流程圖如圖所示。游戲開始操作游戲200步內(nèi)完成游戲游戲完成圖 系統(tǒng)流程圖3.2功能結(jié)構(gòu)圖如圖3.2所示。拼圖游戲游戲開始游戲復(fù)位游戲結(jié)束游戲退出圖3.2功能結(jié)構(gòu)圖這個游戲
5、主要分為四個模塊,分別是游戲開始、游戲復(fù)位、游戲結(jié)束和游戲退出。這四個摸塊的功能各不一樣,游戲開始的模塊就不用多介紹了,我們在這里主要說說重新開始的模塊,如果玩家對自己本次的成績不滿意,可以通過重新開始模塊來重完游戲4 編碼與實(shí)現(xiàn)4.1分析說明游戲開始:界面如圖4-1圖4-1在程序開頭定義變量,實(shí)例化數(shù)組;代碼如下圖游戲進(jìn)行中 :當(dāng)游戲運(yùn)行的時候,桌面上會出現(xiàn)圖上的圖形界面。有一個文本框和一個圖形界面。其中通過點(diǎn)擊鼠標(biāo)移動圖片,游戲就正式開始,且此游戲是通過計算鼠標(biāo)點(diǎn)擊的次數(shù),而不是計算時間,所以玩游戲的人可以有充分的時間考慮。游戲中見圖4-2圖4-2左右圖片對照方便有游戲的進(jìn)行,左下角有顯示
6、有戲進(jìn)行的步數(shù),復(fù)位時直接把右邊的圖相應(yīng)的賦給左邊,代碼實(shí)現(xiàn)如下圖:這里從第一個到第九個PictureBox都有相應(yīng)賦值和命令這里只截取Box1的圖片對應(yīng)的代碼游戲時本段代碼主要運(yùn)用的c#知識是二維數(shù)組和ifelse語句,通過判斷box1游戲復(fù)位:如果覺得自己的成績不夠好,可以選擇復(fù)位重新開始。復(fù)位時直接把右邊的圖相應(yīng)的賦給左邊,復(fù)位后效果和剛開始一樣。代碼實(shí)現(xiàn)如下游戲完成:當(dāng)玩家在200步以內(nèi)完成拼圖則提示"恭喜你已經(jīng)完成拼圖!"如圖4-3 ;否則將提玩家重新來過如圖4-4圖4-44.2具體代碼實(shí)現(xiàn)附源代碼using System;using System.Collect
7、ions.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace拼圖游戲2publicpartialclassForm1 : Formpublicstaticint aa;publicstaticint bb;private System.Windows.Forms.PictureBox, t; public Form1() InitializeComponent(); /實(shí)例化數(shù)組priva
8、tevoid Form1_Load(object sender, EventArgs e) t = newPictureBox3, 3pictureBox1 ,pictureBox2 ,pictureBox3 , pictureBox4 ,pictureBox5 ,pictureBox6 , pictureBox7 ,pictureBox8 ,pictureBox9 ;for (int i = 0; i <= 2; i+) for (int j = 0; j <= 2; j+) ti, j.Enabled = false; /圖片的移動privatevoid pictureBox1
9、_Click(object sender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox2.Image = null) pictureBox2.Image = pictureBox1.Image; pictureBox1.Image = null; elseif (pictureBox4.Image = null) pictureBox4.Image = pictureBox1.Image; pictureBox1.Image = null; privatevoid pictureBox2_Click(object s
10、ender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox1.Image = null) pictureBox1.Image = pictureBox2.Image; pictureBox2.Image = null; elseif (pictureBox3.Image = null) pictureBox3.Image = pictureBox2.Image; pictureBox2.Image = null; elseif (pictureBox5.Image = null) pictureBox5.Image =
11、 pictureBox2.Image; pictureBox2.Image = null; privatevoid pictureBox3_Click(object sender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox2.Image = null) pictureBox2.Image = pictureBox3.Image; pictureBox3.Image = null; elseif (pictureBox6.Image = null) pictureBox6.Image = pictureBox3.Im
12、age; pictureBox3.Image = null; privatevoid pictureBox4_Click(object sender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox1.Image = null) pictureBox1.Image = pictureBox4.Image; pictureBox4.Image = null; elseif (pictureBox5.Image = null) pictureBox5.Image = pictureBox4.Image; pictureBox
13、4.Image = null; elseif (pictureBox7.Image = null) pictureBox7.Image = pictureBox4.Image; pictureBox4.Image = null; privatevoid pictureBox5_Click(object sender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox2.Image = null) pictureBox2.Image = pictureBox5.Image; pictureBox5.Image = null;
14、 elseif (pictureBox4.Image = null) pictureBox4.Image = pictureBox5.Image; pictureBox5.Image = null; elseif (pictureBox6.Image = null) pictureBox6.Image = pictureBox5.Image; pictureBox5.Image = null; elseif (pictureBox8.Image = null) pictureBox8.Image = pictureBox5.Image; pictureBox5.Image = null; pr
15、ivatevoid pictureBox6_Click(object sender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox5.Image = null) pictureBox5.Image = pictureBox6.Image; pictureBox6.Image = null; elseif (pictureBox3.Image = null) pictureBox3.Image = pictureBox6.Image; pictureBox6.Image = null; elseif (pictureBo
16、x9.Image = null) pictureBox9.Image = pictureBox6.Image; pictureBox6.Image = null; privatevoid pictureBox7_Click(object sender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox4.Image = null) pictureBox4.Image = pictureBox7.Image; pictureBox7.Image = null; elseif (pictureBox8.Image = null
17、) pictureBox8.Image = pictureBox7.Image; pictureBox7.Image = null; privatevoid pictureBox8_Click(object sender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox5.Image = null) pictureBox5.Image = pictureBox8.Image; pictureBox8.Image = null; elseif (pictureBox7.Image = null) pictureBox7.I
18、mage = pictureBox8.Image; pictureBox8.Image = null; elseif (pictureBox9.Image = null) pictureBox9.Image = pictureBox8.Image; pictureBox8.Image = null; privatevoid pictureBox9_Click(object sender, EventArgs e) bb+; label2.Text = bb.ToString();if (pictureBox6.Image = null) pictureBox6.Image = pictureB
19、ox9.Image; pictureBox9.Image = null; elseif (pictureBox8.Image = null) pictureBox8.Image = pictureBox9.Image; pictureBox9.Image = null; /設(shè)置游戲最大步數(shù)privatevoid label2_TextChanged(object sender, EventArgs e) try if (int.Parse(label2.Text) >=200) MessageBox.Show("你已經(jīng)超過了游戲所限定的最大步數(shù),歡迎再來!", &qu
20、ot;注意", MessageBoxButtons.OK, MessageBoxIcon.Information); catch privatevoid button1_Click(object sender, EventArgs e) button2.Enabled = true; pictureBox9.Image = null; aa = aa + 1; for (int m = 0; m <= 2; m+) for (int n = 0; n <= 2; n+) tm, n.Enabled = true; ss: switch (aa) /對圖片進(jìn)行隨機(jī)的分割 c
21、ase 1: Clipboard.SetImage(pictureBox1.Image); pictureBox1.Image = pictureBox5.Image; pictureBox5.Image = Clipboard.GetImage(); Clipboard.Clear(); Clipboard.SetImage(pictureBox2.Image); pictureBox2.Image = pictureBox4.Image; pictureBox4.Image = Clipboard.GetImage(); Clipboard.Clear(); Clipboard.SetIm
22、age(pictureBox3.Image); pictureBox3.Image = pictureBox8.Image; pictureBox8.Image = Clipboard.GetImage(); Clipboard.Clear(); button1.Enabled = false; break; case 2: Clipboard.SetImage(pictureBox1.Image); pictureBox1.Image = pictureBox6.Image; pictureBox6.Image = Clipboard.GetImage(); Clipboard.Clear(
23、); Clipboard.SetImage(pictureBox2.Image); pictureBox2.Image = pictureBox8.Image; pictureBox8.Image = Clipboard.GetImage(); Clipboard.Clear(); Clipboard.SetImage(pictureBox3.Image); pictureBox3.Image = pictureBox5.Image; pictureBox5.Image = Clipboard.GetImage(); Clipboard.Clear(); button1.Enabled = f
24、alse; break; case 3: Clipboard.SetImage(pictureBox2.Image); pictureBox2.Image = pictureBox5.Image; pictureBox5.Image = Clipboard.GetImage(); Clipboard.Clear(); Clipboard.SetImage(pictureBox4.Image); pictureBox4.Image = pictureBox6.Image; pictureBox6.Image = Clipboard.GetImage(); Clipboard.Clear(); C
25、lipboard.SetImage(pictureBox3.Image); pictureBox3.Image = pictureBox8.Image; pictureBox8.Image = Clipboard.GetImage(); Clipboard.Clear(); button1.Enabled = false; break; case 4: Clipboard.SetImage(pictureBox1.Image); pictureBox1.Image = pictureBox8.Image; pictureBox8.Image = Clipboard.GetImage(); Cl
26、ipboard.Clear(); Clipboard.SetImage(pictureBox3.Image); pictureBox3.Image = pictureBox5.Image; pictureBox5.Image = Clipboard.GetImage(); Clipboard.Clear(); Clipboard.SetImage(pictureBox6.Image); pictureBox6.Image = pictureBox9.Image; pictureBox9.Image = Clipboard.GetImage(); Clipboard.Clear(); butto
27、n1.Enabled = false; break; default: aa = 1; goto ss; /對數(shù)組賦值privatevoid button2_Click(object sender, EventArgs e) pictureBox1.Image = pictureBox10.Image; pictureBox2.Image = pictureBox12.Image; pictureBox3.Image = pictureBox15.Image; pictureBox4.Image = pictureBox13.Image; pictureBox5.Image = picture
28、Box14.Image; pictureBox6.Image = pictureBox16.Image; pictureBox7.Image = pictureBox17.Image; pictureBox8.Image = pictureBox18.Image; pictureBox9.Image = null; label2.Text = "" bb = 0; button2.Enabled = false; button1.Enabled = true; for (int m = 0; m <= 2; m+) for (int n = 0; n <= 2;
29、 n+) tm, n.Enabled = false; /對游戲完成進(jìn)行判斷privatevoid Form1_Activated(object sender, EventArgs e) if (pictureBox1.Image = pictureBox10.Image && pictureBox2.Image = pictureBox12.Image && pictureBox3.Image = pictureBox13.Image && pictureBox4.Image = pictureBox14.Image && pictureBox5.Image = pictureBox15.Image && pictureBox6.Image = pictureBox16.Image && pictureBox7.Image = pictureBox17.Image && pictureBox8.Image = pictureBox18.Image && pictureB
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年開發(fā)商與購房者長租公寓買賣合同范本3篇
- 二零二五年度餐飲服務(wù)業(yè)勞動合同模板及食品安全3篇
- 二零二五版特種動物繁育與購銷一體化服務(wù)合同3篇
- 二零二五年教育機(jī)構(gòu)教學(xué)資源整合合同書3篇
- 二零二五年空壓機(jī)租賃與應(yīng)急響應(yīng)服務(wù)合同3篇
- 二零二五年教育培訓(xùn)機(jī)構(gòu)代理招生合同模板3篇
- 二零二五版未成年人撫養(yǎng)權(quán)變更合同3篇
- 二零二五年度財務(wù)風(fēng)險控制合同3篇
- 二零二五年度鋼材采購與智能制造合作合同3篇
- 二零二五版豪華游輪包船旅游運(yùn)輸服務(wù)合同參考模板2篇
- 2024版?zhèn)€人私有房屋購買合同
- 2025年山東光明電力服務(wù)公司招聘筆試參考題庫含答案解析
- 《神經(jīng)發(fā)展障礙 兒童社交溝通障礙康復(fù)規(guī)范》
- 2025年中建六局二級子企業(yè)總經(jīng)理崗位公開招聘高頻重點(diǎn)提升(共500題)附帶答案詳解
- 2024年5月江蘇省事業(yè)單位招聘考試【綜合知識與能力素質(zhì)】真題及答案解析(管理類和其他類)
- 注漿工安全技術(shù)措施
- 3-9年級信息技術(shù)(人教版、清華版)教科書資源下載
- (完整)貓咪上門喂養(yǎng)服務(wù)協(xié)議書
- 上海牛津版三年級英語3B期末試卷及答案(共5頁)
- 行為疼痛量表BPS
- 小學(xué)生必背古詩詞80首(硬筆書法田字格)
評論
0/150
提交評論