Back to the blog
Development / DEVELOPMENT NOTES

Tetris.js: falling blocks in JavaScript

A browser version of Tetris, with keyboard controls for moving, rotating, and dropping pieces.

A Tetris.js game in the browser

After experimenting with Tetris for Mega Drive using SGDK, I brought the idea to the browser with a JavaScript implementation.

The project keeps the familiar mechanics of fitting pieces into a board. The demo shows how movement and rotation change the cells occupied by each piece.

A Tetris.js game in the browser

Controls

  • Left and right arrows: move the piece.
  • Up arrow: rotate it.
  • Down arrow: speed up its fall.

Two implementations, the same idea

Comparing this version with the SGDK project helps separate game rules from the platform running them. The board and collision checks remain data-representation problems, even when input and rendering change.

Source code

Explore the project on GitHub

Written by Sergio Soriano

Development, curiosity, and shared projects.

About Sergio Soriano