Roam

How to make a snake game in Python, Scratch or JavaScript

Snake is the classic first coding project because the whole game is a grid and a list. The head moves one cell per tick, the tail follows, food makes it longer, and hitting a wall or yourself ends the run. Learn that logic once and it works in any language.

How Snake works

The idea goes back to Blockade, a 1976 arcade game from Gremlin Industries, and Snake became famous as a game built into Nokia phones in the late 1990s. Every version uses the same parts.

Code it in Python

The same game in Scratch or HTML

Snake without code

If you want the game more than the coding exercise, describe it to Roam, an iPhone app: arena, theme, what the snake eats. It comes back playable, and you can play it with friends. The no-code snake game maker page has twists to ask for.

Play it on Roam

Create your snake game with Roam

Pick the arena and the twist. Play it on your iPhone, then say what to change.

Try: "neon snake arena, eat glowing orbs to grow, boost costs length, my friends are the other snakes"

Roam ("Roam - Make Games" on the App Store) is an iPhone app where you play games and make your own by describing them or from a photo. It is free to download and play, and making games works without a subscription; optional Spark and Reality plans and credit packs add more creation. Android: pre-register on Google Play.

Questions people ask

How do you create a snake game using Python?

Install pygame, make a grid, keep the snake as a list of cells and run a loop that reads keys, moves the head, checks for walls and the tail, and redraws. A beginner following a tutorial can finish a basic version in an afternoon.

What is the code for the snake game?

There is no single code. Every version has a list of body cells, a direction, a food cell and a loop that moves, checks collisions and redraws. The language only changes how you write those parts.

How do you make a snake game in HTML?

Use a canvas element and JavaScript. Store the snake as an array, change direction on keydown, move it with setInterval and redraw the canvas each tick.

What is the best language to code a snake game?

Python with pygame is the most common choice for beginners. JavaScript with an HTML canvas is a close second, and Scratch works with blocks instead of text.

Sources, checked November 5, 2026

Keep exploring

Download on the App StorePre-register on Google Play