The Scripts of Scratch Programming Basic 6 Basic Technology Lesson Note
Download Lesson NoteTopic: The Scripts of Scratch Programming
Learning Objectives
By the end of the lesson, pupils should be able to:
- Identify the different scripts of the scratch interface
Content
Review: What are Scripts? Scripts are programs made by connecting blocks of code in Scratch. They tell sprites what to do.
Block Categories in Scratch
Scratch organizes coding blocks into different categories, each with a specific color. Let’s explore each category:
- MOTION BLOCKS (Blue) These blocks control sprite movement and position.
Common Motion Blocks:
- Move (10) steps – Moves sprite forward
- Turn right (15) degrees – Rotates sprite clockwise
- Turn left (15) degrees – Rotates sprite counter-clockwise
- Go to (x:0 y:0) – Moves sprite to specific coordinates
- Go to random position – Moves sprite to random spot
- Glide (1) secs to (x:0 y:0) – Smooth movement to position
- Point in direction (90) – Faces sprite in direction
- Point towards (mouse-pointer) – Faces sprite toward something
- Change x by (10) – Moves sprite horizontally
- Change y by (10) – Moves sprite vertically
- Set x to (0) – Sets horizontal position
- Set y to (0) – Sets vertical position
Uses: Making sprites walk, fly, drive, dance
- LOOKS BLOCKS (Purple) These blocks control sprite appearance.
Common Looks Blocks:
- Say [Hello!] for (2) seconds – Speech bubble appears
- Say [Hello!] – Speech bubble stays
- Think [Hmm…] for (2) seconds – Thought bubble
- Switch costume to (costume1) – Changes sprite appearance
- Next costume – Changes to next look
- Change size by (10) – Makes bigger/smaller
- Set size to (100) % – Sets specific size
- Show – Makes sprite visible
- Hide – Makes sprite invisible
- Go to front/back layer – Changes which sprite is on top
- Change color effect by (25) – Changes colors
Uses: Animation, special effects, making sprites talk
- SOUND BLOCKS (Pink) These blocks play sounds and music.
Common Sound Blocks:
- Play sound (meow) until done – Plays complete sound before continuing
- Start sound (meow) – Plays sound and continues immediately
- Stop all sounds – Stops all playing sounds
- Change volume by (-10) – Adjusts loudness
- Set volume to (100) % – Sets specific volume
- Change pitch effect by (10) – Makes sound higher/lower
Uses: Adding music, sound effects, voices to projects
- EVENTS BLOCKS (Yellow) These blocks start scripts when something happens.
Common Events Blocks:
- When green flag clicked – Starts when you click green flag (most common start block)
- When [space] key pressed – Starts when key is pressed
- When this sprite clicked – Starts when you click the sprite
- When backdrop switches to (backdrop1) – Starts when background changes
- When I receive [message1] – Starts when message is broadcast
Uses: Starting programs, making interactive projects
- CONTROL BLOCKS (Orange) These blocks control program flow.
Common Control Blocks:
- Wait (1) seconds – Pauses program
- Repeat (10) – Does actions multiple times (loop)
- Forever – Repeats actions continuously
- If <condition> then – Does something only if condition is true
- If <condition> then, else – Chooses between two options
- Wait until <condition> – Waits for something to happen
- Repeat until <condition> – Loops until condition is true
- Stop [all] – Stops scripts
Uses: Creating loops, making decisions, controlling timing
- SENSING BLOCKS (Light Blue) These blocks detect things.
Common Sensing Blocks:
- Touching (mouse-pointer)? – Detects if touching something
- Touching color [color]? – Detects if touching specific color
- Distance to (mouse-pointer) – Measures distance
- Ask [What’s your name?] and wait – Gets input from user
- Answer – Stores user’s response
- Key (space) pressed? – Detects if key is pressed
- Mouse down? – Detects if mouse is clicked
- Mouse x/y – Shows mouse position
Uses: Making interactive games, getting user input
- OPERATORS BLOCKS (Green) These blocks do math and logic operations.
Common Operators Blocks:
- ( ) + ( ) – Addition
- ( ) – ( ) – Subtraction
- ( ) * ( ) – Multiplication
- ( ) / ( ) – Division
- Pick random (1) to (10) – Random number
- ( ) > ( ) – Greater than
- ( ) < ( ) – Less than
- ( ) = ( ) – Equal to
- ( ) and ( ) – Both conditions must be true
- ( ) or ( ) – One condition must be true
- Not ( ) – Opposite of condition
- Join [apple] [banana] – Combines words
- Letter (1) of [world] – Gets specific letter
Uses: Calculations, comparisons, making decisions
- VARIABLES BLOCKS (Orange/Red) These blocks store and use data.
Common Variables Blocks:
- Make a variable – Creates new variable
- Set [my variable] to (0) – Gives variable a value
- Change [my variable] by (1) – Increases/decreases value
- Show variable [my variable] – Displays on stage
- Hide variable [my variable] – Hides from stage
Uses: Keeping score, storing names, counting things
- MY BLOCKS (Purple/Custom) Create your own custom blocks.
Uses: Making your own commands for repeated actions
Example Scripts Using Different Categories
Example 1: Simple Movement
When green flag clicked (Events)
Forever (Control)
  Move 10 steps (Motion)
  If on edge, bounce (Motion)
Result: Sprite moves continuously and bounces at edges
Example 2: Interactive Sprite
When this sprite clicked (Events)
Say “Hello!” for 2 seconds (Looks)
Play sound “meow” until done (Sound)
Change size by 20 (Looks)
Result: When clicked, sprite talks, makes sound, grows bigger
Example 3: User Input
When green flag clicked (Events)
Ask “What is your name?” and wait (Sensing)
Say join “Hello ” answer for 2 seconds (Looks + Operators)
Result: Sprite asks for name and greets user
Example 4: Simple Game
When green flag clicked (Events)
Set score to 0 (Variables)
Forever (Control)
  If touching mouse-pointer? then (Sensing + Control)
    Change score by 1 (Variables)
    Play sound “pop” (Sound)
  End if
End forever
Result: Score increases when sprite touches mouse
Tips for Writing Scripts
- Always start with an Events block (usually green flag)
- Test your script frequently
- Use Control blocks to create loops
- Combine different categories for complex actions
- Keep scripts organized and easy to read
- Add comments to explain what script does
- Debug one block at a time if something goes wrong
Common Script Patterns
Pattern 1: Animation Loop
Forever
  Next costume
  Wait 0.2 seconds
Pattern 2: Random Movement
Forever
  Move 5 steps
  Turn right pick random 1 to 20 degrees
  If on edge, bounce
Pattern 3: User Control
Forever
  If key space pressed? then
    Move 10 steps
  End if
Activities
- Identify block categories by color
- Drag different blocks to Scripts Area
- Create a simple walking animation using Motion and Looks blocks
- Make a sprite respond to mouse clicks using Events and Looks
- Build a simple interactive project using 3+ block categories
- Experiment with different block combinations