Skip to content
VibecodeZero

Can I vibe code a simple game? Is CSS enough, or do I need canvas or a game framework?

Updated

In this guide (9)
  1. Which kind of game needs what?
  2. Is CSS enough?
  3. When does a game need a canvas?
  4. When does a framework like Phaser help?
  5. Good first games
  6. Prompts you can paste
  7. How to test your game on your phone
  8. Common problems and what to ask
  9. What comes next

This guide is for you if you’ve never coded and want your first project to be a game, or if you tried one and it came out slow, blank or broken. It’s about small 2D games that run in a web browser, the kind you can share with a link.

The technical facts come from MDN, Mozilla’s web documentation: the Canvas API, Game development and its tutorials, requestAnimationFrame(), Basic animations, Optimizing canvas, Crisp pixel art look and Mobile touch controls. The facts about Phaser come from its docs: What is Phaser?, Working with Phaser, Arcade Physics and Sprite. The Lovable fact comes from its browser testing docs. We checked all of them on November 2, 2026. The game ideas, the order of the steps and the prompts are our recommendation, not a step from any of those docs. None of the links on this page are affiliate links.

Which kind of game needs what?

Your game What it needs Good for a first project?
You click, tap or choose: a quiz, memory cards, a word puzzle, tic-tac-toe, a “click the cookie” counter Plain HTML, CSS and JavaScript Yes, start here
Things move on their own and bump into each other: Snake, a breakout clone, catching falling objects An HTML canvas, with JavaScript drawing every frame Yes, as a second project
Pixel-art characters with animations, levels and physics: a small platformer Canvas plus a 2D game framework such as Phaser Later, once a simpler game works
3D Phaser’s docs say it’s a 2D framework with no built-in 3D. MDN says 3D in the browser uses WebGL Not as a first project

The first row covers more games than you might think. Anything where the screen only changes after the player does something can be built from normal page parts, like buttons, cards and text.

Is CSS enough?

No, but you don’t need much more. A game has two parts:

  • How it looks. That’s HTML (what’s on the page) and CSS (colors, sizes, layout, and simple animations like a card flipping).
  • How it works. The rules: what happens on each click, when you win or lose, the score, the timer. That’s JavaScript.

MDN’s game development section says making games on the web draws on core web technologies such as HTML, CSS and JavaScript. You won’t write any of it yourself: when you ask an AI tool for a memory card game, it writes all three. What matters is that you ask for the right kind of game for a first try.

When does a game need a canvas?

When something keeps moving even if the player does nothing. MDN describes the Canvas API as a way to draw graphics with JavaScript and the HTML <canvas> element, used among other things for animation and game graphics.

Two things about canvas are worth knowing, because they explain most canvas bugs:

  • The game redraws the whole picture, again and again. MDN’s animation tutorial says that once a shape is drawn on a canvas it stays that way, so to move it you redraw it and everything drawn before it. Each frame clears the canvas and draws everything again.
  • The redraw is tied to the screen. Games usually use requestAnimationFrame(), which asks the browser to call the game’s drawing code before the next repaint. MDN says those calls generally match the screen’s refresh rate, and that most browsers pause them in background tabs to save performance and battery.

There’s one more trade-off. MDN says canvas content isn’t exposed to accessibility tools the way normal HTML is, and that a canvas is better used like an image than for important content. So if your game is mostly text and buttons, like a quiz, plain HTML is the better choice.

When does a framework like Phaser help?

When the game has many moving pieces. Phaser’s docs describe it as a “fast, free, and fun open source HTML5 game framework” that offers WebGL and Canvas rendering across desktop and mobile web browsers. Some facts from its docs:

  • It’s for 2D games. It doesn’t include 3D rendering or 3D physics.
  • It’s a JavaScript library, not an app you install. Your game’s code runs with it in the browser, and it can be added from a CDN or with a package manager like npm.
  • It has ready-made pieces. A Sprite shows static and animated images and can have input events and physics bodies. Arcade Physics is a lightweight physics system, meant for simple things like platformers, top-down games or puzzle games, and it only handles two shapes: rectangles and circles.

