How do I build online multiplayer game?

I want to develop an online multiplayer game similar to Don't Starve, and I believe WebSockets will be essential. However, I'm unsure where to start and have no experience with WebSockets. Could you provide some suggestions or resource recommendations?
9 Replies
ἔρως
ἔρως3mo ago
well, i cant tell you everything, but you will have to learn how to time travel and predict the future based on the past data you will receive some state at some point related to some point in time, and you will have to roll back to that older state and predict from there which is why, in some games, you see "rubberbanding"
5urf
5urfOP3mo ago
then how could I start learning it?
ἔρως
ἔρως3mo ago
im not a game dev, and i have no idea of any tutorials or something like that networking is something always very peculear to handle
13eck
13eck3mo ago
WS is one tool for one kind of game. But there are others. Some are better for real-time (but thus more complicated) while others are less complex but not as "instant" and thus good for turn-based games. But even before you start on the multiplayer aspect you need to have a solid understanding of how to make a web-based game. Do you know about requestAnimationFrame and how to use it? Are you familiar with the Canvas API? Are you doing 2D or 3D? Do you know about how to do animations? Input handling? Etc. Lots of work and knowledge goes into making a game.
ἔρως
ἔρως3mo ago
don't starve doesnt seem to be a turn-based game
Jochem
Jochem3mo ago
It's also not as high paced as a racing game or shooter
ἔρως
ἔρως3mo ago
yup, which makes it a lot less sensitive to ping and jitter and all those funny words i dont know
13eck
13eck3mo ago
If latency is very important, like the games Jochem mentioned, then UDP is what you want. Otherwise TCP will work fine. UDP is "throw it out there and hope it arrives". It's not guaranteed to get there. TCP, meanwhile, has redundencies in it to re-send a missing packet. Video chat apps, for example, use UDP because if you miss a frame (you see that all the time) it's no big deal. You don't want to see what happened seconds ago—you want to see what's happening now. Video streaming services, on the other hand, want TCP b/c it guarantees that the end user will get the entire video with no skipping. Also, there's WebRTC vs WS. Both real-time, bi-directional protocols. But WRTC is peer-to-peer whereas WS needs a server to connect the players. WS gives you the ability to store the state of the game on the server as an anti-cheating method (among other things) but adds more latency as the data needs to go to the server, be processed, then sent out to the other players. WRTC, on the other hand, only uses a server to connect players and after that it's all direct, peer-to-peer connection. Faster than WS as it cuts out the middle-man (server) but unless you open another type of connection to the server there's no way for the server to store game state or whatever. But is is faster.
5urf
5urfOP3mo ago
Thanks for your guys' suggestion. To be honest, I have some related tasks like WebRTC or WebSocket in my current job. I want to do some project to let me learn this concept. based on my interest. The game is a good entry point for me to learn this concept, but maybe it's too far away from the original purpose. I need to make some simple demos to let me know the concept or how it works.

Did you find this page helpful?