[SDL] Good multiplayer game design?
jeffj1 at hiwaay.net
Sun Mar 26 21:53:02 PST 2006
On Mon, 27 Mar 2006, Leo M. Cabrera wrote:
>> This also
>> increases the portability of the code because different compilers and
>> different platforms may align the data differently
>Oh crap! Yeah, I forgot about the portability of structs... I now
>remember from when I learned about binary files... :-P
>> That depends on how often you send updates. Also plan on a 100+ms latency
>> introduced by the modem.
>Does that mean that I have to wait 100ms at the beginning of the
>send/receive function thread?
No, I just ment that your game should work OK with the greater latency. I
can send data across the US in about 100ms, or across town with a modem in
100 to 150ms.
Since it seems like your trying to keep the networking part pretty simple,
I shouldn't have made an issue out of it. Worry about it after you've got
the networking code running and the latency is a problem. If it isn't a
problem, don't worry :-)
>I also have a question now... How do I send the data to the clients? I
>was thinking of sending an integer saying how much players it's going to
>receive, and then send them... Is that alright? Thanks! ;-)
That is certainly the easiest way. Even better is trying to send only data
that has changed. If the gainularity there is all the info on one player
then only when a player does something will the data be sent. That'll help
support modem users.
To support that scheme, you may need to tell clients about new players
entering the game and existing ones leaving the game. Then it can be
useful to send messages. Based on the message type, the client or server
will process the data differently. Then you can have connect, disconnect,
and player update messages. It's pretty common to use some sort of message
system rather than sending data for all players to all clients every time
through some update loop.
>PS: I'm so happy about this game! I hope it comes out well... :-)
:-) Good luck, and have fun with it!
More information about the SDL