摘 要:斗地主游戲系統開發使用的是C++語言,系統使用了C/S架構。本系統建立在局域網之上,主要就是建立一個服務器用來存儲數據,然后通過服務器和客戶端之間的通信來實現游戲過程。此游戲系統主要包括建立服務器、建立客戶端與服務器的鏈接、定義紙牌、發牌、搶地主、出牌、紙牌大小比較等功能。其中利用網絡編程相關知識,實現三次握手四次揮手,同時還可以解決客戶端與服務器之間的鏈接問題。實現定義紙牌模塊與發牌、搶地主模塊,通過定義一個K值,取1-54的數字代表整副紙牌,然后加入TYPE、NUM等變量解決出牌和紙牌牌面大小比較算法。由于受時間及技術嫻熟程度的限制,其功能有待進一步完善;但游戲畫面簡潔明了,可進行傻瓜式操作,具有可玩性較高,流暢度高的優勢。
關鍵詞:C++;桌面游戲;斗地主游戲
中圖分類號:TP317 文獻標識碼:A 文章編號:2096-4706(2018)11-0081-03
The Design and Implementation of the Game of the Bucket Landlord
ZHAO Juan,YI Gaizhen
(School of Computer Science,Xianyang Normal University,Xianyang 712000,China)
Abstract:The Landlords game system is developed using the C++ language,and the system uses the C/S architecture. The system is based on LAN,mainly to establish a server to store data,and then through the communication between the server and the client to achieve the game process. The game system mainly includes the establishment of servers,the establishment of client-server links,the definition of cards,licensing,landlords,cards,card size comparison and other functions. The network programming knowledge is used to realize three handshakes and four waving,and the problem of link between client and server can be solved. Realize the definition of card module and licensing,landlord robbery module,through the definition of a K value,take 1-54 digital representation of the whole deck of cards,and then add TYPE,NUM and other variables to solve the card and card size comparison algorithm. Due to the limitations of time and technical proficiency,its function needs to be further improved,but the game screen is concise and clear,can be foolish operation,with high playability,high fluency advantages.
Keywords:C++;table games;bucket landlords game
0 引 言
實現斗地主這個游戲的方法有很多,C/C++/JAVA等都可以在自己的平臺上實現,并且各有其特點和優勢。此游戲主要基于C++,首先需要對其運行機制與界面元素進行控制。在此基礎上,斗地主游戲主要依賴于后臺的算法。C++的文件讀取不同于Android,Android讀取文件需要一個繼承Activity的類,并且只能對屬于自己程序的文件進行操作,如果是原始文件則需在raw文件夾下,對其在Android中所對應的ID進行操作,但C++只需要知道文件目錄任何一個類就可以對文件進行操作,所以使用C++編寫該游戲系統有一定的便捷性[1]。
1 游戲設計中的數據結構及開發流程……p>