Recursion1 Stephen Cooper Wanda Dann Randy Pausch Barb Ericson Jan 2010 Recursion in Alice.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
-
Upload
dominick-stephens -
Category
Documents
-
view
213 -
download
0
Transcript of Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
![Page 1: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/1.jpg)
Creating a Simple Creating a Simple Game in ScratchGame in Scratch
Creating a Simple Creating a Simple Game in ScratchGame in Scratch
Barb EricsonBarb EricsonGeorgia TechGeorgia Tech
June 2008June 2008
![Page 2: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/2.jpg)
Start up Scratch• Click on Scratch.exe
![Page 3: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/3.jpg)
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: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/4.jpg)
Delete the Cat• Right click on the
cat and pick delete• Or click on the cat
to select that sprite and then click on the scissors to delete it
![Page 5: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/5.jpg)
Add the Baby• Click on the folder with a star in it
– if you hover over it, it says "Choose new sprite from file"
![Page 6: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/6.jpg)
Select the People Folder
![Page 7: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/7.jpg)
Scroll to the Baby• Click on the baby and then OK
![Page 8: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/8.jpg)
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: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/9.jpg)
Move the Baby • Select (click on the arrow and then
on the baby) and click and drag the baby to the bottom of the window
![Page 10: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/10.jpg)
Respond to Arrow Keys• Click on Control (orange) and then
drag out "when space key pressed"
![Page 11: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/11.jpg)
Respond to Right Arrow• Click on down arrow next to
space and select right arrow
• Click on Motion (blue) and drag out a "move 10 steps"
![Page 12: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/12.jpg)
Change the move amount
• Click on the 10– it will highlight in blue
• Type 5 and press enter
![Page 13: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/13.jpg)
Respond to Left Arrow• Click on Control (orange)• Drag out a "when space
key pressed"• Change "space" to "left
arrow"• Click on Motion• Drag out a "move 10
steps"• Change it to -5 (to move
left)• Try out the left and right
arrow keys– Does the baby leave the
window?
![Page 14: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/14.jpg)
Paint a Ball• Click on the paint brush and star
– It will say "Paint new sprite" if you hover over it
![Page 15: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/15.jpg)
Use the Paint Editor• Click on the Ellipse tool
![Page 16: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/16.jpg)
Select a Color
![Page 17: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/17.jpg)
Draw the Ellipse• Click and drag to create the ellipse• Then click on "OK"
![Page 18: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/18.jpg)
Move the ball to the top
• Click and drag the ball to the top of the window
![Page 19: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/19.jpg)
Make the Ball Fall• When the green flag is clicked we
want the ball to start at the top and fall down– Click on Control (orange)– Drag out a "When green flag clicked"
![Page 20: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/20.jpg)
Start the Ball• Click on Motion (blue)
• Drag out go to x # y # – this will always start the ball at the current
position
• Drag out a "point in direction 90"– and change it to 180 (down)
![Page 21: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/21.jpg)
Make the ball fall• Click on Control
(orange)– drag out a "forever"
• Click on Motion (blue)– drag out a "move 10
steps"• change it to 1 step
• Try it out!
![Page 22: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/22.jpg)
Catch the ball!• If the distance from the center of
the ball to the baby is less than the half the size of the ball then it is caught
• Let's track how many balls we have caught with a score
![Page 23: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/23.jpg)
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: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/24.jpg)
Set score to 0• Drag the forever
down• Drag out a "set
score to 0"• Notice the score
showing on the window
![Page 25: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/25.jpg)
Did we catch the ball?• From Control drag out
an if• We will check if the
distance to the baby is less than half the ball size
• Click on Number (green) and drag out a "blank < blank"
![Page 26: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/26.jpg)
Distance to baby• Click on Sensing
(light blue)• Drag out a
"distance to blank"
• Change it to sprite1
![Page 27: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/27.jpg)
Half the Size of the Ball• Click on Number
– Drag out a "blank / blank"
– From Looks drag out a size
– Type on second blank and type 2
![Page 28: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/28.jpg)
Increment the score• Click on Variables
– drag out a "change score by 1"
• Try it out!– is this what you expected?
![Page 29: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/29.jpg)
Reset the ball• Once you catch the
ball– 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 a "go to x # y #"
![Page 30: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/30.jpg)
Pick a random X value• Click on Number
– drag out a "pick random 1 to 10"
– drop on the x value
– change the 1 to -235 and change 10 to 235
– change the y value to 161
![Page 31: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/31.jpg)
Adding Losing• If the baby doesn't catch the ball it
just gets stuck at the bottom of the screen
• Let's tell the player that he or she lost
![Page 32: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/32.jpg)
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: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/33.jpg)
Hide the sprite• Click on Control
– drag out "when green flag clicked"
• Click on Looks– drag out hide
![Page 34: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/34.jpg)
Check if lost• If the ball hits the bottom of the
window – the player has lost
• Click on Control– drag out an if
![Page 35: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/35.jpg)
Check if at bottom• Click on Numbers
– Drag out a "blank < blank"
• Click on Motion– drag out a "y
position"
• Click on the last blank– type in -175
![Page 36: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/36.jpg)
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 new – name it lost• add a stop script tile
– to stop the forever loop
![Page 37: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/37.jpg)
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: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/38.jpg)
Record a Sound• Click on the ball sprite• Click on the Sounds tab• Click the Record button
– Click the red circle to start– Click the black square to
stop– Play with the right arrow
![Page 39: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/39.jpg)
Name the sound• Click in the sound name area and
rename it
![Page 40: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/40.jpg)
Play the Sound• Click on Sound
– drag out "play sound pop"
– drop after increment the score
– change pop to yum
![Page 41: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/41.jpg)
Add a Background• Click on stage• Click on the
Backgrounds tab• Click on import• Select a new
background
![Page 42: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/42.jpg)
Create Instructions• Click on the Show
Project Notes in the upper right corner
• Add the author and instructions
![Page 43: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/43.jpg)
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 44: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/44.jpg)
Other Ideas• Add a sound when you lose
– You may need to add a "stop script" to the script for the ball after you send the lost message
• Only catch the ball in the baby's mouth• Add the ability to win
– When you reach a certain score– Track the amount of time it takes as well
• Speed up the ball over time• Add more sprites to catch• Add a sprite to avoid
– killer sprite
![Page 45: Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.](https://reader036.fdocuments.us/reader036/viewer/2022070411/56649f575503460f94c7b4b2/html5/thumbnails/45.jpg)
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