1 min
Since our game has to support networking, it means that data must be send across different poeple on different computers. For this game, a server is used to store the data on shich is then sent all the clients which updates their game. This a safer method than peer to peer as it stops people changing the data that will be sent, so therefore cheating is reduced, as the server can check if the information sent is correct before sending it all to the other clients.
The data is sent using enet. I have implemented a packets class (recomended by my lecturer), to send data across so any type of data can be streammed into it, it gets sent across to the other players then, gets streammed out in the order it was streammed in. I advanced on this by adding in a packet id as an enum, which is sent along with the packet and when streammed out, it tells the client or server what kind of data this is.
Since the packets can contain any type of data, I decided to use structs, which contain the data which is needed to be sent. Each part of the game will have a differnt struct such as the player, map, cards, tiles, chat room etc. This allows for the data to be sent but in an organised fashion and can easily be accessed once the client or server recieve it.
struct PlayerData
{
int lives = 0;
int score = 0;
int tile = 0;
};
Subscribe to this blog via RSS.
Low level programming dev diary 28
Text based adventure dev diary 6
Level design developer diary 3
Game engine programming dev diary 14
Audio-visual production dev diary 7
Audio-Visual Production: Particle System Mesh Spawning Issues
Posted on 20 Feb 2020Low level programming dev diary (28) Text based adventure dev diary (6) Level design developer diary (3) Post mortem (4) Ex-machina dev diary (11) Game engine programming dev diary (14) Network game dev diary (11) Audio-visual production dev diary (7)