๐Ÿซ
BeanWise Tuition Computer Science
Year 7 ยท Scratch 3.0 ยท 6 Lessons ยท 1 Hour Each
๐Ÿฆˆ

Scratch Game Academy

Build a complete ocean survival game โ€” with enemies, power-ups, health bars, multiple levels, and changing seabeds. Real programming concepts, real fun.

๐ŸŽฎ Full Game Project ๐Ÿ“ฆ 8 Variables ๐Ÿงฉ 6 Custom Functions ๐ŸŒŠ 6 Changing Levels โ˜ ๏ธ 5 Types of Hazard
๐Ÿ—‚๏ธ Variables You'll Build in This Game
โญ
Variable
Score
Increases each time a fish is caught. Different fish = different points.
โค๏ธ
Variable
Lives
Starts at 3. Lost when fish escape or enemies hit the shark.
๐Ÿ’š
Variable
Health
0โ€“100. Drains when touching jellyfish or mines. Recharges per level.
๐ŸŒŠ
Variable
Level
1โ€“6. Each level changes the background, speed, and enemies.
โšก
Variable
FishSpeed
How fast fish swim. Increases each level. Used in spawnFish.
๐Ÿ†
Variable
HiScore
Stores the best score across all games. Never resets with Score.
โฑ๏ธ
Variable
TimeBonus
Countdown per level. Finish fast = bonus points added to Score.
โ˜ ๏ธ
Variable
PoisonActive
Boolean (0 or 1). Tracks if shark is currently poisoned by a pufferfish.
01
Lesson 1 ยท Sprites, Motion, Variables
Meet Your Shark ๐Ÿฆˆ
Stage setup ยท Arrow key movement ยท Score, Lives, Health variables ยท HUD display
๐ŸŒŠ
โ–ผ
By the end of Lesson 1 you'll have an ocean scene, a shark that moves smoothly in all four directions, and a working HUD (heads-up display) showing Score, Lives, and Health on screen. You'll understand what variables are and why games need them.
Part 1 โ€” Setting Up the Ocean
  • Open ScratchGo to scratch.mit.edu โ†’ Click Create. You'll see: the Stage (your game window, 480ร—360 pixels), the Sprite List, and the Code Blocks on the left.
  • Add your first backdrop โ€” Shallow WaterClick the Stage thumbnail (bottom-right) โ†’ Choose a Backdrop โ†’ search "Underwater 1". This will be your Level 1 background. Later you'll add more backdrops for higher levels.
  • Delete the cat, add a SharkRight-click the cat โ†’ Delete. Click Choose a Sprite โ†’ search Shark. If you can't find one, use Paint to draw a simple shark shape. Resize it so it fits comfortably on the stage (try 80px wide).
  • Position the shark at the centre-leftDrag the shark to around x: -150, y: 0 on the stage. This will be its start position.
๐Ÿง  Key Concept: The Coordinate System

Scratch uses X and Y coordinates. The centre of the stage is (0, 0). X goes from -240 (left edge) to +240 (right edge). Y goes from -180 (bottom) to +180 (top). Every sprite has an X and Y position at all times.

Part 2 โ€” Moving the Shark
  • Click on the Shark sprite โ€” all code goes hereMake sure the shark is highlighted in the sprite list before dragging blocks.
  • Build the movement code:
    ๐Ÿšฉ when Green Flag clicked
    go to x: (-150) y: (0)
    forever
    if <key [right arrow โ–ผ] pressed?> then
    change x by (6)
    point in direction (90)
    if <key [left arrow โ–ผ] pressed?> then
    change x by (-6)
    point in direction (-90)
    if <key [up arrow โ–ผ] pressed?> then
    change y by (5)
    if <key [down arrow โ–ผ] pressed?> then
    change y by (-5)
    Press the green flag and test it. The shark should move in all 4 directions.
  • Keep the shark inside the stageAdd this inside the forever loop to stop the shark going off-screen:
    if on edge, bounce
    Or for more control, use: if x position > 230 โ†’ set x to 230 (repeat for all 4 edges).
The forever loop runs 30 times per second. Each time it checks: "is a key being pressed?" This is called a polling loop โ€” the same technique used in real game engines.
Part 3 โ€” Creating All Your Variables

Now we'll create all the variables the game will need. Go to Variables โ†’ Make a Variable for each one. Set them all to "For all sprites".

