So question is basically in the topic title.
In a pong game I would send e.g the following:
- Player1/2 x-/y-Pos
- Ball Pos
Luckily SFML already knows that these values in the packages are float numbers e.g. .
Question is: If it would be a byte stream only, how shall the receiver know that it is a float number? Putting some kind of identifier in it as a prefix?
And let's say there are 6 Players and 3 NPCs, every player is able to collect items. So I have to send the positions every single tick and in case someone collects an item than this information too.
But how do I encode it into a datastream? Like player2 collected weapon1. What Data would you send to your server? Some kind of code?
Like:
std::string message = "Something to tell that player2 collected weapon1";
sf::Packet packet;
packet << message;
socket.send(packet, recipient, port);