All posts

Case Study: Building a Playable Tetris Game with Gemini

tetris.hostilo.page is a Tetris game written by Google Gemini, in one HTML file, without a line of code typed by hand. It didn't work on the first try. We're writing this one up because of that, since most "AI built my app" stories skip the part where it's broken.

What we asked for

A playable Tetris in a single HTML file, made only by prompting. Falling pieces, rotation, clearing full lines, keyboard controls. On paper that's a small project. In practice it's closer to an app than a website, because the page has to keep track of a board, a moving piece and a score, sixty times a second.

What went wrong

The first version from Gemini looked right and played wrong. Game logic is full of edge cases that only show up when you actually play: a piece rotating into a wall, two pieces touching at a corner, several lines clearing at once. Each of those needs code that's correct in situations a quick test won't hit.

So it took several rounds. We'd open the file in a browser, play until something broke, describe the problem to Gemini and paste the corrected file back in. Describing what you see on screen gets better fixes than a general complaint. "The long piece goes through the right wall when I rotate it" gives the model something to work with; "rotation is broken" doesn't.

What the game does now

The version online today is about 900 lines, with roughly 28 KB of JavaScript. It has:

The interface is in Polish, because it's part of a small set of logic games we host at games.hostilo.page.

Where Hostilo came in

At the very end. All the back-and-forth happened in the chat with Gemini, with the file tested locally between rounds. Once a version played properly, we pasted it into the Hostilo editor and clicked Save, and it was live at its address with HTTPS. Any later fix goes the same way, and the previous version stays in the history in case a "fix" makes things worse.

If you're building something interactive

Expect a few rounds before it works, and do them before you publish. Test in a real browser, on a phone too if people will play on one. Describe bugs by what you see rather than what you think the code does. A landing page might work on the first answer; a game, a calculator or anything that remembers state usually won't. Our restaurant case study is the opposite example.

Frequently asked questions

Which AI wrote tetris.hostilo.page?
Google Gemini. Nobody wrote the game code by hand; it came out of several rounds of prompting, as a single HTML file.

Did it work on the first try?
No. The first version had bugs in the game logic. It took a few rounds of describing what went wrong and asking Gemini for a fix before the game played properly.

Can Hostilo host games and other interactive pages?
Yes. A game in one HTML file with its JavaScript inside works on Hostilo the same way as a landing page. The best score in this game is kept in the player's browser, so no server is needed.

Where did the time go?
Into the rounds of fixes in the chat with Gemini. Publishing the finished file was a single step: paste it into the editor and save.

Publish your own game

Paste the HTML from Gemini, ChatGPT or Claude and get a link you can send to friends. The free plan needs no card.

Create a free account

Related guides

More from the blog