Variable NameTypeStarting ValuePurpose
ScoreNumber0Points earned by catching fish
HiScoreNumber0Best score ever โ€” survives between games
LivesNumber3Lives remaining โ€” lose all = Game Over
HealthNumber100Hit points โ€” drains from hazards
LevelNumber1Current level (1โ€“6)
FishSpeedNumber3How fast fish move across the screen
TimeBonusNumber30Seconds left in the level โ€” becomes bonus points
PoisonActiveBoolean01 = shark is poisoned, 0 = shark is fine
Part 4 โ€” The startGame Function (Preview)
  • Set all starting values when the green flag is clickedAdd these at the top of your shark's green flag script, above the forever loop:
    set [Score โ–ผ] to (0)
    set [Lives โ–ผ] to (3)
    set [Health โ–ผ] to (100)
    set [Level โ–ผ] to (1)
    set [FishSpeed โ–ผ] to (3)
    set [TimeBonus โ–ผ] to (30)
    set [PoisonActive โ–ผ] to (0)
    In Lesson 3 we'll move all of this into a proper named function called startGame.
Part 5 โ€” HUD: Showing Variables on Screen
  • Show Score, Lives and Health on screenTick the checkbox next to each variable in the Variables palette. They appear as monitors on the stage. Drag them to neat positions โ€” Score top-left, Lives top-centre, Health top-right.
  • Hide FishSpeed, PoisonActive, Level from the playerUntick those checkboxes โ€” the player doesn't need to see those. Or right-click a monitor and choose hide.
In a real game you'd build a custom health bar sprite. For now the variable monitor is fine โ€” we'll polish it in Lesson 6.
๐Ÿ”ฅ Extension Challenge

Make the shark animate as it swims. In the Costumes tab, duplicate the shark costume and slightly move the tail fin. Then add next costume inside a wait 0.15 seconds loop running alongside your movement code.

โœ… Lesson 1 Checklist
  • Ocean backdrop is displayed
  • Shark sprite moves with all 4 arrow keys
  • Shark stays within the stage edges
  • All 8 variables are created
  • Score, Lives and Health show on screen
  • All values reset correctly when green flag is clicked
  • You can explain: what a variable is, what a coordinate is, what a forever loop does
02
Lesson 2 ยท Clones, Loops & Conditionals
Release the Fish! ๐ŸŸ
Clones ยท Random spawning ยท Collision detection ยท Multi-value fish
๐Ÿ 
โ–ผ
By the end of Lesson 2 your game will have multiple types of fish spawning from the right side. Catching them adds to the score (different fish = different points). Missing them costs a life. A golden fish appears rarely for bonus points.
Part 1 โ€” Add Three Fish Sprites
  • Add a regular fishClick Choose a Sprite โ†’ search Fish. Pick one and rename it "Fish" in the sprite info panel. Resize it to about 50px wide.
  • Add a second fish โ€” the Bonus FishAdd another fish sprite. Rename it "GoldFish". Change its colour in the Costumes tab โ€” select the fish shape and use the fill tool to make it golden/yellow. This fish will be worth 3 points.
  • Add a third fish โ€” the Speed FishAdd a third fish sprite, rename it "FastFish". Make it a bright red/pink colour. This fish moves fast but is only worth 1 point.
๐Ÿง  Key Concept: Clones

A clone is a temporary copy of a sprite. The original sprite hides itself and acts as a factory โ€” it produces clones over and over. Each clone runs its own code, moves independently, and can delete itself. This lets you have many fish on screen without needing many sprites.

Part 2 โ€” Regular Fish Clone System
  • Green flag script โ€” the factory
    ๐Ÿšฉ when Green Flag clicked
    hide
    forever
    create clone of [myself โ–ผ]
    wait (pick random (1) to (3)) seconds
  • Clone startup script โ€” each fish behaves on its own
    when I start as a clone
    show
    go to x: (240) y: (pick random (-160) to (160))
    set size to (pick random (60) to (100))%
    forever
    change x by ((0) - (FishSpeed))
    if <touching [Shark โ–ผ]?> then
    change [Score โ–ผ] by (1)
    play sound [Pop โ–ผ]
    delete this clone
    if <(x position) < (-240)> then
    change [Lives โ–ผ] by (-1)
    delete this clone
Using pick random for both the Y position and size makes each fish feel unique. Varying size also adds an illusion of depth โ€” bigger fish look closer.
Part 3 โ€” Golden Fish (3 points, rare)
  • GoldFish spawns less often and is worth more
    ๐Ÿšฉ when Green Flag clicked
    hide
    forever
    create clone of [myself โ–ผ]
    wait (pick random (5) to (10)) seconds

    when I start as a clone
    show
    go to x: (240) y: (pick random (-150) to (150))
    forever
    change x by ((0) - (FishSpeed))
    change y by (pick random (-2) to (2))
    if <touching [Shark โ–ผ]?> then
    change [Score โ–ผ] by (3)
    play sound [Ding โ–ผ]
    delete this clone
    if <(x position) < (-240)> then
    delete this clone
    Golden fish do NOT cost a life if missed โ€” they're a bonus opportunity only. The wobbly Y movement makes them harder to catch.
Part 4 โ€” Fast Fish (hard to catch, 1 point)
  • FastFish uses a local speed multiplier
    ๐Ÿšฉ when Green Flag clicked
    hide
    forever
    create clone of [myself โ–ผ]
    wait (pick random (3) to (6)) seconds

    when I start as a clone
    show
    go to x: (240) y: (pick random (-150) to (150))
    forever
    change x by ((0) - ((FishSpeed) * (2)))
    if <touching [Shark โ–ผ]?> then
    change [Score โ–ผ] by (1)
    delete this clone
    if <(x position) < (-240)> then
    change [Lives โ–ผ] by (-1)
    delete this clone
    Multiplying FishSpeed by 2 means FastFish always moves at double the current level speed โ€” this scales automatically as difficulty increases.
Part 5 โ€” Game Over Check
  • On the Shark sprite, monitor lives in the forever loop
    if <(Lives) < (1)> then
    broadcast [GameOver โ–ผ]
    stop [this script โ–ผ]
    We'll build the proper Game Over screen in Lesson 4. For now this just stops the shark moving.
HiScore: Add this check after updating Score โ€” if Score > HiScore โ†’ set HiScore to Score. The HiScore variable never gets reset by startGame, so it persists between games in the same session.
๐Ÿ”ฅ Extension Challenges
  • Make GoldFish flash between two costumes using a next costume / wait 0.2s loop so it's easy to spot
  • Add a brief score popup: when a fish is caught, make a clone of a "score text" sprite that floats upward and fades out
  • Play a different sound for each fish type (Pop for regular, Ding for gold, Whoosh for fast)
โœ… Lesson 2 Checklist
  • Regular fish spawn randomly from the right at varying heights and sizes
  • Golden fish appear less often, worth 3 points, and wobble as they swim
  • Fast fish move at double speed and are harder to catch
  • Catching any fish increases Score correctly
  • Missing a regular or fast fish costs 1 life
  • HiScore updates whenever Score beats the previous best
  • You can explain: what a clone is, what a Boolean condition is, what collision detection means
03
Lesson 3 ยท Custom Blocks (Functions)
Tidy Code with Functions ๐Ÿงฉ
Define blocks ยท Parameters ยท Abstraction ยท DRY principle
โš™๏ธ
โ–ผ
By the end of Lesson 3 you'll have reorganised your entire game into clean, named custom blocks: startGame, catchFish(points), loseLife, damageShark(amount), spawnFish, and nextLevel. You'll understand why functions are one of the most important tools in programming.
๐Ÿง  What is a Function?

A function (called a Custom Block in Scratch) is a named chunk of code you can reuse. Instead of writing the same logic in ten places, you write it once, give it a name, and call that name whenever you need it.

