admin管理员组

文章数量:1531521

2024年5月2日发(作者:)

沈阳理工大学学士学位论文

摘 要

本文详细介绍了一个网络对战军棋游戏的设计和实现。对于军棋游戏来说,规则非

常简单,就是按照先后顺序在棋盘上走棋吃子,直到一方最先将对方的“军旗”挖掉为胜。

该游戏使用C#编程实现在网络中的通信。这里使用了UDP(User Data Protocol)。

UDP是用户数据文报协议的简称,两台计算机之间的传输类似于传递邮件;两台之间没

有明确的连接,使用UDP协议建立对等通信。游戏开始后,创建一个线程。启动线程

后,通过不断侦听本机设定的端口,得到对方发送来的信息,根据自己定义的通信协议

中传送的是“输赢信息”、“下的棋子位置信息”、“重新开始”等信息而分别处理。发送信

息较为简单,主要实现创建UDP网络服务,传送信息到指定计算机的端口号后,关闭

UDP服务。

游戏最终实现了在网络中创建游戏、加入游戏等功能,可以实现在网络中联机对战

的要求。

关键词:军棋;UDP;C#

I

沈阳理工大学学士学位论文

Abstract

This paper describes the design and implementation of the Versus-network Jun

rules are very simple:take turns playing chess on a chess board,and the one who dig the “flag”

of the other side first will be the winner.

The game uses the C # programming to establish communication in the network .UDP is

used is the short for User Data ission between two computers is

similar to delivering the message;There is no clear connection between the two, using the

UDP protocol to establish peer the start of the game, create a

starting the thread ,through continuously listening to the port we set,we get

information from the other side. Then process respectively "winning or losing ", "the pieces

position ", "start again" and other information according to our own definition of

communication g information is relatively simple,mainly to create UDP

network services, transmit information to the designated remote port of the other computer,

shut down the UDP service.

Creating the game, joining the game and other functions can be achieved in the network.

Keywords: Jun Qi;UDP;C #

II

本文标签: 信息游戏网络实现军棋