There is a global community dedicated to finding new ways to challenge themselves Tetrisfrom speedrunning the classic puzzle game to technically ‘beating’ it. But the latest achievement isn’t a newly discovered hidden bug or high score; it’s a whole new way to play the game.
Thomas Rinsmaa security analyst and hobbyist, recently discovered how to create a version of Tetris that is output in a PDF file. According to one personal website message then emphasized by BoingBoing on January 15, Rinsma tackled the project “just for fun” after learning the possible implementations of PDF’s JavaScript API. The result is a new version Rinsma calls PDFTRIS.
“[I] realized there might be enough I/O options for a game,” he wrote. “I/O” stands for “Input/Output” and refers to the communication between a computer and its users.
Rinsma explained that it is already “relatively known” that PDFs can support a number of features, such as dynamic content scripting, when opened in Adobe Acrobat/Reader, for example. However, some of that same script support is also available in both Mozilla Firefox and Google Chrome‘s respective PDF readers, PDF.js and PDFium.
[ Related: Is Tetris infinite? Teen world champ reaches fabled ‘rebirth’ ]
From there, things get a bit complicated for the layman, but anyway, the end result is a PDF with a grid of 10×20 field buttons. These alternate between shaded and empty blocks depending on the JavaScript input, allowing a player to use pre-programmed keyboard instructions to move and shift the tetronimos – the official term for four-block shapes, such as those in Tetris blocks.
“It was a bit tricky to find a combination of features that work in both engines, but in the end it turns out that showing/hiding annotation fields works well to create monochrome pixels, and keyboard input can be achieved through a text input box,” wrote Rinsma in a message Hacker news.
Add the ability for the file to automatically loop and reload each command, and you have a functional game Tetris. It even speeds up as your score increases. Anyone interested to watch below PDFTRIS‘s Hood can view Rinsma’s open source files available at GitHub.
For those in the know, the ability to play a video game in a PDF file requires something very specific program community question. As luck would have it Rinsma already has the answer: Yes, PDFs can also be output Fate.