Introduction to Scratch & Coding

Introduction to the Catch Game

In this lesson, we will create a fun catch game using Scratch.

  • One sprite will act as the player and catch other sprites.
  • The player sprite will be controlled using the mouse pointer.
  • This lesson helps students understand movement, sensing, and conditions in Scratch.

What Students Will Learn

  • Control a sprite using the mouse pointer
  • Move sprites using motion blocks
  • Repeat actions using forever loops
  • Detect touch between sprites
  • Use if-then conditions
  • Hide and show sprites
  • Add sound effects
  • Duplicate sprites

Adding Sprites

In this project, we will use two main sprites:

  • Shark sprite – the player
  • Small fish sprite – the object to be caught

How to add sprites:

  1. Click on the Choose a Sprite icon at the bottom right corner
  2. Select a shark sprite from the library
  3. Click again on Choose a Sprite and select a small fish sprite

Changing the Background

  1. Click on the Choose a Backdrop icon
  2. Select an underwater background
  3. This background matches the theme of the shark and fish game

Coding the Shark Sprite (Player)

Starting the Code

  • Select the shark sprite
  • Go to the Events category
  • Drag the when green flag clicked block

Explanation: This block tells Scratch to start the game when the green flag is clicked.

Making the Shark Follow the Mouse Pointer

  • Go to the Motion category
  • Drag the point towards mouse pointer block

Explanation:

  • The mouse pointer is the arrow that moves on the screen
  • This block makes the shark face the mouse pointer

Repeating the Action

  • Go to the Control category
  • Add a forever block
  • Place the point towards mouse pointer block inside it

Explanation: The forever block repeats the code continuously.

Moving the Shark

  • Go to Motion
  • Add the move steps block inside the forever loop
  • Change the value to 3 or 4 for smoother movement

Coding the Small Fish Movement

Starting the Fish Code

  • Select the small fish sprite
  • Go to Events and add when green flag clicked

Making the Fish Move Randomly

  • Go to Motion
  • Add glide 1 second to random position

Explanation: This block makes the fish glide smoothly to random places on the stage.

Repeating the Movement

  • Go to Control
  • Add a forever block
  • Place the glide block inside it

Using Touch Detection

Understanding Touching

  • Sprites can sense when they touch another sprite
  • Touching is handled using sensing blocks

Creating the Touch Code

  • On the fish sprite, add another when green flag clicked block
  • Go to Control and add an if then block

Explanation:

  • If-then checks a condition
  • If the condition is true, the code inside runs

Detecting Touch

  • Go to the Sensing category
  • Pick touching and change it to touching shark

Hiding the Fish

  • Go to Looks
  • Add the hide block inside the if-then block

Repeating the Check

  • Add a forever block around the if-then block
  • This allows Scratch to check the touch condition continuously

Showing the Fish When the Game Starts

  • When the fish hides, it should appear again when the game restarts
  • Go to Looks
  • Add the show block with when green flag clicked

Adding Sound Effects

  • Go to the Sounds tab of the fish sprite
  • Click Choose a Sound
  • Search for a bite sound and add it

Adding the Sound to Code:

  • Go to the Sound category
  • Add play sound until done
  • Place it near the hide block

Duplicating Fish Sprites

  • Right-click on the fish sprite
  • Click Duplicate

Explanation:

  • Duplicating a sprite copies all the same code
  • You can change the costume of each fish to make them look different

Summary of What Students Learned

  • Control a sprite using the mouse
  • Move sprites smoothly
  • Use forever loops
  • Detect touching
  • Hide and show sprites
  • Add sounds
  • Duplicate sprites

Task for Students

Create your own catch game:

  • Choose any sprite as your player
  • Add at least two sprites to catch
  • Try changing speed, background, or sounds