Multiplayer tutorial 3: pong

18

Index

Stats

31,275 visits, 109,685 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 22 Apr, 2014. Last updated 11 Jan, 2022

This tutorial assumes you have already read both Multiplayer tutorial 1: concepts and Multiplayer tutorial 2: chat room.

The first tutorial covered the theory of how multiplayer games work and the way they need to be designed, using techniques like local input prediction and lag compensation. The second tutorial covered a practical example of a chat room, which dealt with practical use of signalling, connectivity and sending messages. This tutorial will now cover a simple case of synchronising objects in real-time for a 2-player multiplayer pong game. This is an advanced tutorial; if you are not already comfortable with your knowledge, consider revising the prior tutorials.

To get going, open the Multiplayer - pong example that comes with Construct. As with the previous tutorial, the project will be described event-by-event in more detail than the comments already in the project.

Running and testing

As with the chat example, the real-time game example must also be run from the first layout (F4), since it needs a valid name entered from the Login layout.

This example uses auto-joining rooms. As players join the game they are paired up in to games, since it only works with two players per game. This is described in more detail later. If you join the game you may find another person running the tutorial at the same time by chance; if not, or you cannot connect to them, try testing with a friend or just opening two browser windows side-by-side.

Next Tutorial In Course

Multiplayer tutorial 4: real-time game 25:38

Learn the advanced concepts of real-time multiplayer games, including input prediction and lag compensation.

  • 4 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Re: "Sync object will automatically create and destroy objects, but when they are created we need to set their peerid instance variable so we can later know which peer the object represents."

    => Why don't we use the Sync instance variable action in order to complete the Paddle object synchronization with its peerid instance variable value?

  • does this tutorial still work? if i am a host i don't see the peer movement

  • как сделать систему очков?хочу чтобы счет у двоих показывало