In the next part of this multiplayer game tutorial the client is made dumb and the server authoritative.

Posted on 21st Sep 2017. Follow @phaser_ and get the Phaser World newsletter.


"This is a continuation of the multiplayer game tutorial series with Phaser in the client and Node.js in the server. In the first part:

  • We successfully set up the developing environment.
  • We connected the clients and the server with and Express.js.
  • We synced all client movements so that the server has one game state.

However, remember that our implementation is very naive because we’re sending our client position directly to the server, and we are broadcasting that position back to the rest of the connected players.

Why is this dangerous? Mainly because client side is easily manipulatable. Moreover, anyone can change javascript files, meaning that a hacker can easily manipulate their position in the game through changing our javascript file, which will harm the game experience of all the other players.

What’s a solution then? We can make our game “Server Authoritative”. This means that all the important data is stored and calculated in the server. We can make our game more secure by sending inputs to the server instead of the position. And then, we can calculate the new position of the player and broadcast it to other players. However, there is one problem. Note that we are using physics for following mouse pointers. It’s not as simple as pressing the arrow keys to move the player. This means that we need a physics system in the server as well!."

Read More

Learn to code and lead your intrepid crew on a mission to save The Cloud in TwilioQuest, a PC role-playing game inspired by classics of the 16-bit era. Free forever, and available now for Windows, Mac, and Linux.

The first book on the creation of HTML5 cross platform games using Phaser 3 and other free software.
  • By Emanuele Feronato
  • 155 Pages
  • 28 Source Code Examples
  • Build a complete game from start to finish
  • Cross Platform
  • Scaling for devices
Buy Now