Scratch basics: your first project

Foundation

Scratch builds programs with blocks — no typing. Sprites perform on the stage; things start with 'when green flag clicked', and blocks run top to bottom.

For:Secondary 1 Information & Communication Technology · Unit:Coding basics · Lesson 8 of 13 in the learning path

After this lesson, you can:
  • Scratch = block coding, no typing needed
  • Sprites act on the stage; events (the flag) start scripts
  • Blocks run top to bottom in sequence
資訊及通訊科技Information & Communication Technology
Before this lesson you should know: Algorithms and flowcharts

§Text Passage

1Scratch, developed by the MIT Media Lab in the United States, is a block-based programming tool: like building with LEGO, you drag coloured command blocks into the scripting area and stack them into a working program. With no syntax to memorise, beginners can focus on the three basic structures — sequence, loops and conditions — and add sprites, sounds and backdrops to make projects lively and fun.

2A first project usually begins by choosing a backdrop, then dragging the 'when green flag clicked' block from the Events category and stacking commands such as 'move 10 steps' and 'say Hello!' beneath it; press the green flag and the sprite moves at once, giving an instant sense of achievement. Once confident, add sensing and repeat blocks — reacting to the mouse, counting runs, keeping score with sound effects — to design more complete games or interactive stories.

3Many primary and secondary schools in Hong Kong hold Scratch competitions, and the Hong Kong Science Museum and the Education Bureau offer free workshops and teaching materials. Setting the stage inside an MTR train, a dai pai dong or a street market gives a project a real Hong Kong flavour. The logical thinking and structural ideas learned in Scratch transfer directly to text languages such as Python later on.

1Summary 重點摘要

Scratch builds programs with blocks — no typing. Sprites perform on the stage; things start with 'when green flag clicked', and blocks run top to bottom.

2Vocabulary cards Vocabulary

S
Sprite角色

The actor on the stage: the cat, a ball, any picture.

S
Stage舞台

The background where sprites perform.

E
Event事件

The trigger that starts a script, e.g. 'when green flag clicked', 'when space key pressed'.

S
Sequence順序

Blocks run from top to bottom, one by one.

M
Motion / Looks blocks動作/外觀積木

Motion (blue) moves and turns the sprite; Looks (purple) makes it talk, grow or change colour.

D
Debugging除錯

A mistake in a program is a bug; debugging means finding and fixing the wrong block.

B
Block palette積木清單

The area on the left where you pick blocks, sorted by colour into categories.

S
Script area程式區

The middle area where you stack blocks to build a script.

3Step by step Steps

  1. Four areas of the screenWhen Scratch opens, the screen has four areas: the block palette on the left, where blocks are sorted by category; the script area in the middle, where blocks are dragged and stacked; the stage at the top right, where sprites perform and results appear instantly; and the sprite list at the bottom right, managing every Sprite. The basic flow: drag blocks from the palette into the script area, stack them, then click the green flag above the stage to run.
  2. Blocks come in coloursBlocks are grouped into colour-coded categories: Motion (blue) moves and turns the sprite; Looks (purple) controls speech bubbles, size and colour effects; Sound (pink) plays audio; Events (yellow) start scripts, such as 'when green flag clicked'; Control (orange) provides repeats and ifs; Sensing (light blue) asks questions and detects touches. Memorising the colours means the right block is found instantly.
  3. Your first programThe first program needs only three blocks: drag 'when green flag clicked' from Events, attach 'move 10 steps' from Motion, then 'say Hello! for 2 seconds' from Looks. Click the green flag to test: the cat moves forward and a bubble shows 'Hello!'. Running one block after another from top to bottom is called a sequence — Scratch always runs the top block first, then the next, and the order never changes.
  4. Add interactionTo add interaction, switch to a keyboard event: replace 'when green flag clicked' with 'when space key pressed', and the stack runs only when the key is pressed. An event block must sit at the very top of a stack — it is the power switch, and without one the blocks below never run, however neatly stacked. Try two different events: one action on the green flag and another on the space key, giving one project two ways to play.
  5. DebuggingPrograms going wrong is completely normal, and fixing mistakes is called debugging. Check one block at a time: click a single block and watch its immediate effect; compare what you expected with what actually happened, find the faulty block and fix its number or swap the block — no need to rewrite the whole program. If the cat turns the wrong way, just change 'turn right 90 degrees' to 'turn left 90 degrees' and test again.
  6. Adding sprites and savingClick 'Choose a Sprite' in the sprite list to pick one from the library, draw one with the paint editor, or upload a picture from the computer; click the backdrop thumbnail to change the stage background — a classroom or a street, for example — to give the project a setting. When finished, save: 'File → Save to your computer' stores the project as a .sb3 file, and 'File → Load from your computer' reopens it later for more editing.

4Diagrams Diagrams

Scratch 介面四大區 Interface zones指令積木區動作・外觀・聲音事件・控制等左邊:揀積木程式編輯區拖積木過嚟砌程式好似砌 LEGO中間:砌積木舞台區睇作品演出綠旗=開始右邊:播放入門三步:① 揀角色 ② 拖「當綠旗被點擊」+「移動」 ③ 撳綠旗試行Scratch 錯咗唔會壞機——放心試,積木啱唔啱即刻見到
Fig. 1: Scratch interface

5Worked example Example

Example: what shape does the cat draw with 'when green flag clicked → repeat 4 [move 50 steps → turn right 90 degrees]'?

  1. Repeat 4 times: four straight runs
  2. Each run moves 50 steps then turns right 90 degrees
  3. Four straight sides + four right-angle turns
  4. 4 × 90 = 360 degrees: exactly one full turn, back to the start
  5. Answer: The cat draws a square with 50-step sides — the classic 'draw a square' program.

6Common mistakes Mistakes

✗ Stacking blocks and expecting them to run by themselves.
✓ You always need an event block on top (like the green flag) or the script never starts.
✗ Using a Motion block to make the sprite speak.
✓ Movement is Motion; speaking and looks are Looks — pick the right category for the effect.
✗ Rewriting everything when it goes wrong.
✓ Debug first: test block by block, find the faulty one, fix just that.
✗ Leaving a block floating near the script area and expecting it to run.
✓ Loose blocks never run; blocks must snap onto the same stack, and the stack must start with an event block.

7Quick check Quick check

Q1'When green flag clicked' belongs to which category? A. Events B. Motion C. Looks

Q2Where does a sprite perform?

Q3In what order does a stack of blocks run?

Q4What file extension does a Scratch project get when saved to your computer?

Q5Which category does 'say Hello! for 2 seconds' belong to?

8Recap Recap

  • Scratch = block coding, no typing needed
  • Sprites act on the stage; events (the flag) start scripts
  • Blocks run top to bottom in sequence
  • Bugs are normal: debug block by block
  • Blocks sort by colour: blue motion, purple looks, yellow events, orange control

Other subjects in this grade

Same subject, other grades