create a halloween computer game in scratch stephanie smullen and dawn ellis barb ericson october...

43
Create a Halloween Create a Halloween Computer Game Computer Game in Scratch in Scratch Stephanie Smullen and Dawn Ellis Stephanie Smullen and Dawn Ellis Barb Ericson Barb Ericson October 2008 October 2008

Upload: howard-lamb

Post on 18-Jan-2016

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Create a Halloween Create a Halloween Computer Game Computer Game

in Scratchin Scratch

Create a Halloween Create a Halloween Computer Game Computer Game

in Scratchin ScratchStephanie Smullen and Dawn EllisStephanie Smullen and Dawn Ellis

Barb EricsonBarb Ericson

October 2008October 2008

Page 2: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Start up Scratch• Click on the Scratch icon

Page 3: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

The Scratch Stage• The Scratch stage is 480 pixels wide

and 360 pixels high.

-240 240

180

-180

0,0at the center of the stage

Page 4: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Delete the Cat• Click on the

scissors and your cursor turns to scissors and then click on the cat to delete it

Page 5: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Add the Witch• Click on the button with the

picture of folder with a star in it– if you hover over it, it says "Choose

new sprite from file"

Page 6: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Select the Fantasy Folder

Page 7: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Scroll to the Witch• Click on the witch and then OK

Page 8: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Resize Your Sprite!• You can make your sprite larger or

smaller by using the “grow sprite” or “shrink sprite” icons.

• You click on one of these icons, then click on your sprite until it is the size you’d like. shrink

grow

Page 9: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Move the Sprite • Select (click on the arrow and then

on the sprite) and click and drag the sprite to the bottom of the window

Page 10: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Respond to Arrow Keys• Click on Control (orange) and then

drag out "when space key pressed"

Page 11: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Respond to Right Arrow• Click on down arrow next to

space and select right arrow

• Click on Motion (blue) and drag out "move 10 steps"

Page 12: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Change the move amount

• Click on the 10– it will highlight in blue

• Type 5 and press enter

Page 13: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Respond to Left Arrow• Click on Control (orange)• Drag out "when space key

pressed"• Change "space" to "left

arrow"• Click on Motion• Drag out "move 10 steps"• Change it to -5 (to move

left)• Click on the stage and try

out the left and right arrow keys– Does the sprite leave the

window?

Page 14: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Paint a Pumpkin• Click on the paint brush and star

– It will say "Paint new sprite" if you hover over it

Page 15: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Use the Paint Editor• Click on the Ellipse tool

Page 16: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Select a Color

Page 17: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Draw the Ellipse• Click and drag to create the ellipse• Use the paint brush to add eyes and

a mouth to make the pumpkin

• Then click on "OK"

Page 18: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Size the pumpkin as desired and move it to

the top• Click and drag the pumpkin to the

top of the window

Page 19: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Make the Pumpkin Fall• When the green flag is clicked we

want the pumpkin to start at the top and fall down– Click on Control (orange)– Drag out "When green flag clicked"

Page 20: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Start the Pumpkin• Click on Motion (blue)

• Drag out “go to x # y # “– this will always start the pumpkin at the

current position

• Drag out "point in direction 90"– and change it to 180 (down)

Page 21: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Make the pumpkin fall• Click on Control

(orange)– drag out "forever"

• Click on Motion (blue)– drag out "move 10

steps"• change it to 1 step

• Try it out!

Page 22: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Catch the pumpkin!

• If the distance from the center of the pumpkin to the sprite is less than the half the size of the pumpkin then it is caught

• Let's track how many pumpkins we have caught with a score

Page 23: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Track the score• When we start the

game set the score to 0

• Click on Variables (red)

• Click on Make a Variable

• Name it score

Page 24: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

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

Page 25: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Did we catch the pumpkin?

• From Control drag out “if”

• We will check if the distance to the sprite is less than half the pumpkin size

• Click on Number (green) and drag out "blank < blank"

Page 26: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Distance to sprite• Click on Sensing

(light blue)• Drag out "distance

to blank"• Change it to

Sprite1 (or the name of your sprite)

Page 27: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Half the Size of the pumpkin

• Click on Number – Drag out "blank /

blank"– From Looks drag

out “size”– Type on the second

blank and type 2

Page 28: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Increment the score• Click on Variables

– drag out “change score by 1”– Put it inside the “if” block

• Try it out!– is this what you expected?

Page 29: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Reset the pumpkin• Once you catch the

pumpkin– move it back to the top

of the window– this time to a random x

value• between the left edge

and right edge

– Click on Motion and drag out “go to x # y #"

Page 30: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Pick a random X value• Click on Number

– drag out "pick random 1 to 10"

– drop on the x value after “go to x:”

– change the 1 to -235 and change 10 to 235

– change the y value to match the y in the first “go to x # y #”

Page 31: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Adding Losing• If the sprite 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

Page 32: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Add text sprite• Click on the Paint new sprite

button– Click on the T for text– Move the square to where you want

the text– Type You Lost!

Page 33: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Hide the sprite• Click on Control

– drag out "when green flag clicked"

• Click on Looks– drag out “hide”

Page 34: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Check if lost• If the pumpkin hits the bottom of

the window – the player has lost

• Click on Control– drag out “if”

Page 35: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Check if at bottom• Click on Numbers

– Drag out "blank < blank"

• Click on Motion– drag out "y position"

• Click on the last blank in the last “if” – type in -175

Page 36: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

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 the forever loop

Page 37: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Receive Lost• Click on the text sprite• Click on Control

– drag out "when I receive blank"

– click on the down arrow and select lost

• Click on Looks– drag out “show”

• Click on Control– drag out “stop all”

• to stop all scripts

Page 38: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Add a Background• Click on stage• Click on the

Backgrounds tab• Click on import• Select a new

background

Page 39: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Create Instructions• Click on the Show

Project Notes in the upper right corner

• Add the author and instructions

• Press OK

Page 40: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Test your game• Click the green flag• If you want, adjust the speed of the

pumpkin• Modify the sprites using the

“Costume” tab• Save your game with the “Save”

button

Page 41: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Share your game• You can share your projects at the

scratch web site– http://scratch.mit.edu

• Click on the Share! button• You can also download other

projects and see how they were created

Page 42: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Other Ideas• Add a sound when you lose

– You may need to add a "stop script" to the script for the pumpkin after you send the lost message

• Add the ability to win– When you reach a certain score– Track the amount of time it takes as well

• Speed up the pumpkin over time• Add more sprites to catch• Add a sprite to avoid (like a ghost)

– killer sprite

Page 43: Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008

Concept Summary• Variables

– can hold values and can change value• Forever loops

– repeat all the commands inside of them one at a time until the script is stopped

• Conditionals – ifs– only execute the body of the if when the condition is true

• Sprites can pass messages– and receive them

• Sprites can react to events– like clicking the green flag and pressing the left or right

arrow keys • Sprites can have several scripts, costumes, and sounds