“Play /Bin/Sh Invaders” is a Space Invaders game implemented entirely in POSIX shell, using terminal escape sequences for display and input rather than a graphics library. It recreates the arcade’s 224-by-256-pixel playfield as a fixed 56-column field centered in a terminal, with 24-32 rows available. Game timing follows the original’s 60 frames per second, while positions and projectile speeds are kept in the arcade’s pixel-based coordinate system and translated to terminal rows for drawing and collision checks. Invaders can be shown with emoji and Unicode symbols or in ASCII; the latter is selectable with `-a` and is also used for slow serial connections with `-b`.
The implementation includes moving formations, player shots, falling bombs, shields that show several damage levels, a saucer, collisions, explosions, and successive waves. It preserves arcade details such as allowing only one player shot at a time, pausing the formation while an invader explodes, and starting the next wave 48 frames after the last invader is hit. Terminal setup is handled directly: the game queries the terminal’s dimensions, adapts when it is resized, hides the cursor, and uses the alternate screen. Cleanup traps restore the cursor, screen, and terminal settings even when the game exits after a signal or shell error. Options also include reverse-index cursor movement for terminals where that escape sequence is preferable.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.