{"id":17290158,"url":"https://github.com/noisebynorthwest/term-asteroids","last_synced_at":"2025-10-16T08:22:55.685Z","repository":{"id":179506529,"uuid":"663573305","full_name":"NoiseByNorthwest/term-asteroids","owner":"NoiseByNorthwest","description":"An Asteroids-like game, running in a terminal, written in PHP","archived":false,"fork":false,"pushed_at":"2025-08-26T16:05:33.000Z","size":4845,"stargazers_count":49,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T13:29:48.225Z","etag":null,"topics":["2d-game","cli-game","console-game","game","shooter","terminal","terminal-game"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NoiseByNorthwest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-07-07T15:56:56.000Z","updated_at":"2025-08-26T16:05:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb787355-f70c-490e-9e59-9b6f47403284","html_url":"https://github.com/NoiseByNorthwest/term-asteroids","commit_stats":null,"previous_names":["noisebynorthwest/term-asteroids"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NoiseByNorthwest/term-asteroids","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoiseByNorthwest%2Fterm-asteroids","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoiseByNorthwest%2Fterm-asteroids/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoiseByNorthwest%2Fterm-asteroids/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoiseByNorthwest%2Fterm-asteroids/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NoiseByNorthwest","download_url":"https://codeload.github.com/NoiseByNorthwest/term-asteroids/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoiseByNorthwest%2Fterm-asteroids/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279169467,"owners_count":26118428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d-game","cli-game","console-game","game","shooter","terminal","terminal-game"],"created_at":"2024-10-15T10:37:11.515Z","updated_at":"2025-10-16T08:22:55.669Z","avatar_url":"https://github.com/NoiseByNorthwest.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TermAsteroids\n\n_An Asteroids-like game, running in a terminal, written in PHP._\n\n![Showcase](assets/demo.gif)\n\nTermAsteroid is a horizontal scrolling [Asteroids](https://en.wikipedia.org/wiki/Asteroids_(video_game))-like game which has the following particularities:\n- it runs in a terminal emulator.\n- it is fully implemented in PHP (except for the alternative and optional rendering backend described below).\n- it features 2 rendering backends (and can switch between the 2 at runtime):\n  - one implemented in PHP.\n  - one implemented in C and called through [FFI](https://www.php.net/manual/en/book.ffi.php).\n- it highlights the benefits of:\n  - using FFI in order to reimplement a tight loop, as long as it significantly outweighs the PHP / FFI communication overhead. This is the case here since the main data movement is between the renderer and PHP's output buffer. \n  - PHP's JIT for such (CPU-bound) application and especially how it boosts the PHP rendering backend, making it roughly 3 times faster.\n  - PHP's cycle collector control functions which allow to disable it before entering a critical game loop and re-enable it later in non-critical parts.\n- it renders early 90s style 2D graphics featuring:\n  - 300x144 true color (24bpp) screen with a pixel change rate of (using kitty as terminal emulator):\n    - 1.5+ MPixel/s with the PHP renderer.\n    - 4+ MPixel/s with the PHP renderer and JIT enabled.\n    - 9+ MPixel/s with the native renderer.\n  - hundreds (500+) of animated sprites rendered per frame, with a sprite fill rate of:\n    - 2+ MPixel/s (~500ns/pixel) with the PHP renderer.\n    - 6+ MPixel/s (~167ns/pixel) with the PHP renderer and JIT enabled.\n    - 30+ MPixel/s (~33ns/pixel) with the native renderer.\n  - transparency, distortion and persistence effects.\n  - procedural bitmap / animation generation via [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise).\n  - pre-rendered sprite rotations.\n  - adaptive performance in order to preserve a minimal framerate of 45 FPS:\n    - non-gameplay objects (flames, smokes) reduction\n    - color reduction \u0026 gradual dithering in replacement of transparency\n\n## Requirements\n\n- Linux\n- Docker\n- A fast terminal emulator with Unicode \u0026 true color support and an adjusted font size so that a maximized window will render at least 300 columns x 77 rows\n  - [xterm](https://invisible-island.net/xterm/) meets these requirements and is embedded in the Docker image\n  - [kitty](https://sw.kovidgoyal.net/kitty/) \u0026 [Alacritty](https://alacritty.org/) are recommended and must be already installed on your host since they are GPU-powered\n  \n## Getting started\n\n### Install \u0026 run\n\n```shell\ngit clone https://github.com/NoiseByNorthwest/term-asteroids.git\ncd term-asteroids\nmake run\n```\n\n\u003e 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.\n\n### Uninstall\n\nThis command will remove the Docker containers and images, and will remove everything under `${PWD}/.tmp` \n\n```shell\nmake clean\n```\n\n## Terminal\n\n### Default\n\nBy default, kitty will be used as terminal emulator if it is found on your host, otherwise xterm (installed in the Docker image) will be used.\n\n### Forcing another terminal\n\nRun one of these commands:\n\n```shell\nmake select.term.xterm\nmake select.term.rxvt\nmake select.term.gnome-terminal\nmake select.term.kitty\nmake select.term.alacritty\n```\n\nAnd then:\n\n```shell\nmake run\n```\n\nThe best terminals for rendering speed are kitty and Alacritty. kitty is the best overall terminal since it also supports keyup event. \n\n## Controls\n\n- **UP arrow** / **Numpad 8**: move the spaceship up\n- **DOWN arrow** / **Numpad 5**: move the spaceship down\n- **LEFT arrow** / **Numpad 4**: move the spaceship left\n- **RIGHT arrow** / **Numpad 6**: move the spaceship right\n- **p**: pause / resume\n- **Esc** or **q**: quit\n- **s**: reset\n\n_N.B.: If the selected terminal is kitty, you will have a better experience using numpad keys to move the spaceship because keyup event is supported for these keys._\n\n## Goals\n\nSurvive as long as possible:\n- use the arrow keys to move the spaceship\n- avoid collision with the asteroids\n- collide with bonuses, they give one third of your health and improve one of your 3 weapons\n- the fourth bonus, which is yellow, will not improve one of your weapons or increase your health, but rather give you few seconds of bullet time \n\n## Other running mode\n\nDefault mode (native renderer + JIT)\n\n```shell\nmake run\n```\n\nRun it without JIT\n\n```shell\nmake run.nojit\n```\n\nRun it with PHP renderer\n\n```shell\nmake run.full_php\n```\n\nRun it with PHP renderer and without JIT\n\n```shell\nmake run.full_php.no_jit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoisebynorthwest%2Fterm-asteroids","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoisebynorthwest%2Fterm-asteroids","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoisebynorthwest%2Fterm-asteroids/lists"}