Scratch Programming

Marr College
Scratch Programming
Contents
Page 1 – Lesson 1- Basic Skills
Page 2 – Lesson 2 – Basic Skills – Snowman
Page 3 – Lesson 3 – Basic Skills – Bumblebee
Page 4 – Lesson 4 – Basic Skills – Mouse & Bumblebee
Page 5 – Lesson 5 – Basic Skills – Variables
Page 6 – Lesson 6 – The Clown strikes back
Page 8 – Lesson 7 - The Maze
Page 10 – Lesson 8 – Whack a Mole
Page 13 – Lesson 9 – Paper Scissors Stone
Page 16 – Lesson 10 – Magic Eight Ball
Scratch—Basic Skills Lesson 1
By the end of this first task you will have created a sprite and made it
move around the screen
Step 1
Create a new project and add any sprite that you want
to use.
Step 2
Use the following script as a starting point
HINT: Up is Direction 0, right is 90,
down is 180 and left is –90
Extension Tasks
Try to create scripts to turn and move your sprite in all 4 directions.
If it works, try to change the colour of your sprite when it moves and
add sounds if you can
Marr College
Page 1
Scratch Programming
Scratch—Basic Skills Lesson 2
By the end of this first task you will have created a sprite and made it
move around the screen
Step 1
In our first project we made our cat say ouch, in this project you are going to create a scene where a snowman is
speaking to the sun and the sun is talking back.
Create a new scratch project.
Step 2
Add the snowman 1 sprite and the sun sprite
and place them as shown in the screenshot.
Name your snowman Snowman
Name the Sun sprite sun
Step 3
Add the following blocks to each sprite
Snowman Sprite
Sun Sprite
Step 4
Save and then run the Project (by pressing the green button) and see what it does.
If it works try to add more conversation between the sun and the snowman.
Or create a new project with some other sprites and hold your own conversation
Marr College
Page 2
Scratch Programming
Scratch—Basic Skills Lesson 3
By the end of this worksheet you will have created a scene where a
sprite will follow the mouse
Step 1
Add a bee sprite to a new project, name the sprite
Bee.
Place the sprite on the left hand side of the screen
Step 2
Add the following code to your bee sprite.
Now save and run the project to see what happens.
You will need to select mouse-pointer
by pressing the down arrow to the
right of the point towards block.
Step 3
If it works make the bee move faster or slower.
Marr College
Page 3
Scratch Programming
Scratch—Basic Skills Lesson 4
By the end of this worksheet you will have created a scene where a
sprite will follow the mouse
It is useful in games if you know when your character touches something.
We are going to use our bee example earlier and put in a vase of flowers so that we can point the bee
towards it. When it touches the flowers we are going to say “Well done”
Step 1
Using your bee project, change the background so
there is a piece of green ground.
To draw on your background click on the stage pixel,
then select Backgrounds and then Edit beside background 1.
This will show the editor
Step 2
Add the following code to your bee sprite
To select the colour click there and then click on
the grass that you have drawn.
Step 3
Save the project then run it to see if it works.
Marr College
Page 4
Scratch Programming
Scratch—Basic Skills Lesson 5
By the end of this worksheet you will have created a scene where
clicking on a randomly appearing button will gain you points
Scratch can use what is called variables to hold things like the points for a game or the speed of a car.
We are going to use one of these variables so that we can keep a track of how many times you can click
on the moving button. The game carries on till you click on the button ten times.
Step 1
Create a new project and add the sprite called button, this
is in the things category. Name it button.
Step 2
We need to add a second costume for the button
so it looks like it is being pressed down.
Select the costumes tab for your button sprite
and select Import.
Then browse to your costumes folder and select
the buttonpressed costume
Step 3
We need to make a variable called Score to keep a track
of how many times you click on the button.
Click on the variables tab then press the Make a variable
button.
Call the variable Score and make sure it has been selected “For all sprites”
Step 4
Add the following blocks to the button sprite,
this will glide the button around the screen
randomly. The pick random block can be found
in the operators tab.
Step 5
Add these blocks to the button sprite.
This will make the button look like it has been
pressed and more importantly keep score.
Marr College
Page 5
Scratch Programming
Lesson 6- The Clown Strikes Back
By the end of this worksheet you will have created a game where
clicking on a randomly moving good clown will earn you points.
Clicking on the bad clown will remove points.
Step 1
Add a clown sprite by selecting the choose a
new sprite from file button.
Step 2
Stop the clown rotating by clicking on the don't rotate button.
Step 3
Go to the Costumes tab and import the
bad clown costume. You should now
have two costumes for your clown
sprite.
Your costumes tab should look like this.
Step 4
Create a global variable called score.
Select the Make a variable button
and then call the variable Score.
Step 5
Add this block to your clown sprite
to set the score to 0.
Step 6
Add the code to point the clown in a
random direction, and move for 5
steps, bouncing if it hits the edge.
Marr College
Page 6
Scratch Programming
The Clown Strikes Back
By the end of this worksheet you will have created a game where
clicking on a randomly moving good clown will earn you points.
Clicking on the bad clown will remove points.
Step 7
Add the code to detect if it’s a good clown or
bad clown and increment or decrement
score. You can also add blocks to play a
sound.
Step 8
Add code to hide the sprite, set it to a
random x,y co-ordinate then point it in a
random direction.
It will then show the sprite again
Step 9
Right click on your clown sprite and duplicate the
sprite to add more clowns, set them as either bad
or good clowns using the costumes tab.
Then run the program and test it.
Marr College
Page 7
Scratch Programming
Lesson 7- Maze
By the end of this worksheet you will have created a game where you
have to navigate a maze. You will only be given some of the scripts
required, but hints are available.
Step 1
Create a suitable background.
Make sure that your walls are one colour and your
path is another colour. Like the example shown
here. Make sure the borders are quite thick compared to your character that you will make in Step 2
Step 2
Add a sprite that you can control to move around the maze.
It is important that you then edit the sprite and put a single
coloured dot in front of your sprite.
Step 3
You then have to edit your sprite so that there is single coloured dot in front of your character. This cannot be the same
colour as your path or your walls.
This will help collision detection
Single black coloured dot
Step 4
Add a sprite to be your goal character,
when your character touches this you win
the game.
Step 5
Select your player sprite. Add the following
code. This will place the character at a start
point.
You can get the x and y co-ordinates for
your character beside the sprite name.
Marr College
Page 8
Scratch Programming
Maze
By the end of this worksheet you will have created a game where you
have to navigate a maze. You will only be given some of the scripts
required, but hints are available.
Step 6
Create the following blocks to place the
character in an initial spot on the screen
and keep it moving until it hits a block
Extension Tasks
1) Add jewels that your character can collect, each jewel should give you a point.
2) Make the jewels disappear when they are touched.
3) Add ‘monsters’ that will roam around your maze, if they touch your character,
the monster should freeze for a second and your character should go back to
the start.
Marr College
Page 9
Scratch Programming
Lesson 8- Whack A Mole!
By the end of this worksheet you will have created a game where you
use a hammer to whack a mole when it appears from its hole! Whack
the mole to get the points!
Step 1
Add the sprite of the mole
 Call it Mole
Step 2
Select your mole sprite and go to the
costumes tab and import the sprite
called no-mole.
Your costumes should look like the image above.
Step 3
We need our mole to randomly pop out of the
hole, so we ill use the wait block and a random
time to change the costume. Add the following
scripts to your Mole sprite.
Step 4
Create a variable called Score and set it for all
sprites
Step 5
When we click on the mole we will check if the
mole is there or not, if it is we will give ourself a
point.
Now test your game to see if it works!
Marr College
Page 10
Scratch Programming
Whack A Mole! - Extension Part 1
By the end of this worksheet you will have created a game where you
use a hammer to whack a mole when it appears from its hole! Whack
the mole to get the points!
Step 6
We are now going to create a hammer that
we can hit the moles with.
 Import the sprite called hammer up— or
create your own
 Name it Hammer
Step 7
Now import a second costume for your hammer.
 Import the sprite called Hammer Down
Your costumes should look like the
image above.
Step 8
When the program starts we want the hammer to be in the up position
Add the following code to your hammer
sprite
Marr College
Page 11
Scratch Programming
Step 9
Now we want the hammer to follow wherever the mouse pointer is, we will then sense if the mouse
button has been pressed, if it has we will change the costume.
It will then check for a mole and wait a fraction of a second before changing back to the original costume.
This has to be repeated forever
Step 10
This has to be then joined on to the rest of your
hammer sprite
Step 11
Now add the following code to your mole, this
will check if it is touching the hammer, if it is and
a mole is showing then it will add a point.
Extension Tasks
Now add a third costume, a rabbit—this should randomly appear and if the user
accidentally hits the rabbit then they should lose points.
Marr College
Page 12
Scratch Programming
Lesson 9- Paper Scissors and Stone
By the end of this worksheet you will have created a game where you
can play a game of Paper, Scissors and Stone against the computer
Step 1
Edit your stage background by double clicking on
the stage. Select the backgrounds Tab and then
select edit. Add appropriate drawings to show
both players.
You can use sprites if you want to.
Step 2
Add a sprite for the player character
by choosing the paper image from
your My Documents.
Step 3
You must now add the Rock then scissors costumes to your player sprite by using the Import
button from the costumes tab.
Your costumes tab should look like this.
Repeat the last two steps for the computer sprite.
Step 4
Select your player sprite. Create variable for all sprites called
 Player Choice
 Computer Choice
Your variables should look like the
image above.
Step 5
Add the sprite called button, import a second costume called
buttonpressed.
Step 6
Add the following code to your
Player Sprite.
This will set the player choice to 1,
this is the scissors costume.
Marr College
Page 13
Scratch Programming
Paper Scissors and Stone
By the end of this worksheet you will have created a game where you
can play a game of Paper, Scissors and Stone against the computer
Step 7
Add the blocks required to change the costume
to number 2 which is Paper and 3 which is Rock.
The paper blocks have been done for you.
Step 8
Now we have to setup the main program
that will animate the button to start the
program and choose the computers
choice.
Add these scripts to your Start Button
Step 9
Now add the following code to your computer
sprite.
Marr College
Page 14
Scratch Programming
Paper Scissors and Stone
By the end of this worksheet you will have created a game where you
can play a game of Paper, Scissors and Stone against the computer
Step 10
The last part is to decide who has won the round.
Add these scripts, we will enter the win conditions into the blank if statements.
1 = Scissors, 2 = paper, 3 = Rock
Step 11
Into the Or statement you have created drag the
following scripts into the blank spaces.
Step 12
Now update the main program to decide the
round winner, then run and test your program.
This code should be in your button sprite.
Extension Tasks
1) Add code to keep a track of the score of the player and the computer, show
these above the sprite for each player.
2) Add code to the main program to play to the best of 5. After this the game
should stop.
3) Adapt your program to use a slider variable to set the game length.
Marr College
Page 15
Scratch Programming
/HVVRQMagic Eight Ball
By the end of this worksheet you will have created a game where you
can use a virtual magic eight ball
Step 1
We need to add a sprite as our character and the
magic eightball sprite.
 Add the boy sprite, name it Boy
 Add the 8ball sprite, name it 8Ball
Step 2
We need to create a variable to hold
all of the possible answers.
Create a list and call it Answers
Your list should look like the image above.
Step 3
There are to be 20 answers to any questions that
we ask our 8Ball, now you could add these individually, but we are going to import them from a
saved text file.
 Right click on your answers list box in the top
right of your stage and select import.
 Browse to the file called responses.
Step 4
We don't want the list to show all of the time
so uncheck
box to the left of the Answers
Marr the
College
icon.
Page 16
Scratch Programming
Magic Eight Ball
By the end of this worksheet you will have created a game where you
can use a virtual magic eight ball
Step 5
We need to create some variables to hold
some information.
Create variables called
 Name
 Question
 Random Answer
Your variables should look like the
image above.
Step 6
We are going to ask the players name. Add these
icons to your Boy sprite.
We will store the characters name in a variable
called answer.
Step 7
Now we need to add code to the 8ball sprite
to ask the user their name and what their
question is.
We now need to wait on the user to answer
the question and then store it in a variable.
Step 8
We will pick an answer out of our list using a random
number.
Our random number has to be between 1 and the
length of our list.
Marr College
Page 17
Scratch Programming
Magic Eight Ball
By the end of this worksheet you will have created a game where you
can use a virtual magic eight ball
Step 9
Now that we have picked a random number we
will show the answer at that position in the list
Step 10
Your when clicked event for your 8Ball sprite
should now look like this, run your program
and test it.
Extension Tasks
1) Add code to allow the user to ask questions again and again
2) Add code to ask the user if they want to continue. If they say Yes then your program
should ask another question
Marr College
Page 18
Scratch Programming
Magic Eight Ball—Extension Tasks
By the end of this worksheet you will have created a game where you
can use a virtual magic eight ball
Step 1
We are going to add the feature so that we can
ask it more than one question, we will ask the
user if they want to ask another question.
Step 2
Create a new variable called
 Again
Your variables should look like the
image above.
Step 3
 Add code to the 8ball to ask another question
after it has given its answer
Step 4
Which part of the program has to be repeated to
allow the user to ask another question,
HINT: Which block from the control section will
allow you to do this? And how will you know if
they want to or not?
Marr College
Page 19
Scratch Programming