GitHunt
NS

nst/PSTris

A Tetris implementation in PostScript

PSTris

A Tetris implementation in PostScript

Motivation

  • implement a realtime game in PostScript
  • play it in Ghostscript on macOS

See also:

Features

  • 600 lines, 10 KB of PostScript
  • 69 unique operators
  • realtime input
  • direct drop
  • levels with increasing speed
  • 7-tetriminos random bags
  • high scores
  • Nintendo scoring scheme
  • sound through external MIDI synthetizer

Play Tetris in Ghostscript

Terminal window 1:

$ gs -sNOSAFER tetris.ps

Terminal window 2:

$ stty raw -echo; cat >> t.txt

Play with arrows and space bar in window 2.

Sound (Optional)

The program write MIDI commands in midi.bin.

You can read midi.bin from a helper script to send the commands to a synthetizer.

On macOS, you can use GarageBand and the brigde midi.py:

1. in "Audio MIDI Setup" application, open "IAC Driver" and check "Device in online"
2. in "GarageBand" application, create a new empty project with a MIDI track. "8-Bit Grit" instrument works fine.
3. run `tail -f midi.bin | python3 midi.py`

Notes and Limitations

Some implementation details inspired from MeatFighter.

Languages

PostScript95.7%Python4.3%

Contributors

MIT License
Created February 18, 2025
Updated November 28, 2025
nst/PSTris | GitHunt