My Perfect Tetris

Project’s GitHub Repo



What Is This

Tetris is a legendary game and one that I enjoy very much. I really love the game and enjoy playing it. It is a great stress reliever. For a fun weekend project, I decided to build the game as a browser game/app designed for both Desktop and Mobile, using the principles of vibe coding. The mobile side of this version was inspired by Play-Tetris, which has a really nice mobile setup with its swipe-based controls. Check out and play my implementation of Tetris here, it’s what I think is the most “perfect” version of Tetris.



gameplay of my version of tetris, play it for yourself here

Beyond The Code

I did not set out to build a Tetris clone as a portfolio project or to learn something new. I built it because I genuinely needed it. When I am stressed, whether it is a rough week at work or just life piling up, Tetris is one of the few healthy things that actually helps me reset. When I am stressed I tend to eat a lot, which adds up over time, so having something that works without any downsides is a big deal for me. Just 10 to 30 minutes of dropping blocks and my brain feels like it has been cleaned out a little. It is not just casual unwinding for me, it is a way to have something simple and focused to pour that stress into. There is even some cool research showing Tetris can affect how the brain handles intrusive memories and stress, for example in trauma film experiments, in people treated after real accidents, and as a supplement to therapy with measurable brain changes. I am not trying to turn this game into a medical treatment, but it is cool to see that there might be real science backing up what I already feel, that Tetris can genuinely help people deal with stress.

So I went looking for a good version of Tetris to play, and the problem was that nothing out there really fit how I wanted to play. Mobile apps on the iOS App Store are full of ads and microtransactions. Web versions were laggy or felt terrible on a phone. The classic NES version is great but needs an emulator and extra hardware. I even bought a Miyoo Mini thinking it would solve the problem, and all I ended up doing was carrying around a second device just to play Tetris. At some point I realized I was spending more time looking for the right version than it would take to just build one.

With modern browsers, LLM tools like Claude Code, and workflows like vibe coding, it finally felt like the right time to build the Tetris I wanted myself. Fast, minimal, no ads, no accounts, no app store. Just a browser game that works on my phone and my laptop and that I fully control. In about a day I had a working version, and after about a week of on and off work to make it robust and get the feel right on both desktop and mobile, I was happy with it.

I am sharing it because if it ends up helping even one other person destress the way it helps me, that would make me really happy. It is a small thing, but sometimes a small thing is exactly what you need.

Features

  • Classic 10x20 Tetris board
  • Full keyboard controls on Desktop and touch gesture controls on Mobile
  • Standard seven-bag piece randomizer
  • Hold piece and next piece previews
  • Ghost piece projection showing where pieces will land
  • Level-based speed curve with dynamic lock delay
  • Score, lines, level, and high score tracking persisted to local storage
  • Soft drop and hard drop scoring
  • In-game menu with resume, restart, quit, mute music/SFX, and source code link
  • Line clear flash animation with sound effect
  • iOS safe area support (Dynamic Island, notch, home indicator)
  • Offline support via Service Worker (works without internet after first visit)
  • Installable as a PWA (add to home screen on iOS/Android for app-like experience)

Controls

Desktop (Keyboard)

Action Keys
Move or A D
Soft Drop or S
Hard Drop Space
Rotate CW W X
Rotate CCW Z
Hold C or LShift
Menu Esc or M
Source Code G (title screen)

Mobile (Touch)

Action Gesture
Move Swipe left / right
Soft Drop Hold and drag down
Hard Drop Quick flick down
Rotate CW Tap
Hold Quick flick up

Difficulty Curve

The speed curve and lock delay in this version were tuned using research into how classic and modern Tetris games handle difficulty progression. In the original NES Tetris, gravity reaches one row per frame at level 29, which became the famous “kill screen” where the game becomes effectively unplayable for most humans. That was not really a designed ending, it was more of a side effect of the hardware and how DAS (Delayed Auto Shift) was too slow to keep up with the drop speed. Willis Gibson proved this in 2024 when he pushed past it and crashed the game at level 157.



gameplay of the classic 1989 nes tetris (original source)

Modern games like TGM (Tetris: The Grand Master) solved this differently. Instead of just making pieces fall faster until the game breaks, TGM caps gravity at 20G (instant drop) and then tightens other timing windows like lock delay and DAS to increase difficulty. The Tetris Guideline standard uses 500ms lock delay with up to 15 move resets, which this version follows. Research into TGM2 Death mode and TGM3 Shirase showed that the practical floor for competitive play is around 250ms of lock delay with fast DAS, while anything below 133ms is specialist territory.

Based on all of this, the speed curve here caps gravity at 33ms per row (similar to NES levels 19 through 28) instead of going to instant drop, and DAS scales from 170ms down to 100ms at higher levels so you can traverse the board during lock delay. The goal was to make high levels feel brutally fast but still fair, closer to how Tetris 99 and TGM handle endgame difficulty rather than the original NES approach of just letting raw speed outrun your inputs.

Under The Hood

  • Responsive design optimized for both Desktop and Mobile (portrait)
  • Pre-rendered block sprites and grid background for performance
  • Uses Super Rotation System (SRS) style wall kicks for piece rotation
  • Velocity-based touch gesture detection for reliable flick vs drag distinction
  • Level-based timing system for gravity speed and lock delay
  • High scores and audio settings persisted with localStorage
  • Background music source NmCCQxVBfyM
  • Line clear sound effect source UMViM2tHrOk
  • The project is fully open-source under the MIT License
  • Built with the following AI tools:

Final Thoughts

This was one of those projects where the motivation was not technical, it was personal. I just wanted a version of Tetris that worked the way I wanted it to, without ads, without extra hardware, and without relying on someone else’s app that could disappear or change at any time. The fact that I was able to go from idea to a polished game in about a week of on and off work using modern AI tools and vibe coding says a lot about where we are right now with software development.

I have been using this version almost daily since I built it, and it still does exactly what I need it to do. It helps me step away from whatever is stressing me out, focus on something simple for a few minutes, and come back with a clearer head. If you give it a try and it does the same for you, that is the best outcome I could ask for. And if you want to fork it, tweak the speed curve, change the controls, or build on top of it, go for it. If you find a bug or have a suggestion, feel free to open an issue on the GitHub repository. That is the whole point of making it open-source.