Jump to content

How to make a multiplayer game


WoodyLau
 Share

Recommended Posts

Without meaning to sound negative, how comfortable are you with JS and web programming?

If the answer isn't at least 'yeah, I'm pretty good' then maybe don't try a multiplayer game. They are orders of magnitude harder.

If you're going for it though:

I'd start looking up and learning how websockets work, and really understand it. If you're familiar with pub/sub or observable patterns then they aren't super complex. The problem you always face (with any program to be honest) is dealing with the asynchronicity of events. If you get that down then you're most of the way there. It certainly isn't easy though.

Then I'd look up server-authoritive architecture i.e. the server is where your game live, your clients (players in the browser) are windows on to that server. Then get a handle on what stuff you can/should do on the client and what stuff must be done on the server. Once you get this then you can employ the lessons learnt above (websockets) to propagate that server state to all your players.

After that you've pretty much got the whole multiplayer thing done from a technical stand point and you can work on the really fun stuff of making your game fun.

Oh, as with all projects, keep your scope initially super small, like, really small, as in, way smaller than you think would be viable. Get it working on that small scope, then expand outwards. You'll hopefully find that even with a tiny fraction of your 'ideal scope' that your core concepts shine through and you have the beginnings of something fun, it probably *will* be fun at that stage if your core concepts are good.

Link to comment
Share on other sites

  • 2 weeks later...

I want to make multiplayer games too. I have some suggestions for you. Set a simple first goal for youself. I think that free Heroku is the best. Make a very simple server app that will send the "hello, world"  message + "counter" to your clients. Chose client side: Canvas API, WebGL, Phaser, Pixi.js, Three.js, Babylon.js, Unity WebGL and so on.

I choose Unity for client. I wrote the very simple server in TypeScript. I built client in WebGL and in desktop app. I uploaded my simple server on Heroku.

You can try run:

You will see a message that server send every one second. If you want, I can explain you in TeamViewer or Skype how to make it for free. Write me a private message.

 

UnityWebGLAndDektopClient.png

Link to comment
Share on other sites

  • 1 month later...

Designing Multiplayer games has a few general things in common, but much of how you will implement them will vary based upon which platform you use. Here a link to one of my favorite tutorials on the subject that goes as much into the theory as it does the technical walkthrough:

http://www.schibsted.pl/blog/back-end/developing-lag-compensated-multiplayer-game-pt-1/

Many tutorials over simplify by just saying "Make it a single player game then add multiplayer support later", which is usually NOT a good idea for most platforms; in the tutorial that I've linked to the writer goes over some of the pitfalls of that approach, pointing out that it's good to design and plan for multiplayer from the start.

One of the largest challenges for most starting out is getting a good understanding of net-sockets so the clients can communicate, then understanding how to make them sync together. It's good to get a decent understanding of both of those conceptually and technically for your platform before becoming too invested in a large project.

I'd also highly recommend this article by Gabriel Gametta on general theory of client-server architecture; it covers some of the history of multiplayer games and the concepts that were used as the industry advanced:

http://www.gabrielgambetta.com/client-server-game-architecture.html

I totally agree with what has already been said by others on this thread: Start Small. It's a lot easier to learn net-sockets and syncing clients for Pong than Ultima Online.

Hope that helps, and most all Good Luck!

Link to comment
Share on other sites

  • 1 year later...

Hi guys, if I have a turn-based game built in vanilla JS and HTML4 (way before HTML5) where you play against the computer in a local HTML file, and I want to host this HTML file somewhere and allow two humans to play each other -- what's the best way to approach this in 2020?

I've seen tons of online tutorials on how to build real-time multiplayer HTML5 games using Node.js and Sockets.io, etc., but all of them walk you through creating a game from scratch using a modern game engine, whereas all I want to do is retrofit my existing HTML4 game to add turn-based multiplayer. Any suggestions would be much appreciated.

Link to comment
Share on other sites

  • 2 weeks later...

I study this book: Multiplayer Game Development with HTML5 I rewrite the classic Snake game example from the book to TypeScript. Author uses Node.js, Express and SocketIO. I want to make 3D version of the Snake game. I will deploy the game on Heroku for free: https://www.heroku.com/ You can use OpenShift (https://www.openshift.com/) - it is the same. I found a very good tutorial how to make a smooth movement using lag compensation and client prediction methods: Real Time Multiplayer in HTML5 I deployed the example from the tutorial on Heroku: https://battle-world.herokuapp.com/?debug (I use a free plan and if no one runs it 30 minute you need to wait 10 seconds) You can open two browser pages to test it. The example from the tutorial on GitHub: https://github.com/ruby0x1/realtime-multiplayer-in-html5

Edited by 8Observer8
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...