A network snake game synchronization made with nodejs and socket.io.
A live demo is hosted on: https://apps.yunzhu.li/snake
master
- For low-latency networks (<100ms RTT). Simple and robust.
rollback_and_prediction
- For high-latency networks. Using rollback & prediction
non-blocking synchronization.
It is very easy to run this containerized app.
-
Make sure you have
docker
anddocker-compose
installed on your local environment. -
Clone this repo, in the repo root, run:
docker-compose up -d
-
Access
http://localhost:8000
in your browser. -
Play!
-
If you run it on remote server or play with others:
- Find this line in
client/snake_client.js
:
var socket = io('http://127.0.0.1:8000', { path: '/socket.io', reconnectionAttempts: 3 });
- Change the IP address (port) accordingly.
- Find this line in