@OpherV
I.T.A.K.E Unconference May 2017
realtime multiplayer game running in the browser
@opherv
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
@opherv
@opherv
more info: http://lance.gg
@opherv
Free Stickers!
follow me @OpherV
@OpherV
opherv.com
opherv@gmail.com