Tutorial Β· 5 steps Β· arcade kit

Make an arcade game with AI

Did you ask an AI for an arcade game and die to a rock that never touched you? Or get a player that slides off the edge of the screen and never comes back? An arcade game is a loop that spawns things, moves them and checks what hit what, sixty times a second. Ask for all of it in one go and you can't tell which part broke.

The arcade kit is Gem Dash, and all of that already works in it. Your runner never stops. Tap, or press Space, to turn around, dodge the falling rocks and grab gems for 10 points each. Your best score stays saved, and the whole game is one file of plain canvas. The five prompts below turn it into Night Flight, a small bird dodging icicles under the stars. Swap in your own theme as you go.

Bamboo Panda and STARWING on this shelf play on the kit's two moves, dodge one thing and grab another. Gravity makes grabbing the whole game.

Step 1: Change the theme

Read index.html. It is a canvas 2D dodge-and-collect arcade game with one-button controls and a high score in localStorage. Change the theme to a night sky: the player is a small bird, the hazards are falling icicles and the pickups are stars. Draw everything with canvas shapes, no image files. Keep everything in index.html.
What you see

the same tap to turn, with a small bird under a night sky. Icicles fall where the rocks were and stars drop in place of the gems.

Want a pixel bird in place of the shapes? Draw one in the pixel sprite maker and press Copy as code. The game still needs no image file.

If it goes wrong

an icicle kills the bird when it looks like a clear miss. The new drawings came out smaller than the old hit areas. Paste this:

Icicles hit the bird when they look like a clear miss. Size the bird's hit circle and each icicle's hit area to the shapes drawn on screen, a little smaller rather than bigger.

Step 2: Make it harder over time

Make the game get harder the longer it runs. Every 15 seconds the hazards fall 10% faster and appear more often. Show the level number in the top left corner, and flash "Level up" in the middle of the screen when it changes.
What you see

a level number in the top left corner. Every 15 seconds "Level up" flashes in the middle and the icicles come down faster.

If it goes wrong

you press Play again and start on level 5, as fast as the round you just lost. Paste this:

A new round starts on the level where the last one ended. Reset the level, the fall speed and the spawn rate to their starting values every time a round starts.

Step 3: Add juice

Add juice. A short screen shake when the player is hit, a burst of small particles when a pickup is collected, and a score that pops bigger for a moment each time it goes up. Keep it at 60 frames a second on a phone.
What you see

the screen jolts when an icicle gets you, each star bursts into sparks and the score jumps for a moment as it climbs. Game makers call these small touches juice.

If it goes wrong

the game stutters on a phone after a minute of play. Old particles never get removed, so the list grows with every star. Paste this:

The game slows down on my phone after a minute. Remove each particle when it fades out, and never keep more than 150 particles on screen at once.

Step 4: Add sound

Add sound with the Web Audio API only, no audio files: a blip for each pickup and a crash on a hit. Start the audio on the first tap or key press, and add a mute button that remembers its setting in localStorage.
What you see

a blip on every star and a crash when an icicle gets you. Mute it, reload, and it stays muted.

Want a blip of your own? Make one in the sound effect maker and copy it as code. It plays with no audio file.

If it goes wrong

the crash plays over and over in a buzz, or two blips stack into one loud one. The game plays the sound on every frame the shapes overlap. Paste this:

The crash sound repeats while the bird and the icicle overlap. Play each sound once per event: once when a star is collected and once when the round ends.

Step 5: Add a game over screen

Add a game over screen with this run's score, the high score, a Play again button and a Share button. Share uses navigator.share when it exists and copies "I scored 1,240 in Night Flight" with the page address to the clipboard when it doesn't.
What you see

your score and your best side by side when a round ends, with Play again and Share under them. On a phone, Share opens the share sheet.

If it goes wrong

the share line says 1,240 every time, whatever you scored. The AI copied the number from the prompt. Paste this:

The share text always says 1,240. Put this run's score in the share text in place of the example number, with commas for thousands.

Where makers took it

Bamboo Panda, switch stalks, squash ladybugs

Bamboo Panda

Switch between three bamboo stalks to dodge the bugs, then time a panda drop to squash ladybugs. Plays with touch or a keyboard.

@aiscannerSee the game
STARWING, arcade space shooter, four weapons

STARWING

Dodge enemy waves and grab power-ups in an arcade space shooter with four weapons to switch between. Played on a keyboard.

@arisonghadaSee the game
Gravity, start as a pebble, end as a black hole

Gravity

Start as a pebble and eat anything smaller than you, from asteroids up to stars, until you become a black hole. Plays on phones.

@hertzmcSee the game

Put it on the shelf

Got a round your friends want to beat? Get the game a public link with the hosting tutorial, then send it to us. Listing is free. Your game gets its own page and a place on the arcade shelf.

Submit your game

FAQ

Do I need to know JavaScript to make an arcade game with AI?

No. The kit already runs the game loop, the hits and the score, and the AI reads that code before it changes anything. When a round feels wrong, tell the AI what you saw in plain words, like "the icicle hit me from a bird's width away".

Will my arcade game work on a phone?

The kit does. It takes one input, a tap anywhere on the game or Space on a keyboard, so a phone needs no extra buttons. Play a round on your phone after each prompt. Step 3 adds particles, and a slow phone feels those first.

Why does my AI game run faster on some screens?

A game that moves things a fixed amount each frame runs twice as fast on a 120 Hz screen as on a 60 Hz one. The kit moves everything by the time since the last frame, so a round plays the same on any screen. If a change breaks that, ask the AI to move every object by the time passed since the last frame.