Advertisement

Preliminary Multiplayer Questions

Started by March 11, 2006 04:43 PM
2 comments, last by Bob Janova 18 years, 11 months ago
Hi, I'm thinking of implementing multiplayer (two computers, not split-screen) in my next game. It's a sidescroller, similar to a Super Mario game. Multiplayer would allow two players to play together in co-op mode, or to fight each other in deathmatch. Multiplayer would ONLY be designed for LAN play, so I won't have to deal with issues related to internet play (like longer delivery times and greater packet loss). I've read the FAQ and checked out some tutorials, but I have a few unanswered questions. My idea for multiplayer is to have the "server" computer act as the authority on everything. Every frame (multiplayer input would be strictly held to 30 FPS, or any other reasonably high number), the "client" computer would send its keyboard input values. The server would respond by doing the same, so both computers have all the input data and calculations will result in both computers and players seeing and believing the same thing. Is this feasible on a LAN? What is the typical delay for packet delivery? Would this allow data to be sent one way, received, and then the other data to be sent back and received, and then all relevant calculations made in such a timely manner that a decent frame-rate would be possible (something like 30-60 fps)? If a packet isn't received after a certain amount of time, it is resent. This way no calculations are made without all the relevant data, and hang-ups woudl only occur when packets don't make it or take a long time. Am I correct in thinking that this wouldn't be much of a problem on a LAN, and that such stuttering would only happen with a frequency of once every few minutes? Any other implementation seems ridiculous to me. Because this is a fast-action game, both computers need to know everything for the user to have an experience that isn't frustrating. It would suck to not see your friend jump when he does, only to see him stand there, and then suddently have him up in the air because your computer finally got updated information (in other words, synchronization in a fast action game where both players are both on the screen for most of the time seems impossible). Does my idea make sense? Any answers to my questions (specifically regarding LANs), or suggestions, would be appreciated. -Gauvir_Mucca
Typical LAN transmission times are in the 0.1 ms to 5.0 ms range, unless you have a large LAN with a crap router.
enum Bool { True, False, FileNotFound };
Advertisement
So if I'm making my program depend on packet's being delivered (the game won't proceed until it has input data from the user's keyboard AND the keyboard of the other computer), and since I'm restricting myself to LANs, am I correct in believing that TCP makes more sense than UDP in this case?

-Gauvir_Mucca
Yes. That is exactly what TCP is designed for.

You shouldn't have any latency issues with TCP over a LAN.

This topic is closed to new replies.

Advertisement