Learn SCRATCH with Real Code Examples
Updated Nov 25, 2025
Code Sample Descriptions
1
Simple Scratch Project
when green flag clicked
forever
if <key [right arrow] pressed?> then
change x by 10
end
if <key [left arrow] pressed?> then
change x by -10
end
end
A simple Scratch project where a sprite moves across the screen and responds to arrow keys.
2
Scratch - Hello World
when green flag clicked
say [Hello World!] for 2 seconds
Displays 'Hello World' when the green flag is clicked.
3
Scratch - Bouncing Sprite
when green flag clicked
point in direction (45)
forever
move 10 steps
if on edge, bounce
end
A sprite moves and bounces around the edges.
4
Scratch - Simple Counter
when green flag clicked
set [count v] to 0
forever
if <key [space] pressed?> then
change [count v] by 1
end
end
A variable counter increases when space is pressed.
5
Scratch - Play Sound
when green flag clicked
play sound [meow v]
Plays a sound when the green flag is clicked.
6
Scratch - Follow Mouse
when green flag clicked
forever
point towards [mouse-pointer v]
move 5 steps
end
A sprite follows the mouse pointer.
7
Scratch - Jump Mechanic
when green flag clicked
set [yvel v] to 0
forever
change y by (yvel)
change [yvel v] by -1
if <key [space] pressed?> then
set [yvel v] to 12
end
end
A simple jump using gravity simulation.
8
Scratch - Timer
when green flag clicked
reset timer
forever
say (timer)
end
Displays how long the project has been running.
9
Scratch - Score System
when green flag clicked
set [score v] to 0
forever
if <touching [apple v]?> then
change [score v] by 1
end
end
Basic score system that increases when touching another sprite.
10
Scratch - Sprite Animation
when green flag clicked
forever
next costume
wait 0.1 seconds
end
Switches costumes rapidly to simulate animation.