PDFTris – play Tetris in a PDF

Thomas Rinsma decided to abuse PDF field objects to render monochrome grid, and combine it with keystroke-entry in a text field to receive inputs – that’s how playable Tetris in a PDF file was born.

You can read the blog post about the implementation details from the author himself – the display part is quite interesting:

For Tetris, I just created a 10×20 grid of buttons (they can be styled however you want), which can be shown/hidden from JavaScript by setting their .hidden property, creating monochrome pixels.

var pixel_fields = [];
function game_init() {
	// Gather references to pixel field objects
	for (var x = 0; x < 10; ++x) {
		pixel_fields[x] = [];
		for (var y = 0; y < 20; ++y) {
			pixel_fields[x][y] = this.getField(`P_${x}_${y}`);
		}
	}
	// ...
}
function set_pixel(x, y, state) {
	// ...
	pixel_fields[x][20 - 1 - y].hidden = !state;
}

The game itself is called PDFTris, and the sources are available on GitHub. Keep in mind the game works in PDF.js (Firefox) and PDFium (Chromium-based browsers) - other engines were not tested.

Can it run DOOM?

If you can play Tetris in a PDF, then you should also be able to play DOOM, right? Yes, of course! The PDFDOOM is a thing, and the sources are on GitHub as well.

No Comments

Leave a Reply

Gamedev.js Jam 2026
Gamedev.js Survey 2025 Report
js13kGames 2025 winners
Gamedev.js Shop
Gamedev.js Discord

Follow us

Gamedev.js Weekly newsletter

Or visit gamedevjsweekly.com directly.

Websites worth visiting