Nice PDF, But Can It Run DOOM? Yup!
DOOM is a classic game to implement on a variety of platforms, but doompdf by [ading2210] is one we didn’t see coming. It runs a bit slow and controls are …read more
DOOM is a classic game to implement on a variety of platforms, but doompdf by [ading2210] is one we didn’t see coming. It runs a bit slow and controls are a little awkward but it does run. Entirely within a PDF file, at that.
How is this possible? PDFs are technically capable of much more than just displaying static content, and support JavaScript with their own library of functions. Adobe Acrobat implements the full spec, but modern web browsers implement at least a subset of the functionality in a sandboxed JavaScript runtime environment. Input and output are limited to things one might expect from a fancy PDF form (text input boxes, clickable buttons, things of that nature) but computation-wise, just about anything goes.
The playable DOOM PDF therefore implements keyboard input by reading characters typed into a text entry box, or has the user click buttons with the mouse. It’s not the smoothest of input methods but it’s gloriously hacky. What’s even better is the video output, which is essentially ASCII-art video frames. Zoom in and you’ll see for yourself! It’s not the fastest frame rate, but it’s fantastic all the same.
This project was partly inspired by Tetris in a PDF which demonstrated a lot of the concepts used, and if you like electronic document related shenanigans, be sure to check out playing chess against your printer with PostScript. PostScript is actually a fully functional interpreted language, but unlike JavaScript it was never intended to be used directly by humans.
Thanks to everyone who sent this to our tips line!