1 of 14

Lesson 7: You’ve got the moves!

Year 7 – Programming essentials in Scratch: part II

2 of 14

Think, write, pair, share

Starter activity

What do you think might happen when this code is run?

3 of 14

Custom blocks are subroutines

Starter activity

Subroutines are a group of instructions that will run when called by the main program or other subroutines.

Subroutines allow us to use a piece of code again and again whenever we call them.

4 of 14

Lesson 7: You’ve got the moves!

Objectives

In this lesson, you will:

  • Define a subroutine as a group of instructions that will run when called by the main program or other subroutines
  • Define decomposition as breaking a problem down into smaller, more manageable subproblems
  • Identify how subroutines can be used for decomposition

4

5 of 14

Four volunteers please!

Activity 1

6 of 14

Subroutines and decomposition

Activity 1

Subroutines can be called whenever you need them, and in any order you want.

Once a subroutine is written and working, the instructions inside become less important.

Subroutines help break down a problem into small manageable chunks. This in known as decomposition.

7 of 14

Problem

Activity 2

A programmer wants to create a character that will perform different dance moves to a song. The dance moves will form part of a dance battle game where players perform the best moves to earn points.

8 of 14

Problem

Activity 2

A programmer wants to create a character that will perform different dance moves to a song. The dance moves will form part of a dance battle game where players perform the best moves to earn points.

Think, pair, write, share

How could the programmer decompose this problem?

9 of 14

Plan four moves

Activity 3

Some decomposition has been started for you.

The programmer would like to have four different dance moves and wants a subroutine for each one.

Use the worksheet to design four moves for your character to perform.

The worksheet shows the nine different costumes that you can use.

10 of 14

How to create your own subroutines

Activity 4

Your teacher will demonstrate how to create your own subroutines in Scratch.

11 of 14

Create four subroutines

Activity 4

Use this Scratch project to create four dance moves.

Two example moves have been given to Jordyn already to help you.

You can delete or keep these moves.

Explorer task

Create more complex moves and check that your moves match the beat of the music.

ncce.io/DanceBattle

12 of 14

Extending your game

Activity 5

Trigger the moves based on a key press.

You can add more than one move to a key press.

Copy the subroutines over to your other character and modify the key presses.

Explorer task

Add a scoring system for the different moves of each character. Work out who wins!

13 of 14

What do you know about subroutines?

Plenary

Write one thing that you know about subroutines on a sticky note and attach it to the whiteboard.

14 of 14

Next lesson

Summary

In this lesson, you…

  • Defined a subroutine as a group of instructions that will run when called by the main program or other subroutines
  • Defined decomposition as breaking a problem down into smaller, more manageable subproblems
  • Identified how subroutines can be used for decomposition

Next lesson, you will…

  • Identify where condition-controlled iteration can be used in a program
  • Implement condition controlled iteration in a program

14