The two big benefits: DRY (Don't Repeat Yourself โ€” less code to write) and maintainability (if you want to change how catching a fish works, you change it in one place, not everywhere it happens).

Function 1 โ€” startGame (Shark sprite)
  • Create the custom blockClick the Shark sprite โ†’ My Blocks โ†’ Make a Block โ†’ name it startGame โ†’ click OK.
  • Move all your setup code into it
    define startGame
    set [Score โ–ผ] to (0)
    set [Lives โ–ผ] to (3)
    set [Health โ–ผ] to (100)
    set [Level โ–ผ] to (1)
    set [FishSpeed โ–ผ] to (3)
    set [TimeBonus โ–ผ] to (30)
    set [PoisonActive โ–ผ] to (0)
    go to x: (-150) y: (0)
    show
    switch backdrop to [Underwater 1 โ–ผ]
  • Call it from the green flag
    ๐Ÿšฉ when Green Flag clicked
    startGame
    forever
    โ€” (movement code) โ€”
Function 2 โ€” catchFish(points) with a Parameter
  • Create catchFish with an inputGo to My Blocks (on the Fish sprite) โ†’ Make a Block โ†’ name it catchFish. Click Add an input (number or text) and name it points. Click OK.
  • Build the block using the parameter
    define catchFish (points)
    change [Score โ–ผ] by (points)
    if <(Score) > (HiScore)> then
    set [HiScore โ–ผ] to (Score)
    play sound [Pop โ–ผ] until done
    delete this clone
  • Call it differently for each fish type
    catchFish (1)
    โ† for regular fish
    catchFish (3)
    โ† for golden fish
    catchFish (1)
    โ† for fast fish
    Same function, different arguments. The word inside the brackets is called an argument โ€” the value you pass into the parameter.
Function 3 โ€” loseLife (Fish sprite)
  • Create loseLife on the Fish sprite
    define loseLife
    change [Lives โ–ผ] by (-1)
    play sound [Oops โ–ผ]
    if <(Lives) < (1)> then
    broadcast [GameOver โ–ผ]
Function 4 โ€” damageShark(amount) (Shark sprite)
  • This will be used by enemies in Lesson 4
    define damageShark (amount)
    if <(PoisonActive) = (0)> then
    change [Health โ–ผ] by ((0) - (amount))
    set [color โ–ผ] effect to (50)
    wait (0.2) seconds
    clear graphic effects
    if <(Health) < (1)> then
    change [Lives โ–ผ] by (-1)
    set [Health โ–ผ] to (100)
    if <(Lives) < (1)> then
    broadcast [GameOver โ–ผ]
    When health hits zero, the shark loses a life but health resets to 100 โ€” giving the player a chance to survive.
Function 5 โ€” nextLevel (Shark sprite)
  • Increase difficulty and update the scene
    define nextLevel
    change [Level โ–ผ] by (1)
    change [FishSpeed โ–ผ] by (1)
    change [Score โ–ผ] by (TimeBonus)
    set [Health โ–ผ] to (100)
    set [TimeBonus โ–ผ] to (30)
    next backdrop
    say (join [Level ] (Level)) for (2) secs
    broadcast [LevelUp โ–ผ]
Notice how nextLevel also adds the TimeBonus to Score and resets Health โ€” the player is rewarded for completing a level quickly and starts fresh. This is a game design decision, not just a coding choice.
Calling nextLevel โ€” Every 5 Fish Caught
  • Add this check to the shark's forever loop
    if <((Score) mod (5)) = (0) and (Score) > (0)> then
    nextLevel
    mod (modulo) gives the remainder of division. 15 mod 5 = 0, 16 mod 5 = 1. So this fires at exactly 5, 10, 15, 20 fish caught.
๐Ÿ”ฅ Extension Challenge โ€” Function with boolean parameter

Edit loseLife to accept a boolean parameter showWarning. If it's 1, show a red flash on screen. If it's 0, just deduct quietly. This teaches conditional logic inside functions.

โœ… Lesson 3 Checklist
  • startGame resets all 8 variables and is called from the green flag
  • catchFish(points) uses a parameter and updates HiScore
  • loseLife deducts a life and broadcasts GameOver when Lives = 0
  • damageShark(amount) reduces Health and handles health = 0
  • nextLevel increases Level and FishSpeed, adds TimeBonus to Score, changes backdrop
  • The game still plays exactly as before โ€” functions didn't change behaviour, just organisation
  • You can explain: what a parameter is, what DRY means, why functions help with debugging
04
Lesson 4 ยท Enemies, Health & Hazards
Danger in the Deep โ˜ ๏ธ
Jellyfish ยท Mines ยท Pufferfish ยท Octopus ยท Health system ยท Poison effect
๐Ÿชผ
โ–ผ
By the end of Lesson 4 your shark will face five types of hazard: a jellyfish that drains health, a mine that causes instant life loss, a pufferfish that poisons the shark slowing it down, an octopus that blocks movement, and a whirlpool that briefly pulls the shark off course.
โ˜ ๏ธ Enemies & Hazards Guide
๐Ÿชผ Jellyfish
Floats up and down slowly. Appears from Level 1.
Effect: -10 Health per second of contact
๐Ÿ’ฃ Mine
Drifts slowly across the screen. Appears from Level 2.
Effect: -1 Life instantly on touch
๐Ÿก Pufferfish
Swims like a fish but inflates when touched. Level 3+.
Effect: Activates PoisonActive for 5 seconds โ€” shark moves at half speed
๐Ÿ™ Octopus
Emerges from the bottom. Tentacles grab the shark. Level 4+.
Effect: Freezes shark movement for 2 seconds, -15 Health
๐ŸŒ€ Whirlpool
Appears randomly on screen, slowly rotates. Level 5+.
Effect: Pushes shark in a random direction, -5 Health
Hazard 1 โ€” Jellyfish
  • Add a Jellyfish spriteSearch the sprite library for "Jellyfish" or draw one. Rename it "Jellyfish". Make it semi-transparent in the costumes editor (set fill opacity to 70%).
  • Factory script (green flag)
    ๐Ÿšฉ when Green Flag clicked
    hide
    forever
    create clone of [myself โ–ผ]
    wait (pick random (4) to (8)) seconds
  • Clone script โ€” floating movement
    when I start as a clone
    show
    go to x: (pick random (-200) to (200)) y: (-200)
    forever
    change y by (2)
    change x by (pick random (-1) to (1))
    if <touching [Shark โ–ผ]?> then
    damageShark (10)
    wait (0.5) seconds
    if <(y position) > (200)> then
    delete this clone
    The wait 0.5 seconds after dealing damage prevents the shark from losing all health instantly โ€” it caps the damage rate to 20 HP per second.
Hazard 2 โ€” Mine
  • Add a Mine spriteDraw a simple black circle with small spikes (like a sea mine) in the Paint editor, or search the library. Rename it "Mine".
  • Mine clone script
    ๐Ÿšฉ when Green Flag clicked
    hide
    forever
    if <(Level) > (1)> then
    create clone of [myself โ–ผ]
    wait (pick random (6) to (12)) seconds

    when I start as a clone
    show
    go to x: (240) y: (pick random (-150) to (150))
    forever
    change x by (-1)
    if <touching [Shark โ–ผ]?> then
    change [Lives โ–ผ] by (-1)
    set [ghost โ–ผ] effect to (80)
    wait (0.3) seconds
    delete this clone
    if <(x position) < (-250)> then
    delete this clone
    Mines only start appearing from Level 2 (the if Level > 1 check). They're slow but deadly โ€” instant life loss.
Hazard 3 โ€” Pufferfish (Poison)
  • Add a Pufferfish spriteSearch the library or paint a round fish. Give it two costumes: normal (small) and puffed up (large circle). Rename it "Pufferfish".
  • Poison effect script
    when I start as a clone
    show
    switch costume to [puffer-normal โ–ผ]
    go to x: (240) y: (pick random (-150) to (150))
    forever
    change x by ((0) - (FishSpeed))
    if <touching [Shark โ–ผ]?> then
    switch costume to [puffer-big โ–ผ]
    set [PoisonActive โ–ผ] to (1)
    wait (5) seconds
    set [PoisonActive โ–ผ] to (0)
    delete this clone
  • Slow the shark when poisoned โ€” modify movement code In the shark's movement forever loop, change the movement amounts:
    if <key [right arrow โ–ผ] pressed?> then
    if <(PoisonActive) = (1)> then
    change x by (3)
    else
    change x by (6)
    Repeat this pattern for all 4 directions. When poisoned, the shark moves at half speed. The same pattern goes for Y movement.
Hazard 4 โ€” Octopus (Freeze)
  • Add Octopus sprite from the libraryRename it "Octopus". It will rise from the bottom and broadcast a freeze event when touched.
  • Octopus clone + freeze broadcast
    when I start as a clone
    show
    go to x: (pick random (-180) to (180)) y: (-200)
    repeat (60)
    change y by (3)
    if <touching [Shark โ–ผ]?> then
    broadcast [FreezeShark โ–ผ]
    damageShark (15)
    delete this clone
    delete this clone

    when I receive [FreezeShark โ–ผ]
    โ† Add this to the SHARK sprite
    stop [other scripts in sprite โ–ผ]
    set [color โ–ผ] effect to (150)
    wait (2) seconds
    clear graphic effects
    broadcast [UnfreezeShark โ–ผ]
Using broadcast to communicate between sprites is a key Scratch technique. It's a simplified version of the event-driven programming pattern used in real apps and games.
Hazard 5 โ€” Whirlpool
  • Create a Whirlpool sprite in the Paint editorDraw a blue spiral. Give it two costumes and animate it. Rename it "Whirlpool".
  • Whirlpool script โ€” push effect
    when I start as a clone
    show
    go to x: (pick random (-180) to (180)) y: (pick random (-150) to (150))
    repeat (200)
    next costume
    wait (0.1) seconds
    if <touching [Shark โ–ผ]?> then
    change x by (pick random (-20) to (20))
    change y by (pick random (-20) to (20))
    damageShark (5)
    delete this clone
๐Ÿ”ฅ Extension Challenges
  • Add a visual health bar sprite: a long rectangle that changes width based on the Health variable using set size to (Health) % (width only)
  • Make the shark turn green and flash when PoisonActive = 1 using a colour effect loop
  • Add a power-up fish (a starfish?) โ€” catching it sets Health back to 100 and gives 5 seconds of invincibility where damageShark does nothing
โœ… Lesson 4 Checklist
  • Jellyfish drains Health by 10 on contact (with 0.5s cooldown)
  • Mines appear from Level 2 and instantly cost a life on contact
  • Pufferfish sets PoisonActive = 1 for 5 seconds, halving shark speed
  • Octopus broadcasts FreezeShark, stopping movement for 2 seconds
  • Whirlpool pushes the shark in a random direction
  • damageShark(amount) function is used by all enemies
  • Health dropping to 0 costs a life and resets Health to 100
  • You can explain: event-driven programming, what a broadcast does, why the damage cooldown is important
05
Lesson 5 ยท Levels & Changing Worlds
Level Up! ๐ŸŒŠ
6 backdrops ยท Level transitions ยท Difficulty scaling ยท Game Over screen
โšก
โ–ผ
By the end of Lesson 5 your game will have 6 full levels, each with a different ocean backdrop, increasing difficulty, new enemies unlocking at specific levels, a TimeBonus countdown, and a polished Game Over screen that shows the final score and HiScore.
Part 1 โ€” The 6 Level Backdrops

Go to the Stage โ†’ Backdrops tab. Add 6 backdrops in order. The next backdrop block in your nextLevel function will cycle through them automatically.

๐ŸŒ…
Level 1
Shallow Reef
Bright, colourful coral. "Underwater 1" from library.
๐ŸŒฟ
Level 2
Seagrass Meadow
Murky green. "Underwater 2" from library.
๐Ÿ”†
Level 3
Open Ocean
Deep blue, less coral. Use "Blue Sky 2" recoloured.
๐ŸŒ‘
Level 4
Twilight Zone
Dark purple. Use Paint โ€” dark gradient background.
๐Ÿ”ด
Level 5
Volcanic Vent
Dark red/orange glow. Paint a dark bg with orange spots.
๐ŸŒŒ
Level 6
The Abyss
Near-black. Paint nearly black โ€” adds dramatic tension.
After adding all 6 backdrops, check they appear in the right order in the Backdrops tab. next backdrop moves through them in order, looping back to the first if it reaches the end.
Part 2 โ€” Level Difficulty Table

Your nextLevel function increases FishSpeed by 1 each time. Here's how each level feels:

LevelFishSpeedSpawn DelayNew Enemies UnlockedTimeBonus
131โ€“3 secJellyfish only30
240.8โ€“2.5 secMines appear30
350.6โ€“2 secPufferfish appear30
460.5โ€“1.5 secOctopus appears30
570.4โ€“1.2 secWhirlpools appear30
680.3โ€“1 secAll enemies โ€” survival mode30
Part 3 โ€” Level-Gated Enemy Spawning
  • Each enemy checks the Level variable before spawning You already did this for Mines. Do the same for each other enemy. Example โ€” Pufferfish:
    ๐Ÿšฉ when Green Flag clicked
    hide
    forever
    if <(Level) โ‰ฅ (3)> then
    create clone of [myself โ–ผ]
    wait (pick random (5) to (10)) seconds
    Apply this pattern to each enemy with their unlock level from the table above.
Part 4 โ€” TimeBonus Countdown
  • Add a separate countdown script on the Shark
    when I receive [LevelUp โ–ผ]
    repeat (30)
    wait (1) seconds
    if <(TimeBonus) > (0)> then
    change [TimeBonus โ–ผ] by (-1)
    When a level starts (triggered by the LevelUp broadcast), TimeBonus counts down from 30 to 0. Whatever's left gets added to Score when nextLevel fires.
Part 5 โ€” Winning at Level 6
  • Check if Level goes past 6 โ†’ trigger Win state Add to the nextLevel check in the forever loop:
    if <(Level) > (6)> then
    broadcast [YouWin โ–ผ]
    stop [this script โ–ผ]
Part 6 โ€” Game Over & You Win Screens
  • Create a "GameOver" spriteUse the Paint editor. Draw a dark rectangle that covers most of the stage. Add text: "GAME OVER", and use join blocks to show the score and HiScore. Add a "Press Space to Restart" instruction.
  • GameOver sprite code
    ๐Ÿšฉ when Green Flag clicked
    hide

    when I receive [GameOver โ–ผ]
    show
    go to front layer
    say (join [Score: ] (join (Score) (join [ Best: ] (HiScore))))
    wait until <key [space โ–ผ] pressed?>
    hide
    broadcast [RestartGame โ–ผ]
  • Restart the game from broadcast On the Shark sprite, add:
    when I receive [RestartGame โ–ผ]
    startGame
    forever
    โ€” (movement code) โ€”
    Now the game fully restarts without needing to press the green flag again.
  • Create a YouWin screen similarlyDuplicate the GameOver sprite, change the text to "YOU WIN! ๐Ÿ†", add a congratulations message with the final score, and trigger it from the YouWin broadcast.
๐Ÿ”ฅ Extension Challenges
  • Add a level transition animation โ€” when LevelUp broadcasts, show a full-screen flash or a "LEVEL 2" text sprite that fades in and out before gameplay resumes
  • Play different background music per level using a music sprite that changes its costume/sound on each LevelUp broadcast
  • Add a combo multiplier โ€” catch 3 fish in a row within 3 seconds, get 2x points. Miss one = combo resets
โœ… Lesson 5 Checklist
  • All 6 backdrops are added to the Stage in order
  • Backdrop changes automatically with each level via next backdrop
  • Each enemy has a level gate โ€” enemies unlock progressively
  • TimeBonus counts down during each level and is added to Score on level completion
  • Level 7 triggers a YouWin broadcast instead of a new level
  • Game Over screen shows Score and HiScore
  • Pressing Space on the Game Over screen fully restarts the game
  • You can explain: what event-driven programming is, how broadcasts enable sprite communication
06
Lesson 6 ยท Polish, Debug & Showcase
Make It Shine โœจ
Sound ยท Health bar ยท Start screen ยท Debugging ยท Peer review ยท Share
๐Ÿ†
โ–ผ
By the end of Lesson 6 your game will feel like a complete, polished product โ€” with a start screen, background music that changes per level, a visual health bar, particle effects, and your project shared on the Scratch community.
Part 1 โ€” Start Screen
  • Create a StartScreen spritePaint a large rectangle that covers the stage. Add your game title "SHARK ATTACK!", the controls (arrow keys to move, avoid enemies, catch fish), and "Press SPACE to Start".
  • StartScreen code
    ๐Ÿšฉ when Green Flag clicked
    show
    go to front layer
    switch backdrop to [title-screen โ–ผ]
    wait until <key [space โ–ผ] pressed?>
    hide
    broadcast [StartGame โ–ผ]
  • Update all sprites to wait for StartGameChange every sprite's green flag script so their factories don't start until they receive the StartGame broadcast. This stops fish and enemies spawning before the player is ready.
Part 2 โ€” Visual Health Bar
  • Create a HealthBar spriteIn the Paint editor, draw a green rectangle about 100px wide and 12px tall. Position it in the top-right corner of the stage.
  • Make it scale with Health
    ๐Ÿšฉ when Green Flag clicked
    forever
    set size to (Health) %
    if <(Health) > (60)> then
    set [color โ–ผ] effect to (0)
    else if <(Health) > (30)> then
    set [color โ–ผ] effect to (25)
    else
    set [color โ–ผ] effect to (0) ... and make it flash red
    Green = healthy (60โ€“100), yellow = caution (30โ€“60), red and flashing = danger (0โ€“30). This gives the player at-a-glance health feedback.
Part 3 โ€” Sound Design
  • Background musicAdd a Music sprite. On StartGame broadcast: play a looping background track. On LevelUp: switch to a slightly faster/more intense track. On GameOver: play a sad jingle.
  • Sound effects checklist
    • ๐ŸŽต Regular fish caught: Pop
    • ๐ŸŽต Gold fish caught: Ding / Tada
    • ๐ŸŽต Life lost: Oops / Boing
    • ๐ŸŽต Jellyfish hit: Zap / Crackle
    • ๐ŸŽต Mine explodes: Boom / Crash
    • ๐ŸŽต Poisoned: Wah Wah / Sad Trombone
    • ๐ŸŽต Level up: Trumpet / Fanfare
    • ๐ŸŽต Game over: Lose / Game Over
    • ๐ŸŽต You win: Win / Cheer
Part 4 โ€” Particle Effects
  • Create a "Particle" sprite โ€” small sparkle/bubbleDraw a tiny star or circle in the Paint editor. This will be used for a catch effect.
  • Spawn particles when a fish is caught In your catchFish function, add before deleting the clone:
    repeat (5)
    create clone of [Particle โ–ผ]
    Then on the Particle sprite, when starting as a clone: go to the fish's position, move in a random direction, fade out (ghost effect 0โ†’100), then delete.
Part 5 โ€” Debugging Your Game
  • Playtest 3 full gamesWrite down: anything that crashes, any score that seems wrong, any enemy that behaves unexpectedly, anything that feels unfair or boring.
  • Use variable monitors to debugTick the checkbox on PoisonActive and Lives temporarily. Watch them change in real-time during play. Untick when fixed.
  • Give your game to someone else to play โ€” don't explain anythingWatch where they get confused. If they can't figure out the controls, you need a better start screen. If they die without knowing why, your feedback needs improving.
Common bugs: score increasing multiple times per catch (fix: delete clone immediately after catchFish), enemies dealing damage too fast (fix: add a wait after damageShark), Level variable going past 6 (fix: cap with if Level > 6 โ†’ set Level to 6 OR trigger YouWin).
Part 6 โ€” Share & Showcase
  • Write a project descriptionIn Scratch, click Share then fill in: Title ("SHARK ATTACK! by [Your Name]"), Instructions (arrow keys, what to avoid, how to score), and Notes (how long it took, what you're most proud of).
  • Peer reviewPlay two classmates' games. Leave a comment with: one specific thing you liked (be precise โ€” not "it's good", but "the golden fish wobbling is a great challenge") and one constructive suggestion.
๐ŸŒŸ Bonus Mega-Challenges
If you finished everything โ€” try these!
  • Power-up Starfish โ€” catching it gives 10 seconds of invincibility (PoisonActive blocks damage already, use a similar InvincibleActive variable)
  • Scrolling seabed โ€” create a long backdrop sprite and scroll it left at FishSpeed to give the illusion of movement
  • High score leaderboard โ€” use Scratch's cloud variables (requires account) to store top 3 scores that persist between sessions for all players
  • Two-player mode โ€” second shark controlled by WASD keys, competing for the same fish, each with their own score variable
  • Boss level at Level 6 โ€” a giant whale that slowly moves across the screen. Takes 5 hits to kill (using a BossHealth variable). Defeating it gives 20 bonus points.
โœ… Final Game Checklist โ€” Is It Complete?
  • Start screen appears before gameplay begins
  • Shark moves in 4 directions, stays on stage
  • 3 fish types: regular (1pt), golden (3pt, rare), fast (1pt, moves fast)
  • 5 hazards: jellyfish (health drain), mine (instant life), pufferfish (poison/slow), octopus (freeze), whirlpool (push)
  • 8 variables working: Score, HiScore, Lives, Health, Level, FishSpeed, TimeBonus, PoisonActive
  • 6 custom functions: startGame, catchFish(points), loseLife, damageShark(amount), nextLevel, spawnFish
  • 6 level backdrops change automatically
  • Enemies unlock progressively by level
  • TimeBonus countdown adds to Score each level
  • Visual health bar changes colour with health
  • Game Over screen shows Score + HiScore, restarts on Space
  • You Win screen appears after Level 6
  • Sound effects for every major event
  • Project shared on Scratch with title, instructions and description
  • You left constructive feedback on two classmates' games
๐Ÿ†
You Did It!

You've built a complete game with 8 variables, 6 custom functions with parameters, 5 types of enemy, 6 changing levels, collision detection, health systems, event-driven programming and a polished UI. That's genuinely impressive โ€” and it's the same set of ideas used in every game ever made.