Someone got Tetris running in a PDF, and you can play it right now
Summary
Tetris in PDF is an unexpectedly enjoyable game that uses simple controls. Thomas Rinsma created PDFTris inside a PDF document for user-friendly gameplay. Chrome or Firefox allows PDFs to run in a JavaScript sandbox, enabling unique projects like PDFTris.
So we've heard about getting Doom on as many screens as possible, but what about Tetris? We've seen some truly insane implementations of the classic block-stacking game across multiple formats, such as that one time someone made Tetris in Excel. Now, another madman has re-created Tetris in a PDF, and you don't even need to install anything special to play it.
Related
Anbernic RG35XXSP review: A nostalgic design for an excellent retro handheld
The Anbernic RG35XXSP is the latest gaming handheld from Anbernic, and it's a fantastic retro gaming handheld that you can pick up for cheap.
Posts 1
Tetris on PDF is a surprisingly playable version of the iconic game
This awesome feat was the idea of Thomas Rinsma, who posted about the PDFTris project on X. For a game coded within a static document type, it's actually very fun to play; you can move the pieces around, spin them, make them fall faster, and remove blocks by making a line. You can control the blocks using the buttons on the document or by clicking within a text entry field and using WASD controls.
So, that's definitely something else -- but how is it done? Fortunately, Thomas gives away all the details on his blog, th0mas.nl. It turns out that if you open a PDF in Chrome or Firefox, it'll run inside a sandboxed JavaScript runtime. It doesn't give you total control over the PDF, but it gives you enough to work out how to play Tetris on it. And yes, before you ask, Thomas got an ASCII version of Doom running on it, too.
If you want to see how this was done, check out the PDFTris GitHub page for the source.