資源描述:
《走迷宮游戲程序設(shè)計(jì)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在學(xué)術(shù)論文-天天文庫(kù)。
1、一、題目(問(wèn)題)描述模擬網(wǎng)絡(luò)中的走迷宮游戲,如圖1:圖1迷宮地圖-33-二、功能分析通過(guò)體驗(yàn)并分析后得出走迷宮游戲中主要功能包括:1.初始化新游戲的開(kāi)局功能。2.尋路功能3.小人前后左右移動(dòng)。-33-三、系統(tǒng)設(shè)計(jì)1.程序總體結(jié)構(gòu)程序中由主模塊負(fù)責(zé)協(xié)調(diào)各功能模塊的工作。開(kāi)局后,根據(jù)輸入操作,執(zhí)行小人的前后左右移動(dòng)和尋路功能,并同時(shí)在屏幕輸出。如圖2:走迷宮程序系統(tǒng)開(kāi)局輸入小人移動(dòng)小人尋路輸出圖2走迷宮的總體結(jié)構(gòu)圖2.界面設(shè)計(jì)如圖3,代表墻壁;代表道路;代表目的地;代表小人;-33-3.輸入方式設(shè)計(jì)此游戲?yàn)閐os下程序,因此簡(jiǎn)化為鍵盤(pán)控制。w,s,a,d,鍵用來(lái)移動(dòng)小人的位置。如
2、圖3:圖3程序化迷宮圖4.重要數(shù)據(jù)的數(shù)據(jù)結(jié)構(gòu)設(shè)計(jì)圖形界面數(shù)據(jù)intmap[25][25]={{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{1,6,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1},{1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1},-33-{1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1},{1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,0,
3、1,1,1,0,1,0,1,1,1},{1,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,1},{1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,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設(shè)計(jì)文件中函數(shù)的功能如下:文件名函數(shù)原型函數(shù)功能函數(shù)處理描述走迷宮.Cchari
7、nput無(wú)需回車(chē)確認(rèn)地獲取用戶輸入,用于控制行走方向w,s,a,d來(lái)控制小人上下左右移動(dòng)voiddraw_map繪圖功能定義一個(gè)二維數(shù)組,不同ID號(hào)代表不同的圖像元素voidResult(void)輸出結(jié)果處理處理走迷宮的結(jié)果voidFind(void)成功處理走迷宮成功后的處理-33-voidNotFind(void)失敗處理走迷宮失敗后的處理四、關(guān)鍵技術(shù)、難點(diǎn)及其解決方法此程序的關(guān)鍵是判斷數(shù)組的ID號(hào),保證游戲可以正常運(yùn)行并且闖關(guān)成功。解決方法:根據(jù)在紙面上設(shè)計(jì)好的游戲圖形界面,分析在二維數(shù)組里所對(duì)