NoiseByNorthwest / term-asteroids

An Asteroids-like game, running in a terminal, written in PHP
MIT License
37 stars 2 forks source link
2d-game cli-game game shooter terminal terminal-game

TermAsteroids

An Asteroids-like game, running in a terminal, written in PHP.

Showcase

TermAsteroid is a horizontal scrolling Asteroids-like game which has the following particularities:

Requirements

Getting started

git clone https://github.com/NoiseByNorthwest/term-asteroids.git
cd term-asteroids
make run

The first make run execution will take some time (building the Docker image, warming up some caches...) before starting the game, but the next executions will start instantly.

Controls

Goals

Survive as long as possible:

Other running mode

Game modes

Default mode (native renderer + JIT)

make run

Run it without JIT

make run.nojit

Run it with PHP renderer

make run.full_php

Run it with PHP renderer and without JIT

make run.full_php.no_jit

Dev mode

The dev mode gives nearly infinite health and more controls (see below). The difficulty level also increases faster.

make run.dev

Additional controls:

Benchmark

This game comes with a benchmark mode which allows to highlight the performance differences between the four optimization levels (PHP/native renderer combined with JIT on/off).

Running it

To run all benchmark and generate the Markdown report:

make run.benchmark.all

Results

PHP version: 8.2.6

CPU: Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz

Native Renderer + JIT Native Renderer PHP Renderer + JIT PHP Renderer
Execution time 20.7s 20.9s 20.7s 20.9s
Rendered frames 909 746 609 369
Average frame time 22.7ms 28.0ms 33.9ms 56.7ms
Average framerate 44.0 FPS 35.7 FPS 29.5 FPS 17.6 FPS
Average gameplay+physic time 7.0ms 11.0ms 7.8ms 13.5ms
Average rendering time 15.8ms 17.0ms 26.1ms 43.2ms
Average drawing time 1.7ms 1.9ms 7.6ms 20.7ms
Average update time 1.1ms 1.2ms 5.4ms 11.1ms
Average flushing time 13.0ms 13.9ms 13.1ms 11.4ms

Time breakdown explanation: