Simplewitchgame 6 4 2009
Simplewitchgame 6 4 2009
in Scratch
Barb Ericson
Georgia Tech
Goals
Learn about
event handling
simple sequential execution
loops
variables
conditionals
parallel execution
message passing
Game Description
We will make a game
where the player
controls a witch using
the arrow keys to
catch a falling
pumpkin. If the witch
misses the pumpkin
the game is over.
Add a Background
Click on the Stage in
the area that shows
the sprites and stage
Click on the
Backgrounds tab
Click on the import
button
Pick a background
Like night-city in
outdoors
Event Handling
We want to control the witch using the
arrow keys
-180
Paint a Pumpkin
Click on the paint brush and star
It will say "Paint new sprite" if you
hover over it
Drawing area
Click ok when
done
Sequential Execution
One block is executed
after the other
In order from top to
bottom
When the green flag
is clicked
the pumpkin will go to
the specified x and y
location
Loops
We want the pumpkin to continue to
move down unless the witch catches it
How do we make this happen?
We could use lots of blocks one after the
other
But, that would be slow and repetitive
Try it out!
Variables
If we are going to keep track of the
score
Set score to 0
Highlight the pumpkin
sprite
Drag the forever down
Drag out "set score to
0
Drag the forever back
up
Notice the score
showing on the window
Conditionals
We want to increase the score if the
witch caught the pumpkin
So this action will only occur only if
some condition is true
This is called a conditional or an if
If this is true
increment the score
From Variables
Computers do
what you tell
them to do
Increment the
score
And move the
pumpkin to some
random spot at the
top of the window
Adding Losing
If the witch doesn't catch the
pumpkin it just gets stuck at the
bottom of the screen
Let's tell the player that he or she
lost
Click on Control
Click on Looks
Check if Lost
If the y position gets
near the bottom (near
-180)
Drag out an if
from Control
Add a y position
From Motion
Broadcast a message
Sprites communicate by passing messages
One sprite broadcasts the message
Other sprites can listen for it and react to it
when they receive it
Click on Control
drag out "broadcast blank"
click on the drop down arrow
next to new name it lost
Add stop script
to stop
loop
stopthe
theforever
forever
loop
Receive Lost
Click on the text sprite
Click on Control
Click on Looks
Click on Control
Parallel Execution
We have several
things happening at
the same time
when the green
flag is clicked
This is called
parallel execution
Create Instructions
Click on the Show
Project Notes in
the upper right
corner
Add the author and
instructions
Press OK
Other Ideas
Add a sound when you lose
Add the ability to win
Concept Summary
Variables
Forever loops
Conditionals ifs
like clicking the green flag and pressing the left or right arrow keys