6 ms·
Tetris in PostScript
- beefburger 2y agoI've just implemented Tetris in PostScript, pushing the limits of a document-processing language to run a realtime game. It works in GhostView on macOS. * 600 lines / 10 KB * 69 different PostScript operators, no external libs * Realtime input, direct drop, increasing speed levels * 7-tetrimino random bags * Nintendo-style scoring and high score tracking This project builds on my earlier experiments with PSChess and PSSokoban. It show that PostScript is a lightweight, expressive, and surprisingly interactive programming language. A perfect tool for hacking on unexpected platforms.
- yodsanklai 2y agoCool! I didn't know that postscript supported interactive content. I thought the code would be generating the document and that's it.
- hamburglar 2y agoWell, it really doesn’t. This uses a clever hack where you write the input to a text file that the PS program is continuously reading. Very cool.
- cenamus 2y agoPS was actually used for OS graphics multiple times (with more adaptions of course) https://en.m.wikipedia.org/wiki/Display_PostScript https://en.m.wikipedia.org/wiki/Display_PostScript
- hamburglar 2y agoYes but using raw postscript in this perverse way to get interactivity is truly inspired. My hat is off to the author.
- pjmlp 2y agoNot really, that is exactly how it was used in Sun NeWS. https://en.m.wikipedia.org/wiki/NeWS https://en.m.wikipedia.org/wiki/NeWS You would write full blown GUI apps in Postscript with some C glue.
- codr7 2y agoIt's actually a pretty cool language, a forthy lisp/lispy forth.
- bobajeff 2y agoThis is pretty neet. Tried running it with ghostscript under Linux and it crashes pretty much after the first tetromino falls a square.
- zzmmm 2y agoAnyone remember NeWS - Network extensible Window System? It was built in Postscript. http://dev.rsnous.com/dewdrop/executive/ http://dev.rsnous.com/dewdrop/executive/
- pjmlp 2y agoI surely do, all my favourite UNIXes went the extra mile to not be yet another clone, embraced better GUI development approaches, and additional userspace stack. Unfortunately only one of them survives to this day.
- cafeinux 2y agoIn two weeks we'll see "Doom in PostScript" pop on the homepage.
- kristianp 2y agoIs there a C to PS transpiler?
- OhMeadhbh 2y agoThere's already Doom in PDF... https://github.com/doom-pdf/ https://github.com/doom-pdf/ And Linux in PDF... https://github.com/ading2210/linuxpdf https://github.com/ading2210/linuxpdf
- cafeinux 2y ago...but not in PostScript (I didn't know about Linux in PDF, gotta check it out)
- WCSTombs 2y agoThis is very cool! To run this on a modern Linux, install Ghostscript and run it like this: gs -dNOSAFER tetris.ps In another terminal in the same working directory, run the command it gives in the source file: stty raw -echo; cat >> t.txt Keep the second terminal focused for your keyboard inputs. I don't know if there's an elegant way to quit, but I just close the Ghostscript window and kill the second terminal.
- deleted 2y ago[deleted]
- redbell 2y agoSomehow, this reminds me of Tetris in a PDF: https://news.ycombinator.com/item?id=42645218 https://news.ycombinator.com/item?id=42645218
- DrNosferatu 2y agoIs there any PS web reader that can run it? (WASM or otherwise)