So I’ve been making a (two player) game for a while, and I want to add an online mode. I’m able to get the Server, Client, etc. classes working the way I want, so that’s fine. I’m just wondering how I would go about making the actual game playable over the internet. I’ve decided that one player will have a server as well as a client, and the second player will have just the client. These are the two strategies I thought of:
Have the client-only player send their control inputs to the server player. The server player sends them back a picture of the screen, and the sounds they should be playing. (both players have the same camera view in the offline mode, btw)
PROS: Simple to implement, and if I ever want to add more than two players it will be easy to do.
CONS: Essentially streaming a video to the client, which seems like it would be pretty slow. Sure, the client has all the audio assets, and the screen resolution is only 640x480 (it’s a retro-style game), but it’s still video streaming.
Player 1 sends their inputs to player 2, and vice versa. Each player process the inputs and runs the game on their own.
PROS: This is the more “normal” way of doing things, and would likely be much faster than the other method.
CONS: There’s more of a risk of gameplay becoming… “desynced”? For lack of a better word. If any of the inputs get dropped, or if I forget to keep the same seed for any of my random number generators, gameplay between the two players will end up differently. This can be prevented, but it will be much more work.
What do you all advise? Some variation of these? A third method?
(I’ve been trying to find tutorials for this, but my Google-Fu must not be that great. So, sorry if this has already been answered)