Learning Hub/Scratch/Session 3

Session 3 of 5 · 60 minutes

Sports

Build sports games: make things move, notice when they touch, and keep score.

Goals

By the end of this session you can:

  • Move a sprite with motion blocks and the keyboard
  • Use if touching to react when two sprites meet
  • Keep a score with a variable
  • Remix a sports starter project and change how the game plays

Words to know

condition
A question the game asks, like "am I touching the ball?". The answer is yes or no.
variable
A named box that holds a value, such as score. It can change while the game runs.
coordinates
The x and y numbers that say where a sprite is on the stage.

The lesson

Step 1: Net Sports

Today’s main project is Sports - Net Sports. Open a starter, press the green flag, play it, and look at how it works with See inside.

Step 2: Move things

Open the Motion category.

BlockWhat it does
move 10 stepsMoves the sprite forward.
change x by 10Moves the sprite right (use a negative number to go left).
change y by 10Moves the sprite up.
go to x: y:Jumps to a spot on the stage.
if on edge, bounceTurns the sprite around when it hits the edge.

Add when right arrow key pressed from Events on top, and you can move a sprite with the keyboard.

Step 3: Ask a question with if

A sports game must notice when things meet. Use if touching Ball then from Control and Sensing, and put the blocks you want to run inside it. Put the if inside a forever so the game keeps checking.

Step 4: Keep score

  1. Open Variables and click Make a Variable. Name it score.
  2. Under when green flag clicked, add set score to 0.
  3. Inside your if touching, add change score by 1.

Step 5: Projects to remix

If your class finishes the main project early, choose one of these.

Exercise

Catch the ball and score

  1. Add a ball sprite and a catcher sprite (a basket, a net or a glove).
  2. Make the catcher move: when right arrow key pressed, change x by 10, and the same for the left arrow with change x by -10.
  3. In Variables, click Make a Variable and name it score. Put set score to 0 under when green flag clicked.
  4. On the ball: forever, if touching Catcher then, change score by 1, then go to the top of the stage.
  5. Play it and see if the score goes up.
Need a hint?

Choose the catcher's name in the drop-down of the touching block.

Small project

My sports game

Remix a sports starter project and change it so it plays your way.

  1. Open Net Sports (choose one of its starters) and click Remix.
  2. Play it once. Find the score, the moving parts and how it ends.
  3. Change the look: new sprites, costumes or a new backdrop.
  4. Change one rule, such as how fast things move or how many points a catch is worth.
  5. Test it and ask a classmate to play.

Stretch it: Make the game get harder as the score grows.

Quiz

Check your understanding

Pick one answer for each question. Your score appears right in the page; nothing is sent anywhere.

  1. Question 1What does a variable do in a game?
  2. Question 2Which block would you use to add 1 point to the score?
  3. Question 3You want a script to run only when a sprite is touching the ball. What do you use?
  4. Question 4Why do we put set score to 0 under when green flag clicked?
  5. Question 5In the game, a ball must keep checking whether it touches the catcher. Which block repeats the check?