LEVEL 2 ๐Ÿ•น๏ธ

Make it listen

Your programs start reacting to you โ€” clicks, keys, decisions. Plus: your first taste of the terminal, the black window from every hacker movie.

2A

Traffic Light

An if-statement is a decision: "IF this is true, do that." Click the canvas to cycle the light.

Code โ€” copy me into the p5.js editor

        
      
Demo โ€” click on it!
๐ŸŽฏ Challenges: add a 4th secret colour ยท make it go backwards ยท draw all three lights at once with only the current one bright
2B

Arrow Key Hero

Four if-statements = full movement. This is genuinely how characters move in real games. Click the canvas first so it hears your keyboard!

Code โ€” copy me into the p5.js editor

        
      
Demo โ€” click it, then use arrow keys
๐ŸŽฏ Challenges: make the hero faster ยท stop it leaving the screen (hint: you know if-statements nowโ€ฆ) ยท add a coin at a random spot โ€” can you tell when the hero touches it?
2C

Pattern Machine

A loop means "do this again and again". Two loops together fill the whole screen. Writing 70 circles by hand? No thanks.

Code โ€” copy me into the p5.js editor

        
      
Demo โ€” what yours should do
๐ŸŽฏ Challenges: tighter spacing ยท squares instead of circles ยท delete the noLoop() line โ€” instant disco ยท make the size depend on x (hint: circle(x, y, x/10))

The Terminal ๐Ÿ–ฅ๏ธ

It's just another way to talk to your computer โ€” with words instead of clicks. Your files are folders inside folders; the terminal is you walking through them.

pwd # "where am I right now?"
ls # "what's in this folder?"
cd projects # "go into the projects folder"
cd .. # "go back up one level"
mkdir my-game # "make a new folder called my-game"

๐Ÿ’ก Press Tab and the terminal finishes typing names for you. Press โ†‘ to repeat your last command. Real engineers use these two keys constantly โ€” lazy typing is professional typing.