Building a multiplayer game server

and keeping (most of) your hair

@OpherV
I.T.A.K.E Unconference May 2017

What if there was

a better way to play games?

 realtime multiplayer game running in the browser

@opherv

Hi! I'm Opher

I'm a creative developer at Eko

 

http://lance.gg

anatomy of a game

 

@opherv

while (true)
{
  processInput();
  updateGameState();
  render();
}

Input

0

1

2

3

4

5

6

7

render

game step

8

9

10

11

12

13

14

15

@opherv

peer-to-peer

Why do you even need a server?

Because your players suck

if cheating can happen,

it will happen

authoritative server

@opherv

authoritative server

Run game world

Receive input request

Validate input

Broadcast game state

Why

@opherv

Non-blocking Event I/O 

@opherv

Running the same game code,

both on the server and the client

@opherv

open source

Thriving ecosystem with NPM

@opherv

Web dev == Game dev

@opherv

Browser/Server Communication

 

websockets

WebRTC*

@opherv

io.emit('myEvent',{ x: 15, y: 20, ammo: 20});

Server

socket.on('myEvent', function (data) {
  console.log(data);
});

Client

14,951 km

299,792,458 m / s

Speed of Light

50 milliseconds

Bucharest -> Melbourne

Round Trip Time (RTT) > 100ms

@opherv

Bucharest

Melbourne

Request - 50ms

Reply - 50ms

LAG

Syncing the game world

Game Loop

Render Loop

@opherv

Broadcast Loop

Option 1

client step N

X: 200

client step M

X: 50

Interpolation

The client is in the past

Real Time Strategy

Role Playing Games

client side prediction

bending

Option 2: Extrapolation

30

31

32

33

34

35

36

37

38

39

30

31

32

33

34

35

36

37

38

39

Input

game state

extrapolated

steps

Building a multiplayer game server

and keeping (most of) your hair

Don't worry, here's a
link to a wig store

Building a multiplayer game server

and keeping (most of) your hair

Building a multiplayer game server

and keeping (most of) your hair

@opherv

@opherv

more info: http://lance.gg

@opherv

Free Stickers!

follow me @OpherV

Thanks!

@OpherV

opherv.com

opherv@gmail.com

Building a multiplayer game server and keeping (most of) your hair

By Opher Vishnia

Building a multiplayer game server and keeping (most of) your hair

  • 397
Loading comments...

More from Opher Vishnia