Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

Scratch

LESSON 1

1
Starter
We need one volunteer who is willing to be blindfolded.
We need another volunteer to direct them around the
room.
The blindfolded person must follow the instructions
EXACTLY and must get to the “X” avoiding the sharks.

2
Objective of the lesson
Understand how flow diagrams help with the
planning of programs.

All of you will:


◦ Create simple codes using Scratch.

Most of you will:


◦ Create more complex code including the repeat function.
◦ Understand how a flow diagram relates to a program.

Some of you will:


◦ Explain the difference between a forever and repeat function
and create code in Scratch confidently.
3
Scratch
You are going to be using a programming language
called Scratch.
This uses pieces of code known as “script” to affect
a character on the screen known as a “sprite”.
Load up Scratch and we will look at the layout of
the screen.

4
Script
Groups

Sprite

Stage

Script Script
Blocks Area
Script Groups
To help you find the script that
you need, they have been
grouped together and colour
coded.
For instance, all the script to do
with movement is in the motion
group, all the script to do with
how the program runs is in the
control group.

6
Adding Script
To add a script to the program you need to follow these steps:

Step 1: Select
the correct
Script group

Step 2: Select
Script block Step 3: Drag the
block into the
Script area
7
Moving the Cat
What will this do?

When the Space Key


is pressed…

Turn the cat 15


degrees clockwise
Try it out!
Change the code
What will the code do now?

When the Space Key


is pressed…

Turn the cat 15


degrees clockwise

Change the cat’s


colour effect by 25
Algorithms
An algorithm is a plan, a set of step-by-step instructions
to solve a problem.
There are three basic building blocks (constructs) to use
when designing algorithms:
• sequencing
• selection
• iteration
These building blocks help to describe solutions in a form
ready for programming.
Sequence
Sequencing is the specific order in which instructions are
performed in an algorithm.
Each step is an instruction to be performed. Sequencing is the
order in which the steps are carried out.
A computer can only do what it is programmed to do. If the
steps are programmed in the wrong sequence, the computer
will perform the tasks in this sequence – even if this is incorrect.
Showing this in a flow chart
Start

Turn 15 degrees
clockwise

A “Flowchart” is a diagram showing


Change colour how the program will run.
effect by 25 It is used to help when planning
programs.
Stop
Selection
Selection is a decision or question.
At some point in an algorithm there may need to be a
question because the algorithm has reached a step where
one or more options are available.
Depending on the answer given, the algorithm will follow
certain steps and ignore others.
Without selection, different paths would not be included
in algorithms. This means that the solutions created would
not be realistic.
Showing this in a flow chart
Start

Move 10 steps

If touching
the edge
This flow diagram includes a decision
box to see if the counter touched the
Turn 15 degrees edge – if it has then it will turn 15
clockwise degrees clockwise and if not then it
will stop moving

Stop
Iteration
Iteration in programming means repeating steps,
or instructions, over and over again. This is often called a
‘loop’.
Algorithms consist of instructions that are carried out
(performed) one after another. Sometimes an algorithm
needs to repeat certain steps until told to stop or until a
particular condition has been met.
Iteration allows algorithms to be simplified by stating that
certain steps will repeat until told otherwise. This makes
designing algorithms quicker and simpler because they
don’t need to include lots of unnecessary steps.
Getting the program to repeat
Rather than having to keep pressing the space bar (or
holding it down) it would be nice to make the programme
run automatically.

Repeat the code


inside this section
10 times
Showing this in a flow chart
Start

Counter = 1

Counter No
= 10?
Turn 15 degrees
Yes clockwise
This flow diagram includes
Change colour a decision box to see if the
effect by 25
counter has reached 10.
Counter + 1
Stop
Over to you…
Add a piece of code which
will do the following:
◦ When the space Bar is
pressed
◦ Repeat 3 times
◦ Make the cat say “Hello!” for 1
second
◦ Turn 15 degrees anticlockwise
New Project
Start a new project
Delete the Cat sprite
by right-clicking on
the cat and selecting
Delete.
Change the sprite by using the New Sprite button.

New sprite
button
Change the Sprite
Select the Beachball sprite.
Add some code for the following:
◦ When the green flag is clicked
◦ Move 10 spaces

What happens when you click on the green flag?


Showing this as a flow chart
Start

Move 10 steps This will run the code once so the


user will have to keep clicking on the
green flag to move the ball again.

Stop
Change the code
What will this code do?

What is the difference between a repeat and a forever


loop?
Showing this as a flow chart
Start

Move 10 steps
Once the green flag is clicked the ball will
carry on moving, even if that means it moves
off the edge of the screen.
Stopping the ball moving off the screen
Change your code to the
following:

You can change the direction of the ball.


Stop the program running
Click on Direction

Drag the blue line to


a different angle
Showing this as a flow chart
Start

Move 10 steps

Is it
touching No Now this has a decision box
the edge?
to find out if it is touching
Yes the edge and if it is, it will
Turn away from move away from the edge.
edge
Over to you…
Start

Start a new project. Move 5 steps

Delete the cat sprite. Change the colour


effect by 25
Add a sprite of your choice.
Create the code to match this Is it No
flow chart. touching
the edge?

• Add a second sprite Yes


Turn away from
which will move faster edge
than the first.
Have a go yourself…
Today you have learnt:
◦ Ways to start the program (green flag and space bar)
◦ How to move an object
◦ How to change colour
◦ Using the Repeat and Forever loops
◦ How to change the sprite

Now you can experiment with Scratch and practise


what you have learnt by creating an animation of
your choice.

You might also like