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 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.

As shown by zooming in, video frames are rendered as rows of ASCII. It’s enough to implement 6-color monochrome and make in-game text legible.

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!

12 thoughts on “Nice PDF, But Can It Run DOOM? Yup!

  1. ISTR PDF is at it’s core Postscript which is, as the article states, a fully functional interpreted language so it’s not really a surprise that you can port Doom to it but it’s impressive all the same.

  2. Interestingly, it doesn’t work in Acrobat DC (the site actually says it only works in Chromium based browsers). If it only works in one web browser, and not in Adobe’s own PDF software, does it count as a proper PDF? If it’s fully compliant with the PDF spec, why can’t Acrobat run it?

    1. Reminds me of “badformer” the platformer written for the typesetting language Typst (by the developers of Typst). You type your motion in as text and the output is rendered as a very basic wireframe game.
      The rendering occurs in real time, and although it can be rendered to a PDF, the PDF would only be the “display”. Rendering is performed at compilation which is triggered by changing the source document text. As I understand it, rendering to PNG is faster than to PDF.

      https://typst.app/universe/package/badformer/

      I suppose it would be possible to extend this all the way to a Doom clone. Render times might get too long though.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.