Doom

Yes, we all know that good old classic game.

Can it run inside a PDF?

Not streamed.

Not embedded.

Actually running inside a PDF file.

Get the PDF from this link.

Try it out for yourself.

How is this even possible?

It uses old-school C code, compiled with an ancient Emscripten targeting asm.js.

Inputs?

PDF text fields.

The hard part?

The framebuffer.

DOOM runs at 320x200 resolution.

You’d need 64,000 text fields to fake that pixel-by-pixel.

Totally impractical.

So instead, this version uses one text field per row.

Then it fills each with ASCII characters to show the game frame.

Monochrome, six-color output.

Runs at ~80ms per frame.

Is it fast? Nope.

Is it smooth? Nope.

But it’s dope 😄

Originally shared on LinkedIn

Subscribe to Vishnu Santhosh – Engineer, Writer, Technologist, YouTuber

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe