Creating a Simple Game in Scratch

Download Report

Transcript Creating a Simple Game in Scratch

Making a Sprite Dance
Barb Ericson
Georgia Tech
June 2011
Goals
• Learn about
– Deleting a sprite
– Adding a sprite with several costumes
– Programming the sprite – creating scripts
• The typical way to start a script executing
• Using a forever block to repeat execution of a set of
blocks
• How to change the costume in a script
• How to make build in an amount of time to wait
before executing the next block
Project Description
• We will make a sprite with more than one
costume look like it is dancing by repeatedly
changing costumes
Big Picture
• Delete cat sprite
• Add a sprite from
the people folder
– Add multiple costumes
for the sprite
• Program the sprite to
look like it is dancing
– Start dancing when the
green flag is clicked
– Forever loop (repeat)
• Change the costume to
the next costume
• Wait for a short amount
of time
• Then try out some
additional things like
adding sound or
movement
Delete cat sprite
• To delete the cat
– Click the scissors
– Click the cat
• Or right click on
the cat and select
delete
Add a Sprite
• Add a sprite from
the "People" folder
– Click on the star
with a folder under
the stage view
– Select the People
folder
Add a Sprite (continued)
• Scroll down to
pictures of
Cassy and
select one of
the costumes
• Then click
"OK"
Add more costumes
• Click on the
"Costumes" tab in
the center area
• Click on "Import"
• Select another
costume for the
same sprite
– Then add more
Program the sprite
• Create a script for
the sprite
– Click on "Scripts" in
center area
– Click on "Control on
left"
– Drag out a "when
green flag clicked"
Program the sprite -cont
• Drag out a forever
block
– From the Control
category
– And connect it
under the "when
green flag clicked"
• You will see a white
line where it will
connect
Program the sprite - cont
• Click on the Looks
category – Purple
– And drag out a
"next costume"
block
– Put it inside the
"forever" block
Program the sprite
• Click on the
"Control" category
– Drag out a "wait 1
secs" block and put
it after the "next
costume" block
– Inside the
"forever" loop
Program the sprite
• Change the wait
time to 0.25
seconds
– Click on the 1 and it
will highlight
– Type in 0.25
– Hit return (enter)
Try it out
• Click the green
flag to start the
script
– At the top right
corner
• Click the red stop
sign to stop
Challenges
• Play a drum when she changes costume
– See the "Sound" category
• Move her right and left as she dances
– See the "Motion" category
Concept Summary
• Sprites
– Can be added from a file
– Can have multiple costumes
– Can be programmed with scripts
• You can start a script
– By clicking the green flag
• You can repeat a block of code
– Using a forever loop
– Or pause execution using wait