In practice, you ask the AI to use Phaser, and it writes the game with it. Plain canvas or Phaser, both are fine for a small game. What helps is to choose once and say it in your first message, so the AI doesn’t mix approaches.

Good first games

Our recommendation, from easiest to hardest:

  1. A quiz about something you know: 10 questions, 3 answers each, a score at the end.
  2. A memory card game: pairs of cards face down, flip two, keep the match.
  3. A word puzzle: guess a hidden word letter by letter, with a limited number of tries.
  4. Tic-tac-toe for two players on the same phone.
  5. A catch game on canvas: move a basket left and right to catch falling objects. Your first game with movement.
  6. Snake or a breakout clone on canvas. MDN’s tutorials include a 2D breakout game in pure JavaScript and the same game built with Phaser, so there’s an official step-by-step version of it if you’re curious.

Keep the first version tiny: one screen, one rule, one way to win. Sounds, levels and a high score table come later, one at a time.

Prompts you can paste

Each prompt follows the shape from Your first app in 30 minutes: who it’s for, what it does, what it needs and what’s left out. Change the details to fit your idea.

A click game with plain HTML:

I want a simple memory card game that runs in the browser. It's for my kids to play on a phone.

It needs:
- 12 cards (6 pairs) face down in a grid, using emoji as the pictures;
- tap a card to flip it; if two flipped cards match they stay open, if not they flip back after one second;
- a move counter and a "You won!" message with a "Play again" button.

Use plain HTML, CSS and JavaScript, with no canvas and no game framework.
For now it doesn't need sounds, levels, login or a high score table.
Big cards that are easy to tap on a phone. All the text in English.

A movement game on canvas:

I want a simple catch game that runs in the browser, on a phone or a computer.

It needs:
- an HTML canvas where fruit falls from the top at random places;
- a basket at the bottom that the player moves left and right, with the arrow keys on a computer and by touching and dragging on a phone;
- 1 point for each fruit caught; the game ends after 3 missed fruits, with the score and a "Play again" button.

Draw simple shapes, no images yet. Base the movement on the time between frames, so the speed is the same on every screen.
For now it doesn't need sounds, levels, login or a high score table.

A pixel-art game with Phaser:

I want a very small pixel-art platform game that runs in the browser. Use the Phaser game framework.

It needs:
- one screen with a floor and three platforms;
- a small character that walks left and right and jumps, using the arrow keys on a computer and on-screen buttons on a phone;
- five coins to collect, a coin counter and a "You won!" message when all five are collected.

Use simple placeholder pixel art for now. Keep the pixels sharp when the game is scaled up, not blurry.
For now it doesn't need enemies, sounds, more levels or login.

After the first version works, ask for one change per message, like “add a sound when two cards match”, and test after each one. If the AI changes things you didn’t ask for, see The AI changed parts I didn’t ask about.

How to test your game on your phone

  1. Publish it and open the link on your phone. Publishing gives you a free public link that opens in your phone’s browser. The steps for Lovable, Bolt and Replit are in section 6 of the first app guide. After each change, publish again before you test, or the phone shows the old version.
  2. Play it with your thumbs, not only with a mouse. A game that only listens to the keyboard can’t be played on a phone. MDN’s guide to mobile touch controls describes touch events like touchstart and touchmove, which fire when a finger touches and moves on the screen. If your game has no touch controls, ask: “Add touch controls so the game can be played on a phone.”
  3. Turn the phone sideways and back. Check that the game still fits the screen and nothing important is cut off.
  4. Play it yourself, every time. Lovable has browser testing, where the AI clicks through your app, but Lovable’s docs say it can’t interact with canvas-based or drawing tools. For a canvas game, you are the tester.
  5. Ask someone else to play without your help. Watch where they get stuck. That’s your next change.

For a full manual test of an app, with a checklist, see How to test your vibe-coded app without coding.

Common problems and what to ask

The screen is blank. The game hit an error before it could draw anything. Copy the error message and your last request, and follow My app shows a blank screen.

