Programming Games With Scratch: Teacher's Guide
Programming Games With Scratch: Teacher's Guide
Teacher's Guide
Contents
About..................................................................................................................................................... 1
Suggested Activity ................................................................................................................................ 1
Additional Details ................................................................................................................................. 2
Handout Overview ................................................................................................................................ 3
Solutions................................................................................................................................................ 4
Driving Game .................................................................................................................................... 5
Super Fashion Dress-Up ................................................................................................................... 7
Clay Shooting .................................................................................................................................... 9
Room Escape....................................................................................................................................11
Cat and Mouse ................................................................................................................................ 12
Moon Landing ................................................................................................................................. 14
About
“Programming Games in Scratch” is a series of handouts that can be used to teach programming and
computational thinking. The handouts guide students through the logic and algorithms underlying
computer games. They cover many different types of games and different experience levels, so it is
easy to customize your lessons to the interests and abilities of different students. All the necessary
instructions are included on the handouts themselves, so students can often follow them without
guidance from a teacher. As such, teachers do not necessarily need a programming background to use
the handouts in classrooms; nevertheless, a programming background is useful for teachers to help
students contextualize the lessons, to help students when they encounter difficulties, and to direct
students to supplementary material for further learning.
The handouts make use of the Scratch programming language from MIT. Scratch is a free
programming language that can be used from most PCs without the need to install any software. It is
designed to expose programming to students in a friendly environment that encourages creativity and
independent learning.
Suggested Activity
The handouts contain all the necessary instructions to use them. As such, students can follow the
handouts themselves individually or in small groups. Younger students may need adult guidance to read
through the handouts and to stay focused on the tasks.
1
Unless students have experience using the Scratch language, they should all start with the introductory
handout “Making a Basic Game in Scratch.” They simply visit the website listed on the first page of the
handout and then following the instructions on the handout. The introductory handout provides an
overview of the basic functionality and features of the Scratch language by guiding students through
the making of a simple game. The handout is written in a “walkthrough”-style: all steps are described
in exact detail with no occasions for deviating from the suggested solution.
The other handouts are more open-ended and require more reflection by students to complete.
Instructions are described in general terms, requiring students to figure out the exact steps needed to
solve the problems themselves. Each handout is self-contained, so students can choose which handouts
to complete based on their interests and abilities. The handouts also often contain optional sections of
varied difficulties, which students can optionally complete based on their own interests and abilities.
Additional Details
Below is a list of the handouts:
2
foster an independent interest in programming. Encourage them to change the artwork, add their own
sounds, and to experiment with their own ideas. Have them add more enemies, write a story, or adjust
the speeds of things to change the difficulty level.
Handout Overview
Overall difficulty
Optional improvements to
the game are in grey
3
Solutions
STOP
Although sample solutions are provided here, please avoid using them.
There are no “correct” or “perfect” solutions to the handouts. There are many ways to program the
same game. It is also possible (and even encouraged) for students to write their own variants of the
games that play differently and use completely different techniques.
The most important part of learning to program is to develop problem solving skills. Learners often
give up and want to see the “answers” too early. In programming, the “answers” are actually
unimportant. The important part of programming is struggling with problems and coming up with
solutions. Some programming problems have no solutions. Some require a lot of reflection and
ingenuity to find a solution. Some problems exceed a programmer’s skill level and require
programmers change their programs to behave in a way that’s easier to program.
The solutions are mainly provided to clarify some unclear descriptions in the handouts and to help
instructors provide hints to guide students.
4
2. No Shortcuts: When the up arrow key is
Driving Game pressed, the game should check whether the car is
1. Driving Part 1: Add a block for moving forward touching green (i.e. the grass) and move forward a
into the forever loop smaller amount if that is the case.
5
Try It: Speed and Brakes Part 1: It’s the same code Try It: Speed and Brakes Part 2: Then, we can start
as in step 2 except that a new speed variable is playing with adjusting the speed. The speed will
substituted in for the number of steps to move initially be set to 0. When the up arrow is pressed,
forward. That speed variable is initially set to 3. the car should go faster. That means the speed
should be increased. Do something similar when
the down arrow is pressed for slowing the car
down. Lastly, the car should always move
forward by the speed regardless of what keys are
being pressed.
6
Super Fashion Dress-Up 5. More than Just Pants: Although it's possible to
use a “when space key pressed” event block to
3. Moving the Pants: You should make the check when a key is pressed, it is recommended
“Clothes” sprite keep moving to the mouse that you use an “if ___ then” block instead.
pointer in a forever loop.
The clones of a sprite will respond to events just
like the original sprite. When a “when space key
pressed” event block is used, all the clothes added
to the doll will change when you press space
because they are clones. You don’t want that. By
using “if ___ then” blocks in a forever loop that is
started when the green flag is clicked, you avoid
this problem.
4. Adding the Pants to the Doll: In the “Clothes” The code for the “if ___ then” block is similar to
sprite, you should keep checking if the mouse the code from the previous section, except that it
button is pressed down, and create a clone of the will change the costume instead of creating a
sprite if the mouse button is down. You can create clone.
a new forever loop for this, or reuse the loop used
in the previous step. Since clones will be
continually created while the mouse button is held
down, you should wait a small amount of time
(0.2 seconds works well) after creating the clone
to prevent too many clones from being created.
7
6. Body Styles: In the “Body” sprite, you should 8. Hair Styles: The “switch costume to” block can
add code that is almost identical to the code you be used to switch to a costume # and not just a
wrote in the previous section. It's also possible to costume name. Since each hair style has five
use a “when ___ key pressed” event block, and it colours, you can change the hair style by skipping
is safe to do so since you are not making any over five costumes.
clones of the “Body” sprite, just the “Clothes”
sprite.
8
Clay Shooting 4. Play Again: After the clay moves, it should
check if it’s touching the edge and then reset its
1. Move the Crosshair: On the crosshair sprite, position and costume if it is.
have it continuously move itself to where the
mouse pointer is.
9
6. No Cheating: Hide the clay when it touches the
edge. Wait a random amount. Show the sprite
again after the wait.
10
Room Escape Try It: Combination Lock: On every single number,
it should advance to the next number when it is
1-4. Books, Painting, Clock, Door: The code should clicked.
be put on the book, painting, clock, and door
respectively. The code is similar for all three.
When the sprite is clicked, they should ask for the
code, and then hide themselves if the right answer
is given.
Try It: Checking the Combination Part 2: On the books, painting, clock, and door, there needs to be code
that is run whenever one of the numbers on the combinations are changed. It should then check if the
code is correct. Since the costume # is the same as the number being shown, it’s possible to just
compare the costume #s to see if they match the desired code.
11
Cat and Mouse 4. Caught!: The code below is put on the cat, but
similar code can be put on the mouse instead. In
1. The Mouse: Put this code on the mouse. It this case, the code is put in a new, separate
should only “point towards” the mouse-pointer forever loop, but it’s also possible to put the code
and then move forward. in forever loop that you already have.
12
6. The Cat and Walls Part 1: The code for moving Try It: Less Jumpy: If the mouse is too close to the
the cat is similar to that of the mouse. mouse pointer, it will “overshoot” the mouse-
pointer when it moves towards it. To avoid this
problem, don’t move if the mouse is already close
to the mouse pointer.
13
Moon Landing 2. Crashing: Add some code to the “forever” loop
that checks if the ground is hit or not.
1. Basic Movement: Just copy the code for moving
left and right in order to move up and down.
14
3. Space Movement: Instead of having the left and 4. Up and Down: Do a similar thing with the up
right arrow keys change the x position directly, and down arrow keys.
these keys will change the x speed. The x position
will be continuously changed by the x speed
regardless of whether the arrow keys are pressed
or not.
15
5. Moon Gravity: Gravity is simulated with just an 6. Landing: Since the previous code stack is
extra block that changes the y speed every turn. getting a little long, here the code for landing is
put in a separate stack, but it can also be merged
into the existing forever loop.
16