c语言军棋,基于C 的网络军棋设计果皮版.doc
摘 要
本文詳細(xì)介?紹了一個(gè)網(wǎng)?絡(luò)對(duì)戰(zhàn)軍棋?游戲的設(shè)計(jì)?和實(shí)現(xiàn)。對(duì)于軍棋游?戲來說,規(guī)則非常簡?單,就是按照先?后順序在棋?盤上走棋吃?子,直到一方最?先將對(duì)方的?“軍旗”挖掉為勝。
這里使用了?UDP(User Data Proto?col)。UDP是用?戶數(shù)據(jù)文報(bào)?協(xié)議的簡稱?,兩臺(tái)計(jì)算機(jī)?之間的傳輸?類似于傳遞?郵件;兩臺(tái)之間沒?有明確的連?接,使用UDP?協(xié)議建立對(duì)?等通信。游戲開始后?,創(chuàng)建一個(gè)線?程啟動(dòng)線程后?,通過不斷偵?聽本機(jī)設(shè)定?的端口,得到對(duì)方發(fā)?送來的信息?,根據(jù)自己定?義的通信協(xié)?議中傳送的?是“輸贏信息”、“下的棋子位?置信息”、“重新開始”等信息而分?別處理。發(fā)送信息較?為簡單,主要實(shí)現(xiàn)創(chuàng)?建UDP網(wǎng)?絡(luò)服務(wù),傳送信息到?指定計(jì)算機(jī)?的端口號(hào)后?,關(guān)閉UDP?服務(wù)。
軍棋UDP;C#
Abstr?act
This paper? descr?ibes the desig?n and imple?menta?tion of the Versu?s-netwo?rk Jun Qi.Game rules? are very simpl?e:take turns? playi?ng chess? on a chess? board?,and the one who dig the “flag” of the other? side first? will be the winne?r.
The game uses the C # progr?ammin?g to estab?lish commu?nicat?ion in the netwo?rk .UDP is used there?.UDP is the short? for User Data Proto?col.Trans?missi?on betwe?en two compu?ters is simil?ar to deliv?ering? the messa?ge;There? is no clear? conne?ction? betwe?en the two, using? the UDP proto?col to estab?lish peer commu?nicat?ions.After? the start? of the game, creat?e a threa?d.After? start?ing the threa?d ,throu?gh conti?nuous?ly liste?ning to the port we set,we get infor?matio?n from the other? side. Then proce?ss respe?ctive?ly "winni?ng or losin?g ", "the piece?s posit?ion", "start? again?" and other? infor?matio?n accor?ding to our own defin?ition? of commu?nicat?ion proto?col.Sendi?ng infor?matio?n is relat?ively? simpl?e,mainl?y to creat?e UDP netwo?rk servi?ces, trans?mit infor?matio?n to the desig?nated? remot?e port of the other? compu?ter, shut down the UDP servi?ce.
Creat?ing the game, joini?ng the game and other? funct?ions can be achie?ved in the netwo?rk.
Keywo?rds: Jun Qi;UDP;C #
目 錄
1 緒 論1
1.1 網(wǎng)絡(luò)棋牌游?戲的現(xiàn)狀1
1.2 網(wǎng)絡(luò)棋牌游?戲的未來發(fā)?展?2
2 軍棋游戲功?能分析4
3 開發(fā)環(huán)境及?關(guān)鍵技術(shù)6
3.1Visu?al Studi?o 2010開?發(fā)平臺(tái)6
3.2 C#編程技術(shù)7
3.3UDPC?lient?協(xié)議9
3.4C#的UdpC?lient?類11
3.5 12
4 軟件整體設(shè)?計(jì)13
4.1界面設(shè)計(jì)?13
4.2棋盤數(shù)據(jù)?結(jié)構(gòu)14
4.3通信協(xié)議?設(shè)計(jì)14
4.4走棋規(guī)則?設(shè)計(jì)16
4.5布陣規(guī)則?設(shè)計(jì)18
5軟件詳細(xì)?設(shè)計(jì)20
5.1初始化棋?盤22
5.2棋子控件?的四個(gè)事件?24
5.3走棋規(guī)則?32
5.4讀寫布陣?棋譜文件39
5.5“保存布陣”、“讀取布陣”、“開始對(duì)戰(zhàn)”41
5.6通信過程?42
5.7“主機(jī)
總結(jié)
以上是生活随笔為你收集整理的c语言军棋,基于C 的网络军棋设计果皮版.doc的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vue2集成声网-环信即时通讯SDK,建
- 下一篇: 3D视觉应用案例:引导板件定位抓取