Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Latest commit

 

History

History
91 lines (59 loc) · 1.92 KB

README.md

File metadata and controls

91 lines (59 loc) · 1.92 KB

Sn4k3 - next generation MMO

Frendly snek

Frendly snek demo

Documentation index

Requirements (if you don't have Docker)

  • PHP >=7.0
  • Python >=2.7 (with pip)
  • NodeJS >=4.4 (with npm)

Install

With Docker

Just run docker-compose build.

Without Docker

Execute all these commands directly from the root directory of the repository.

pip install crossbar
composer --working-dir=backend install
cd frontend
npm install
npm run build

Run

With Docker

Just execute docker-compose up -d

And go to 127.0.0.1:8080.

Without docker

You will need at least 3 terminals for this, because all apps need to be run independently.

Run Crossbar middleware instance

crossbar start --config=crossbar/config.json

Run the php broadcast application

php backend/broadcast.php

And finally execute nodejs static server

cd frontend
node server.js

And go to 127.0.0.1:8080.

Bottlenecks

Collisions

On EVERY tick, the app checks collisions for every "snake head vs any other object".

In this case, we make other naive/less precise assumptions.

  1. First, we check the distance between each object's center (because we're making comparisons on circles, most of the time). It's very fast because it just compares two values.
  2. Next, we calculate a rectangle hitbox collision, which is slower but still faster than a precise text.
  3. And finally we make a geometrical comparison of circles, which is very slow.

Here are some benchmarks about this:

Assumption type   Naive Rectangle Circle
Total calculations 200000 70000 20
Average time 1500 8300 18000