Module 4
Visual programming with Scratch
Quick-reference revision notes for parents.
4.1 Getting started with Scratch
Scratch is a block-based programming language. Drag colour-coded blocks together to build scripts.
- Stage: where the action happens.
- Sprite: a character or object on the stage.
- Backdrop: the stage's background.
- Scripts: the code that runs for a sprite.
Block categories (colours)
| Category | Examples |
|---|---|
| Motion (blue) | move, turn, go to |
| Looks (purple) | say, costume, change effect |
| Sound | play sound, change volume |
| Events (yellow) | when green flag clicked, when key pressed |
| Control (orange) | repeat, if-then-else, wait |
| Sensing (light blue) | touching, key pressed, ask |
| Operators (green) | +, =, and, random |
| Variables (orange) | set / change / show variable |
4.2 Sprites, costumes & naming
- Each sprite can have several costumes (different appearances). Switching costumes makes it look animated.
- Name your sprites sensibly (e.g. "ball", "player1") — it makes scripts much easier to read.
4.3 Duplicating sprites & backdrops
- Right-click → Duplicate makes an exact copy with all its scripts. Useful for enemies, projectiles, etc.
- Add a backdrop from the library or paint your own.
4.4 Interacting with keypresses and other sprites
Common event blocks:
- When green flag clicked — run when the project starts.
- When [space] key pressed — run when a key is pressed.
- When this sprite clicked.
- When I receive [message] — broadcast/receive lets sprites talk to each other.
Detecting collisions: if <touching [other sprite]?> then ….
4.5 Variables
A variable stores a value (number or text) you can use later. In a game it's how you keep score, lives, level.
- Set variable to a value (e.g. set score to 0).
- Change variable by an amount (e.g. change score by 1).
- Show / hide on the stage.
Use if … then … else to react to variable values:
if <lives = 0> then
say "Game over"
stop all
4.6 Timers
- The built-in timer starts at 0 and counts up in seconds. Reset with the "reset timer" block.
- Combine with the wait block to space things out, or with repeat until to make a count-down loop.
- Use a variable like time_left if you want a count-down displayed.
Quick reference
- Sprite = character; backdrop = scene; script = code
- Yellow Events start scripts; orange Control loops/decides
broadcast+when I receivelet sprites communicate- Variables: set, change, show — used for score, lives, etc.
- Timer counts in seconds; combine with wait/repeat-until