Computer Game Design & Computational Thinking Scratch

Metcalfe County High School

Creating Games With Scratch

Introduction to Scratch

Scratch is a program which lets you control how objects called sprites move around and interact with each other on a background called a stage.

1.  Open Scratch by going to the Start Menu..All Programs.... then Select ….Scratch or look for the icon on the desktop.

2.  Create a new folder in your student folder called Scratch.

When saving in scratch it is important that you know your network drive letter. Follow the instructions below to find out what your letter is. Write the letter down or at least remember what it is for later use.

3.  Go to My Computer

4.  In the ‘Network Location’ area find your student folder

5.  Note the letter at the end of the drive in your progress sheet. E.g.

You will use this letter later to save your work.

The scratch program looks like the screen shot below. There are three main parts of the screen: the Block Screen, the Script Screen, and the Stage.

Exercise 1: Taking The Cat For A Walk

Your project will be made up of sprites, in the example below; the smiling cat is a sprite. Your sprite can be anything you want (elephant, football, tree, smiling cat).

We are going to change the name of the sprite to cat, to make it easier to use.

1.  Rename the cat sprite from Sprite1 to cat, by changing it here. /

You can now give instructions to a sprite, telling it to move, change colour or react to other sprites. To do this we must build blocks of instructions called scripts. Scratch will run these scripts from the top to the bottom.

Before we can make a script we must first make sure the scripts tab is selected.

2.  Click on the Scripts tab. /

Scripts are made by clicking and dragging blocks from the block window into the script window. The blocks will click together to make the script. To start with we will need two blocks.

3.  Click and drag each block from the block screen to the scripts screen.

These blocks need to be connected to each other to make a script.

4.  Click and drag the blue block up till it is just below the yellow block. When you see a white line between the blocks you can let go of the mouse button.

You can drag blocks directly from the block screen to a script exactly the same way. Any new blocks will be added where the white line is. You can also drag blocks away from a script to remove them.

Your script is now ready to run. Click on the icon to run your script. The cat will move a short distance.

Now let’s animate the cat: To change the look of your sprite, you can give it costumes, this changes the way your sprite looks.

5.  Select the ‘Costumes’ tab.
You can see that there are two different cat pictures. By changing between these pictures we can animate the cat.
Remember to click on the script once you are finished. /

We can use the Looks block to make the sprite switch between the two different costumes.

6.  Add the Looks block Next Costume to your script.

Your script should now look like this:

Click on the icon to run your script. The cat will move a short distance and then change to a slightly different picture. If we want to animate the cat properly we will have to make it do these two blocks many times.

7.  Add the control blocks repeat and wait to your script.

You will have to change the number in the wait block. Click on the number inside the block to delete it and type a new one in

Make sure your script looks exactly the same. Remember that you can pull blocks apart by dragging them away if you are having problems.

Now click on the icon to run your script. The cat should now walk across the stage. If your cat moves too far to the right, you can click and drag it back into the middle of the stage.

8.  Go to the File Menu and select Save As

9.  Click on the computer button and then choose your drive letter.

This will take you into your MyDocuments area.

10. Find your Scratch folder and save the file as Exercise 1.

WARNING – you must continue to save like this or you will not be able to find your tasks and will have to start again!

Exercise 2 – Chatty Cat

When you put together a script, you have to pay careful attention to the order of the blocks. In this exercise we are going to work out how to make the cat say hello before it walks across the screen.

You will need the following blocks (remember to change the numbers inside blocks by clicking and typing):

Control Blocks: /
Motion Blocks: /
Looks Blocks /

One of the three scripts below will make the cat say hello and then walk forward. Which one do you think will work correctly?

1.  Choose the script from the three on the right that you think will make the cat say hello then walk

Enter that script only

Now click on the icon to run your script. Did you pick the right one?

2.  Change your script until the cat says hello and then walks forward.

3.  Save the file as Exercise 2

Exercise 3 – Controlling The Cat

Games are interactive. They let the player control the main character. If we want to make a game, we’re going to need to be able to use the input from the user to control a sprite. This exercise does that.

You will need the following blocks.

Control Blocks: /
Motion Blocks: /
Looks Blocks /
Sensing blocks /
You can change what this block senses by clicking on the drop down arrow and selecting a different key

1.  Create the script shown on the right

Remember to change the values inside the change x, wait and key pressed blocks

Now click on the icon to run your script. Press and hold the right cursor key. The cat will move to the right as long as the key is held. However, if we try the other cursor keys, the cat will not move. We need to tell the script what to do if other keys are pressed.

2.  Add more blocks to your script so it looks like the one on the right.

