the easiest is to simply stop all the scripts.
Look in the Controls panel for the appropriate button.
Just a Little More . . .
Let’s Add the Score!
Now we’re getting close to creating a
game. However, it would be nice to know
how many UFOs we touched during
the game. That’s pretty easy to do, but
we need some way to count how many
touches have happened. This introduces
a wonderful new concept called a variable. A variable is a special place in memory that holds some kind of value.
Look at the Variables tab and you’ll see
a simple set of controls, but there’s a lot
more there than meets the eye. Click on
the Make a Variable button, and a little
dialog pops up. We want to call this new
variable Score, and it will be available to
all sprites. When you’re finished creating
the variable, a bunch of new command
buttons appear in the Variables tab.
Use the check box next to the Score
button to determine if the score is displayed on the screen.
You can now add code to your program
to reset the score to 0 when the game begins and change the score by 1 (or a thousand—video games practically invented
grade inflation) every time you hit a UFO.
Your final game ought to look like Figure
6. You can play it here: www.aharrisbooks
But Wait . . . There’s More!
You have now learned how to create a
game. But I’ve walked you through my
game. It’s time for you to make your
own. You should have all the basic fea-
tures you need. Here are a few ways to
make it your own:
fects, and change the theme.
I’ll Talk to You Now
If you’re already a computer program-
mer, you probably can see what’s going
on here. Scratch is a very clever envi-
ronment that helps us teach all the main
ideas of programming. With the exercis-
es outlined in this article, I’ve introduced
• Event-driven programming (through
messages and sensing)
• Simple functions (through-message
an instance of a sprite class)
The examples I’ve shown are still quite
simple, but Scratch actually supports
quite sophisticated programming para-
digms. You might want to experiment
with some of these things:
add a basic physics model.
upward thrust on a key press.
monsters, and interactions.
Really, we can do all of these things.
Scratch’s best feature is that it allows us
to introduce extremely sophisticated
ideas in math, science, and computer
programming in a way that’s fun for
kids and adults to learn together. Build
some great games, and let me know
what you’ve learned! Send me your best
games and I’ll post them on my website
for others to enjoy!
Andy Harris is a homeschool dad,
father of four great kids, and husband
to the greatest homeschool teacher ever.
He has taught all ages of students, from
kindergarten to university level. Andy is
the author of a number of well-known
books, including HTML/xHTML/CSS:
All in One for Dummies, Game Programming—The L Line, PHP6/
MySQL Programming for the Absolute
Beginner, and Beginning Flash Game
Programming for Dummies. For
more information about his books, to
see where he is speaking next, or to just
say hi, please stop by his website: www
NOEO SCIENCE Teach science...painlessly.