Coding Club
Game making in JavaScript
Six games, written in JavaScript, the language every web browser understands. They are built in the site's Web Studio, so they work on any school computer, a Chromebook or a computer at home, with nothing to install and no account. Each step's game runs on its page, so you can play it as you build it, and Download saves your finished game as one file that plays anywhere.
Six days, six projects
One small project a session. Each one is a numbered list of steps with a picture of what to click and what you should see, then tests and stretch challenges for anyone who finishes early.
Get set up before day 1
You will need
- Any computer with a web browser, including a Chromebook
- A mouse and a keyboard
- The Web Studio on this site, or Notepad
- Nothing to install and no account
Setup step 1: Open the Web Studio
Every game is made in the Web Studio, which is part of this site: nothing to install and no account. Open it in a new tab, then choose the day's game under Games in the Project list. Each game starts you off with its first step already typed in.
Web StudioDay 1: Balloon PopRunDownloadCopy a linkStart againindex.htmlstyle.cssscript.js1<!DOCTYPE html>2<html>3 <head>4 <meta charset="utf-8">5 <title>Balloon Pop</title>6 <link rel="stylesheet" href="style.css">7 </head>8 <body>9 <h1>Balloon Pop</h1>10 <canvas id="game" width="480" height="360"></canvas>11 <script src="script.js"></script>12 </body>13</html>PreviewBalloon PopChoose the day's game from the Project list. Setup step 2: Where the code goes
A game is a web page. index.html holds the canvas, the box the game is drawn in. style.css sets the colours round it. script.js is the game itself, in JavaScript, and it is where you will spend most of your time. Each step says which tab its code goes in.
Web StudioDay 1: Balloon PopRunDownloadCopy a linkStart againindex.htmlstyle.cssscript.js1const canvas = document.getElementById("game");2const ctx = canvas.getContext("2d");3 4function loop() {5 ctx.clearRect(0, 0, canvas.width, canvas.height);6 // move things, then draw them7 requestAnimationFrame(loop);8}9 10loop();PreviewBalloon PopMost of each game is in the script.js tab. Setup step 3: Click the game to play it
The preview runs your game as you type. A game only hears the keyboard once you have clicked it, so click the preview, then press the keys. Every step on these pages also has the game running in it: click it and play.
Tip If a game stops working, an error has usually crept in. Look back at the step's highlighted lines, and check every bracket and quote.Setup step 4: Keep your game
Download saves your game as one .html file. Double click it on any computer and it plays in the browser, even without the internet, so you can take it home on a memory stick or email it to a friend. Copy a link makes a link with the whole game inside it.
Web StudioDay 1: Balloon PopRunDownloadCopy a linkStart againindex.htmlstyle.cssscript.js1<!DOCTYPE html>2<html>3 <head>4 <meta charset="utf-8">5 <title>Balloon Pop</title>6 <link rel="stylesheet" href="style.css">7 </head>8 <body>9 <h1>Balloon Pop</h1>10 <canvas id="game" width="480" height="360"></canvas>11 <script src="script.js"></script>12 </body>13</html>PreviewBalloon PopDownload saves the whole game as one file.
Notes for the teacher
Before the first session
- Open the Web Studio on a club computer and play one of the finished games, to check the school's filter allows the site. Everything runs in the browser, so nothing needs installing, and it works on Chromebooks too.
- Work is saved in each browser, on that computer. If students change computers between sessions, they should use Download or Copy a link at the end of each session. Every day also starts from its own starter, so nobody is ever stuck.
- Keyboard games need a keyboard, and the game must be clicked before it hears the keys. Remind students of this every session!
- The Web track's first days (HTML and CSS) help but are not needed: each game explains what it uses.
Why JavaScript?
JavaScript runs in every web browser, so these games need no Python, no installer and no permission from IT. A downloaded game is one .html file that runs offline on any computer, which students love to take home and share.
How the six games build up
Day 1 is drawing, the game loop and the mouse. Day 2 adds the keyboard and collisions, day 3 velocity and bouncing, day 4 state and a page built from code, day 5 grids and level design, and day 6 gravity and platforms.