- PHP >=7.0
- Python >=2.7 (with
pip) - NodeJS >=4.4 (with
npm)
Just run docker-compose build.
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 buildJust execute docker-compose up -d
And go to 127.0.0.1:8080.
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.jsonRun the php broadcast application
php backend/broadcast.phpAnd finally execute nodejs static server
cd frontend
node server.jsAnd go to 127.0.0.1:8080.
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.
- 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.
- Next, we calculate a rectangle hitbox collision, which is slower but still faster than a precise text.
- 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 |

