Teaching kids to code with games: what works in our coding club
I run a coding club where kids learn HTML, CSS and JavaScript, and I'm convinced the fastest way to get a kid excited about code is to let them make a game. Not a quiz about variables, not a worksheet, but something they can play and show their friends the same day. Here's the approach I recommend.
Why games work
A game gives instant feedback. You change one number, press refresh, and the star falls faster. That loop of change, try and see is the heart of programming, and games make it fun. Games also give kids a reason to learn the boring parts. Nobody wants to learn about if statements in the abstract, but everybody wants to know how to make the game end when the player gets hit.
Start with something tiny that works
A great first project is a catch-the-star game, like the one in Make your first game in 30 lines of JavaScript. It has a basket, a falling star and a score, and it's short enough to finish in one session. That first success matters more than anything else. A kid who leaves the first lesson with a working game wants to come back.
Then: change things
Before writing anything new, let kids change what's there. Make the basket bigger. Change the colours. Make the star fall faster. Add a second star. These small changes teach how the code works without explaining it first, and they let every kid make the game their own.
Teach ideas when they're needed
Introduce new concepts at the moment a kid wants something. "I want the game to end after three misses" is the perfect time to learn about variables and if. "I want lots of stars" is the moment for arrays and loops. Learning something to solve your own problem sticks far better than learning it in advance.
The game loop is the big idea
Almost every game, from a 30-line star catcher to the games on this site, is built on a loop that runs about 60 times a second: read the input, update the world, draw everything. Once kids understand that loop, they can read almost any simple game's code. I explain it in How a browser game works.
Mistakes to avoid
- Too much at once. A big project with no working version for weeks is discouraging. Keep a playable game at every step.
- Copying without changing. Copying code is fine, but kids should always change something and see what happens, or nothing is learned.
- Fixing bugs for them. It's tempting, but it's better to ask questions: what did you expect to happen? What happened instead? Which line do you think does that?
- Only the strongest kids get to type. In pairs, swap who's at the keyboard every few minutes.
From a small game to a real one
Every game on this site started as a simple version that worked, and then got better one step at a time: graphics, sounds, levels, phone controls, a leaderboard. That's the same path a kid's game can follow. Showing kids that real games are built this way, in small steps, makes a big project feel possible.
Want to try it?
All you need is a computer and a text editor. Start with the 30-line game, change five things about it, and then ask: what would make this more fun? That question is where every game starts.