Now click on the icon to run your script. The cat can now move left and right. We can make it move up and down by adding two more groups of blocks – one for the up arrow key and one for the down arrow key.

3.  Add the blocks on the right into your script. They should go directly below the other if blocks.

These blocks use the change y block instead of change x because we want the cat to go up and down.

Click on the icon to run your script. Check that your cat is moving in all four directions correctly.

4.  Save the file as Exercise 3

Exercise 4 – Why Limit Ourselves To Cats?

Games would be pretty dull if every player character ever was a cat. Scratch comes with a number of different sprites we can use and animate.

1.  Start a new Scratch project and delete the cat sprite by right clicking on where it appears below the stage

2.  Select delete from the menu

3.  Add a new sprite by clicking on the choose new sprite from file button

4.  Choose an animal from the animals folder.

You need to make sure there are at least two pictures of the animal. The parrot is a good example

Click on OK to add your new sprite

5.  Remember the costumes tab? We need to select it now

6.  Use the import button to add the other picture of the animal as a second costume

We’ve now imported an entirely different animal to animate. We can add scripts to this sprite in exactly the same way as we did with the cat.

7.  Add a script to your new sprite that will allow you to move it using the cursor keys

If you can’t remember how to do this, look at exercise 3

8.  Add a background by clicking on the stage icon

Then click on background tab and select import. Choose an appropriate background for your sprite

Click on the icon to run your script. Check that your new sprite is moving in all four directions correctly. Get a print out of your script to give to your teacher.

9.  Make sure the Scratch window is visible and hit the print screen key.

10. Open Microsoft Office Word and paste your screenshot into a blank document. Make sure your name is in the footer and print it out.

11. Save your Scratch file as Exercise 4.

Exercise 5 – Why Limit Ourselves to Sprites From Files?

Scratch has an inbuilt painting tool that lets you create your own sprites. With this we can make any sprite we want for our games.

1.  Ask your teacher for some paper. Draw what you want your new sprite to look like.

2.  This time we will use the paint new sprite button.

3.  Experiment with the tools in the paint editor to draw a new sprite.

When you put the mouse over a tool, a pop up tip will tell you what it does.

4.  We can use the Copy button in the Costumes tab to copy the sprite. Use the Edit button to make changes. The more costumes you have the smoother your animation is.

5.  Now add a script to your new sprite to make it move when the player presses keys. Try using a different set of keys than the cursor keys.

6.  Run the script to check that it works.

7.  Save the file as Exercise 5.

End of Part 1 - Ask your teacher before you go any further

Exercise 6 – Going In Other Directions

At the moment, our sprites can go up and down, left and right. We can make sprites move in any direction. Randomly moving sprites are great to use as enemies in a game. We're going to make our first enemy sprite.

You will need the following blocks:

Control Blocks: /
Motion Blocks: /
Looks Blocks /
Operators Blocks /

1.  Start a new Scratch project and delete the cat sprite.

Add the shark sprite shown on the right using choose new sprite from file. Add an extra costume for the sprite.

2.  Make sure the only face left-right button is selected. This will stop the shark swiming upside down.

3.  Add the two scripts on the right to the shark.

4.  Run your scripts to check that they work.

5.  Save the file as Exercise 6.

Exercise 7 – Falling Off The Edge

An alternative way to move the shark is to make it wrap around the edges. When it gets to far on one side, it re-enters the stage from the opposite side.

You will need the following blocks:

Control Blocks: /
Motion Blocks: /
Operators Blocks /

1.  Open your Exercise 6 file. Save it again as Exercise 7. This will stop you accidentally overwriting the previous exercise.

2.  Change the first script on the shark as shown.


3.  Run your scripts to make sure that they work. You will have to check that the shark wraps correctly from all 4 edges of the stage.

Tip: You can alter the direction of the shark while the program is running by clicking and dragging this blue line.

4.  Save the file as Exercise 7.

End of Part 2 - Ask your teacher before you go any further

Exercise 8 – Shark and Swimmer

Most games include more than one character. The shark makes a good enemy, but we will want a sprite for the player to control. We're going to add a second sprite to make a simple game: The object will be for the swimmer to avoid the shark.

As well as the blocks you have already learned about, you will need the following new blocks:

Control Blocks: /
Sensing Blocks: /

1.  Open your Exercise 6 file or, if you completed it, Exercise 7. Save it again as Exercise 8. This will stop you accidentally overwriting the previous exercise.

2.  Add the diver sprite shown on the right using choose new sprite from file.

3.  Make sure the new sprite is highlighted below the stage by clicking on it.

With more than one sprite you have to be careful the correct sprite is selected when adding a script. If you accidently add the script to the wrong sprite, you can drag and drop it onto the correct sprite below the stage.