The game runs too fast on some screens and too slow on others. MDN warns that if the code doesn’t use the time between frames, the animation runs faster on high refresh-rate screens. Ask: “Make the movement depend on the time since the last frame, so the game runs at the same speed on every screen.”

The game is slow or choppy. MDN’s tips for canvas performance include drawing a static background with plain CSS under the canvas instead of redrawing it every frame, using separate layered canvases for parts that change at different speeds, using whole numbers for positions, and not resizing images while drawing them. Ask: “The game is choppy on my phone. Following MDN’s Optimizing canvas tips, find what is redrawn every frame that doesn’t need to be, and fix only that.”

The pixel art looks blurry. Ask the AI to keep the canvas at the small original size, scale it up with CSS and set image-rendering: pixelated, which is the technique in MDN’s crisp pixel art guide.

The images don’t load when I open the downloaded game on my computer. Phaser’s docs explain that a game which loads images, audio or data files needs to run from a web server, because browsers restrict pages opened straight from a file. In your AI tool’s preview or on the published link this isn’t a problem. If you downloaded the code, test it in the tool or ask the AI how to run it with a local server.

The game pauses when I switch tabs. That’s normal. MDN says most browsers pause animation calls in background tabs to save performance and battery.

My high score disappears. The game isn’t saving it anywhere. To keep it on one device, ask the AI to save it in the browser’s local storage. A high score table shared by all players needs a database and is a much bigger step. See My data disappeared when I reloaded the page.

The AI keeps “fixing” the same bug. Stop after two or three tries and go back to the last version that worked. AI agent stuck in a loop and burning credits shows how to break the loop without spending more.

What comes next

Once one small game works on your phone, make the next one a little harder, not ten times harder: add one level, one sound, or move from a click game to a canvas game. The 4-week vibe coding roadmap gives you a pace for a first project, and How hard is vibe coding, really? explains which parts get harder as a project grows.

Questions people ask

Can I make a game with AI if I can't code?

Yes, if you keep it small. A game that runs in the browser is a web page with rules, so the AI app builders that make web apps can make one. Start with a game where the player clicks, taps or chooses, like a quiz or a memory card game. Describe it in one message, test it, then ask for one change at a time.

Is CSS enough to make a game?

Not on its own. CSS controls how things look and can animate them, but a game also needs rules: what happens when you click, when you win and what the score is. That part is JavaScript. For click, tap and choice games, HTML, CSS and JavaScript together are enough, with no canvas and no framework. When you ask an AI tool for one of these games, it writes all three for you.

When do I need a canvas instead of normal HTML?

When things move all the time, like a snake that keeps going, a ball that bounces or a character that runs and jumps. MDN describes the Canvas API as a way to draw graphics with JavaScript and the canvas element, used for things like animation and game graphics. A canvas is a picture that the game redraws many times per second. For a quiz or a card game, normal HTML is simpler and easier to fix.

What is Phaser, and do I need it?

Phaser's docs describe it as a free, open source HTML5 game framework with WebGL and Canvas rendering, for games played in desktop or mobile browsers. It's a 2D framework, written in JavaScript, and it comes with pieces like sprites and Arcade Physics, which its docs say is meant for simple things like platformers, top-down games or puzzle games. You don't need it for a quiz or a card game. It can help when your game has many moving sprites, collisions and levels.

How do I make pixel art look sharp instead of blurry?

Ask the AI to keep the pixels crisp when it scales the art up. MDN's technique is to give the canvas the small original size, make it bigger with CSS, and set the CSS property image-rendering to pixelated. MDN also notes that at some zoom levels the pixels may look slightly uneven, which is hard to avoid.

Why does my game run faster on some screens?

Usually because the game moves things a fixed amount per frame. MDN says the browser's animation calls generally match the screen's refresh rate, and warns that if the code doesn't use the time between frames, the animation runs faster on high refresh-rate screens. Ask the AI to base movement on the time since the last frame, not on the number of frames.

New guides by email. An email when we publish a new guide, error fix or chapter, in plain English. Subscribe