If you want to know how to make a video game from scratch, the honest answer is that you start much smaller than you think: one idea, one core action, one screen. Every game you have played, from a phone puzzler to a sprawling RPG, is built on the same skeleton, a loop that reads input, updates the world and draws it, dozens of times per second. Once you can build that skeleton and finish something tiny on top of it, every bigger project is the same process repeated with more content.
This guide walks through what “from scratch” actually means, the seven steps from idea to finished game, a complete JavaScript example you can run today, and how to add art, sound and even a trailer without a team.
What does “from scratch” actually mean?
The phrase covers three very different starting points, and choosing the right one decides whether you finish.
- Writing your own engine. A game engine is the software layer that handles rendering, input, physics, audio and asset loading so you do not rebuild them for every game. Some developers write their own. The two-person team behind the 2006 horror adventure Scratches built a custom engine called SCREAM because existing adventure engines could not produce the pre-rendered “pseudo-3D” look they wanted. That is a valid choice when you have a specific technical need, but it is a long road for a first project.
- A blank project in an existing engine. This is what most developers mean. As the overview of video game development notes, the technology in a game can be written from scratch or reused, and small self-funded teams (indie developers) usually reuse engines and libraries so they can spend their time on the game itself. Godot, Unity, GameMaker, Phaser and Three.js are common picks.
- An AI game engine. You describe the game in plain English and an AI writes and runs the code. This is close to what is often called vibe coding, building software by prompting a language model rather than typing every line. It is the fastest route to something playable, and you still learn design by iterating on it.
There is also Scratch, the block-based programming language from MIT aimed at younger learners. It is a fine place for kids to learn logic, but it is not what most adults mean by “from scratch.”
What you need before you start
Less than you think. For a first game you need:
- An idea you can finish in a weekend. “Dodge falling rocks,” “jump between platforms,” “match three tiles.” If your pitch needs the word “and” more than once, cut it down.
- One tool. A browser plus a text editor is enough for a 2D game in JavaScript. An engine adds an editor and built-in systems. An AI engine adds an agent that writes the code for you.
- Placeholder art. Coloured rectangles are perfectly good art for the first version. Real sprites come later.
- A short design note. Half a page is enough: the goal, the controls, how you win or lose. If you want structure, our game design document template walks through each section.
Skills help but are not gatekeepers. Basic programming (variables, functions, if statements, loops) will make everything easier, and an AI tool will happily explain any code it writes if you ask.

How to make a video game from scratch, step by step
Whatever tool you choose, the process is the same. Here are the seven steps, in the order that gives you the best chance of shipping.
Step 1: Define the core loop
The core loop is the action the player repeats every few seconds: move, dodge, score, repeat. Write it as one sentence. Everything else (menus, story, upgrades) is decoration around this loop, and if the loop is not fun with rectangles, it will not be fun with beautiful art.
Step 2: Pick your tool and lock it in
Choose one engine or approach and stick with it for the whole project. Switching tools halfway is one of the most common ways first games die. Our guide to video game development for beginners compares the main options if you are undecided.
Step 3: Build an ugly prototype
Get the player moving, the obstacle spawning and the lose condition working, using shapes only. A prototype is a rough, playable version that answers one question: is this fun? Aim to reach this point in your first session.
Step 4: Make it a complete game
Add a start, an end and a restart. A score counter. A game-over message. This step turns a toy into a game, and it is the step beginners most often skip.
Step 5: Add art and sound
Replace rectangles with sprites (2D images of characters and objects) and add a few sound effects and a music loop. A sprite sheet, one image holding every frame of an animation in a grid, is the standard format for 2D animation.
Step 6: Playtest with real people
Hand the game to someone and watch silently. Note where they get confused, where they die and where they smile. Fix the top three problems, then test again.
Step 7: Polish and ship
Add “juice” (screen shake, hit flashes, particles), tune difficulty, export a build and put it somewhere people can play it, such as a static web host or a game storefront. Then record a short video so people know it exists.
A worked example: a dodge game in plain JavaScript
Here is a complete, tiny game written with no engine and no libraries, the most literal version of how to make a video game from scratch. Save it as game.js, create an index.html file that loads it with a script tag, and open that file in your browser. Arrow keys move, R restarts.
// A complete dodge game: no engine, no libraries.
const canvas = document.createElement("canvas");
canvas.width = 480;
canvas.height = 320;
document.body.appendChild(canvas);
const ctx = canvas.getContext("2d");
const keys = {};
addEventListener("keydown", (e) => (keys[e.key] = true));
addEventListener("keyup", (e) => (keys[e.key] = false));
const player = { x: 230, y: 290, w: 20, h: 20, speed: 240 };
let rocks = [];
let spawnTimer = 0;
let score = 0;
let gameOver = false;
let last = performance.now();
function overlaps(a, b) {
return a.x < b.x + b.w && a.x + a.w > b.x &&
a.y < b.y + b.h && a.y + a.h > b.y;
}
function update(dt) {
if (keys["ArrowLeft"]) player.x -= player.speed * dt;
if (keys["ArrowRight"]) player.x += player.speed * dt;
player.x = Math.max(0, Math.min(canvas.width - player.w, player.x));
spawnTimer -= dt;
if (spawnTimer <= 0) {
rocks.push({
x: Math.random() * (canvas.width - 16),
y: -16, w: 16, h: 16,
vy: 120 + score * 3
});
spawnTimer = 0.6;
}
for (const r of rocks) {
r.y += r.vy * dt;
if (overlaps(r, player)) gameOver = true;
}
const before = rocks.length;
rocks = rocks.filter((r) => r.y < canvas.height);
score += before - rocks.length; // one point per rock dodged
}
function draw() {
ctx.fillStyle = "#111";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "#4fc3f7";
ctx.fillRect(player.x, player.y, player.w, player.h);
ctx.fillStyle = "#e57373";
for (const r of rocks) ctx.fillRect(r.x, r.y, r.w, r.h);
ctx.fillStyle = "#fff";
ctx.font = "16px monospace";
ctx.fillText("Score: " + score, 10, 20);
if (gameOver) ctx.fillText("Game over - press R", 150, 160);
}
function loop(now) {
const dt = Math.min((now - last) / 1000, 0.05);
last = now;
if (!gameOver) update(dt);
if (gameOver && keys["r"]) {
rocks = [];
score = 0;
spawnTimer = 0;
gameOver = false;
}
draw();
requestAnimationFrame(loop);
}
requestAnimationFrame(loop);
Three ideas in this file carry over to every game you will ever make:
- The game loop.
requestAnimationFramecallslooponce per screen refresh. Each call updates the world, then draws it. - Delta time.
dtis the seconds since the last frame. Multiplying speeds by it keeps movement consistent on fast and slow machines. The cap at 0.05 stops objects teleporting if a tab lags. - Collision.
overlapsis an axis-aligned bounding box (AABB) check: two rectangles touch if they overlap on both the x and y axes.
Notice the difficulty curve hiding in vy: 120 + score * 3: rocks fall faster as you score. That single line is game design. If you want to go deeper into the hand-built approach, our walkthrough of an HTML5 canvas game engine expands this pattern into reusable systems.





