Coding with blocks
Scratch is a free programming language where you snap together colourful blocks instead of typing code. It was created by the Lifelong Kindergarten group at the MIT Media Lab, led by Mitchel Resnick, and launched in 2007. Millions of people around the world use it to make games, stories, animations and music, and to learn how computers think.
You can use Scratch in a web browser at scratch.mit.edu or download the free app. Younger learners (ages 5–7) can start with ScratchJr on a tablet.
The Scratch screen
| Area | What it is |
|---|---|
| Stage | The area where your project plays; it’s 480 units wide and 360 units tall |
| Sprites | Characters or objects that move and act; the cat is the default sprite |
| Sprite pane | Shows all the sprites in your project |
| Block palette | All the coding blocks, sorted by colour |
| Code area | Where you drag blocks to build scripts |
| Costumes tab | Different looks for a sprite, used for animation |
| Sounds tab | Sounds your sprite can play |
| Green flag and stop sign | Start and stop your project |
Positions on the stage
The stage uses x and y coordinates, just like a graph in math.
| Position | Coordinates |
|---|---|
| Centre | x: 0, y: 0 |
| Right edge | x: 240 |
| Left edge | x: −240 |
| Top edge | y: 180 |
| Bottom edge | y: −180 |
Block categories
| Colour | Category | Examples |
|---|---|---|
| Blue | Motion | move 10 steps, turn 15 degrees, go to x: y: |
| Purple | Looks | say Hello!, switch costume, change size |
| Pink | Sound | play sound, change pitch |
| Yellow | Events | when green flag clicked, when key pressed |
| Gold | Control | wait, repeat, forever, if–then |
| Light blue | Sensing | touching?, key pressed?, ask and wait |
| Green | Operators | +, −, >, =, pick random |
| Orange | Variables | set score to 0, change score by 1 |
| Pink-red | My Blocks | Make your own custom blocks |
Blocks are shaped like puzzle pieces, so only blocks that make sense together will fit.
Big coding ideas in Scratch
| Idea | What it means | Scratch example |
|---|---|---|
| Sequence | Instructions run in order, top to bottom | move, then say, then turn |
| Events | Code starts when something happens | when green flag clicked |
| Loop | Repeats instructions | repeat 10, forever |
| Conditional | Runs code only if something is true | if touching edge then bounce |
| Variable | Stores information that can change | score, lives, timer |
| Operators | Do math or compare values | if score > 10 |
| Broadcasting | Sprites send messages to each other | broadcast "game over" |
These same ideas are used in every programming language, from Python to JavaScript.
Your first project: a cat that walks and talks
Build this script for the cat sprite:
- when green flag clicked
- go to x: −200 y: 0
- say "Hi! Watch me walk!" for 2 seconds
- repeat 10
- move 20 steps
- next costume
- wait 0.1 seconds
- say "Ta-da!" for 2 seconds
Click the green flag. The cat walks across the stage, switching costumes to look like it’s moving its legs. That’s animation!
Making a simple game: catch the apple
Goal: move a bowl left and right to catch falling apples.
Bowl sprite:
- when green flag clicked → go to x: 0 y: −150
- forever → if key right arrow pressed then change x by 10; if key left arrow pressed then change x by −10
Apple sprite:
- when green flag clicked → set score to 0
- forever → go to x: (pick random −220 to 220) y: 180, then repeat until touching Bowl or y position < −170: change y by −5
- if touching Bowl then change score by 1 and play sound "pop"
Challenge: make the apple fall faster as the score goes up, or add a "lives" variable.
Debugging
When a project doesn’t work, programmers debug it: they find and fix the problem.
Debugging tips:
- Click one block at a time to see what it does.
- Check that the right sprite has the right script.
- Use "say" blocks to show variable values while the project runs.
- Ask: "What did I expect? What actually happened?"
Mistakes are a normal part of coding. Every programmer debugs.
Sharing and remixing
The online Scratch community lets you share your projects and look inside others’ projects to see how they work. You can remix a project to build on it, giving credit to the original creator. Follow the community guidelines: be respectful and never share personal information.
Why learn Scratch?
- Builds problem-solving and logical thinking
- Encourages creativity through art, music and stories
- Teaches coding concepts used in all programming languages
- Connects to math (coordinates, angles, negative numbers, randomness)
- Prepares you for text-based languages later
Common mistakes
- Forgetting an event block. Without "when green flag clicked," a script won’t start.
- Putting a script on the wrong sprite.
- Using "forever" when you need "repeat." A forever loop never ends.
Try it yourself
- Make a sprite draw a square using the Pen extension: repeat 4, move 100 steps, turn 90 degrees. Then try a triangle (turn 120) and a hexagon.
- Create a two-sprite conversation using "say" and "wait" blocks, or "broadcast."
- Build the catch-the-apple game and add a timer variable.
Quick recap
- Scratch is a free block-based programming language from MIT.
- Sprites act on the stage using scripts made of blocks.
- Key ideas are sequence, events, loops, conditionals and variables.
- Debugging means finding and fixing problems.
- Scratch builds creativity and coding skills you can use in any language.