Encaje

  • Difficulty: Hard
  • Puzzle
  • Classic
Click inside the game to use the keyboard. Open in a new tab

How to play

Four-block pieces fall: rotate, fit them and clear lines. They drop faster with every level.

Arrow keys
move, rotate and soft drop
Space
hard drop
Swipe / tap
move and rotate on mobile

The game runs isolated from the rest of the site. Your high score and settings are saved only in this browser.

How this game was made

This game came out of a single message to an AI. Below: a short prompt to copy and paste, how to get the game as one HTML file, the full prompt that was actually used, and what it was missing.

Ask for it like this

Copy this prompt, paste it into Claude or ChatGPT, and that's it. It's the short version: the minimum for the game to come out playable.

Make me the game of falling four-block pieces you have to fit together, for the browser, with original art.

- Board 10 columns by 20 rows, with the 7 classic pieces in bag order so they don't repeat too much.
- I can move them, rotate them, drop them faster or hard-drop them. When rotating against a wall, the piece shifts over if there is room.
- A complete line disappears; 1, 2, 3 and 4 lines are worth 100, 300, 500 and 800 points times the level. Every 10 lines the level goes up and pieces fall faster.
- The next piece is shown, plus a ghost of where it will land. I can hold a piece for later, once per turn.
- I lose when a new piece has no room to appear.
- Controls: arrow keys, space and C on desktop; swipe to move, tap to rotate and swipe down fast to drop on mobile.
Technical: a single HTML file with the CSS and JavaScript inside, no libraries and no external images, everything drawn on canvas. It should fill the window and be playable with a finger on a phone and with keyboard or mouse on a computer.

Getting it as an HTML file

A game like this is a single file you open with a double click. These four steps are the same in any AI.

  1. 1. Ask for the whole file

    Add this line at the end of your prompt: Give me a single, complete HTML file, nothing cut out, ready to save as index.html and open in the browser. Without it, you often get the code in pieces.

  2. 2. Copy all of the code

    In Claude the game shows up on the side, already running, with a button to copy or download it. In ChatGPT, copy the whole code block: it has to start with <!DOCTYPE html> and end with </html>.

  3. 3. Save it as index.html

    Paste it into Notepad (Windows) or TextEdit in plain text mode (Mac) and save it as index.html. Watch out for .txt: if the file ends up as index.html.txt, it won't open as a page.

  4. 4. Double-click to open it

    It opens in your browser and it's ready to play, with nothing to install and no internet needed. To share it, upload it to any web host or send it by email: it's just one file.

If the game shows up blank, go back to the AI and paste the error from the browser console (right click → Inspect → Console). With that text it fixes it fast.

The full prompt, the one actually used

Longer and more specific: numbers, screens and style details. It's the one that produced exactly this game, unedited. Use it if you want to fine-tune the result.

Diego wrote it in Spanish and it stays in Spanish on purpose: it's the honest record of how the game was made, and a translation would be a prompt nobody used. Claude and ChatGPT understand it as is; add "Answer in English" if you want the game's text in English.

Hazme un juego de navegador llamado "Encaje".

La idea: el clásico de piezas de 4 bloques que caen y hay que encajar para completar líneas, con arte original y sin marcas.

Mecánica:
- Tablero de 10 columnas por 20 filas. Caen las 7 piezas de 4 bloques (I, O, T, S, Z, J, L), en orden de "bolsa" para que no se repitan demasiado.
- Puedes mover la pieza a los lados, girarla, bajarla más rápido o dejarla caer de golpe.
- Al girar contra una pared o contra otra pieza, la pieza se corre un poco si hay espacio (que el giro no se trabe innecesariamente).
- Una línea completa desaparece y lo de arriba baja. 1, 2, 3 y 4 líneas a la vez valen 100, 300, 500 y 800 puntos, multiplicados por el nivel.
- Cada 10 líneas sube el nivel y las piezas caen más rápido.
- Se ve la siguiente pieza y una sombra que marca dónde va a caer la actual.
- Se puede guardar una pieza para después, una vez por turno.
- Pierdes cuando una pieza nueva no tiene espacio para aparecer.

Pantallas: título con Jugar; el juego con HUD (puntaje, récord, nivel, líneas, siguiente y guardada); pausa; y fin con reintentar.

Controles: en PC, flechas izquierda/derecha para mover, flecha arriba para girar, flecha abajo para bajar rápido, Espacio para caída instantánea y C para guardar. En celular, deslizar a los lados para mover, tocar para girar, deslizar hacia abajo para bajar rápido y un deslizamiento rápido hacia abajo para caída instantánea, más un botón en pantalla para guardar.

Estilo: bloques con bisel y un color por pieza sobre fondo oscuro, un destello al borrar líneas, y el tablero que tiembla un poco al borrar 4 a la vez.

Técnico:
- Un solo archivo HTML con todo el CSS y el JavaScript dentro. Sin librerías, sin CDN, sin imágenes externas: todo dibujado en canvas.
- Tiene que llenar la ventana y adaptarse a cualquier tamaño, de celular a pantalla grande, sin deformarse.
- Tiene que jugarse completo desde celular (solo con el dedo) y desde PC (teclado o mouse).
- Tiene que funcionar dentro de un iframe con sandbox="allow-scripts". El récord va en localStorage dentro de try/catch para que el juego no se rompa si no hay acceso.
- Se pausa solo cuando la pestaña no está visible.
- El texto del juego va en español.

For ChatGPT, add the line from step 1 at the end: it tends to hand over the code in pieces.

What this prompt was missing

What became clear once the game was finished. If you're making your own from this one, add these from the start: fixing things later costs another round.

  • Ask to see the next 3 pieces instead of one: it changes how you play a lot.
  • Say whether soft drops and hard drops score points, like in the modern versions.
  • Ask for the hard-drop gesture to be tunable, because a real finger is faster than a test.

What was asked after the first result, in Diego's own words (Spanish):

  • Agrégale un menú de pausa, un botón para cambiar entre español e inglés, y que el récord no se pierda al recargar.

It works in any AI

Claude, ChatGPT, Gemini, Copilot: the prompt is the same and so is the method. What changes is where you see the result. Four things that hold in all of them:

  1. Ask for a single file

    "A single HTML file with everything inside, no libraries or CDN." That way the game works with a double click, with nothing to install, and you can upload it to any website.

  2. Ask it to tell you what it assumed

    End with: "before writing the code, tell me in 5 lines what you assumed". That's where the gaps in your prompt show up, while fixing them is still cheap.

  3. One fix per message

    Say what happens and what you expected. If you ask for three changes at once, one usually undoes another.

  4. Ask it to test, not to promise

    "Check that every level can be won and tell me how you checked." That's how the games on this page found their bugs before going live.

The 6 parts of a good prompt, with a template to copy

More games

Ajedrez

Full chess with the real rules: castling, en passant, promotion and draws. Against the computer, two players on one device, or online with a code.

  • Medium
  • Classic
  • Strategy
  • Online

Bola 8

8-ball pool with its own physics: spin, cushions and ball in hand. Against the computer, two players on one device, or online with a code.

  • Medium
  • Physics
  • Sports
  • Online

Kuru

Greedy worms in a night field: eat the seeds, grow long and make the others crash into you. Solo against bots or online with up to 6.

  • Medium
  • Action
  • Arcade
  • Online

Horda

Hold out against waves of shadows in a closed map. Four weapons, exploding barrels and barricades. Solo, two on one keyboard, or online.

  • Hard
  • Action
  • Co-op
  • Online