Exercise 2
2
) Create a client-server multiplayer game that allow players to
walk together through a maze.
•
•
The server must be authoritative: the player’s movements must
be validated and performed in the server. The clients must
receive only the updated positions.
A protocol of messages that are exchanged by client and server
is indispensable.
•
Example 1: when a player wants to move right he send a message to the
server: “r|ID|”, where r represents the right direction and ID must be a
number that identifies the player (every player must know his ID, which is
defined by the server – i.e.: the server must send the ID to the player).
Example 2: when a player moves, the server sends messages to all clients
informing the positions of all players: “U|ID|AVATAR|POSX|POSY|”, where
U indicates that this is an update, ID is the identification of the player,
AVATAR is a unique letter that represents the player, and POSX and POSY
are the positions of the player.
•
•
The client must show the map and the movements of all players
in real-time (as illustrated in the image).
A and B are players