Real JavaScript for coders in grades 3 to 12. Each mission has a live code box: change the code, press Run, and watch it work. Eight missions take you from your first shape to a full game with lives, a score and a restart.
New to these words? Start with the Word Wall. Each mission also lists its new words, and you can tap any of them to see what it means.
Every coder learns these words one at a time. Read one, try it in a mission, then tick I know it to earn a star.
You already know more than you think. Bitsbox is built on JavaScript, so the ideas carry straight over. The words just change a little.
| Idea | In Bitsbox | In p5.js |
|---|---|---|
| Code that repeats | function loop(), about 20 times a second | function draw(), about 60 times a second |
| Code that runs once | Lines at the top | function setup() |
| Background | fill('rainy') | background(30, 40, 70) with red, green, blue numbers |
| Put something on screen | stamp('fish33',300) | circle(x, y, size), rect(), text() |
| Mouse position | x and y inside drag() | mouseX and mouseY, anywhere |
| Touching | a.hits(b) | dist(x1, y1, x2, y2) is less than the two sizes added |
| Random | random(6) gives a whole number 1 to 6 | random(6) gives a decimal from 0 up to 6. Use floor(random(6)) + 1 for a dice. |
| Making a variable | score = 0 | let score = 0 |
| The screen | (0, 0) is the top left | Same. The canvas here is 400 by 400. |
To play a game that uses keys, click the canvas first so it can hear the keyboard.
When code breaks, the red message under the canvas tells you the line. Find the bug in each one, then check.
A right answer on the first try earns a star.
Plan before you build. Your notes save in this browser.
When you outgrow this page, the p5.js Web Editor runs the same code, and the p5.js reference lists every command with examples. Saving and sharing in the Web Editor may need an account, so check with your teacher first.
Before you post a game or a link online, ask a teacher or a parent.
The Word Wall explains ideas. This list is the actual commands you type.