Costumes and variables - name/letters

Goals
 Understanding Costumes, Ordering, Naming
 Switching Costumes with Switch and Next
 Using Variables to control state
 Changing costumes in a loop to animate a sprite
 Show and Hide
 Layering
Objectives
 Students are introduced to the topic and given
examples of costumes, animation through loops,
and showing/hiding sprites based on conditions
 Students are introduced to variables to store and
retrieve information
 Students are given real problems to code and solve
 Results are demonstrated through demos of
running code and displayed results
Pre Requisites
 Repeat loops
 Basic Understanding of Scratch, Sprites, IF blocks
Materials
 Slides with examples (or present on whiteboard)
 PCs with development environments installed
Lesson Description
 Students use variables to track sprite state, and
animate sprites using costumes
 Students practice and extend examples to their own
wishes, and create costume animations
 Students present their solutions, typically F2F with
the instructor(s) at their desk
 Students analyze their and others’ solutions for
bugs
Lesson Procedure
 Review last lessons: Repeat loops, IF blocks
 Intro/examples of multiple costumes to show animation
within a sprite
 Using Next Costume to cycle through costumes
 Setting a costume by name
 Using variables to control speed of animation, applied
color and graphics effects
 Give exercises for in class practice (create their name with
multiple sprites for each letter), and animate the sprites
both through costumes and with movement (wiggle in
place, slide across the screen, etc.)
 Walk the room answering questions, looking over the
shoulder, asking questions, etc.
Closure/Conclusion
 Discussion
 How can you use costumes for your Galaga enemy ships or Defender ship?
 How can you use variables in your Galaga project?
 Track/show score
 Enemy lives
 Defender hits before death
 Power ups
 Summary
 Costumes are an easy way to make better looking programs
 Variables are powerful for storing information for later use
 Decisions/IF statements based on variables (bonus lives after score reaches a
certain point?)
 Storing information for later use
 Tracking state
 Ask questions on what is confusing or needs more time/practice
Costumes and Variables
Lesson Plan 6
Example Demo
 Today we will learn about variables and costumes,
using these concepts and ones we have already
learned we will create an animated billboard with
our names (or whatever appropriate word or
collection of sprites that you wish).
 Demo – Name animation
Costume
 What is a costume?
 Costumes are an attribute, characteristic, or property
of a sprite that helps change the look of the sprite.
 What can we use costumes for?
 Change the action of a sprite
 Turn a sprite into something completely new
 Change the background
Costume
 What do these costume blocks
do?
 Switch the costume to #2
 Switch the costume to the next
one
 Variable costume number
Variable
 What is a variable?
 Stores a value that can be
reused in code.
 Pros: if you want to change
a number, you will only have
to change it in one place.
 Example how to create a
variable and use it.
Example Demo
 Demo of variable use (ballerina and animated name)
Daily project
 By the next class: create an animated billboard.
 Worth 10 points total. Save your project:
 File format: LP6-YourLastName_YourFirstName.sb
Grade Breakdown – Must Include
Points
Sprite initial positions are set in code
1
Contains at least 4 sprites
2
Contains at least 3 costumes per sprite
2
Contains 1-2 variables to control the animation
2
Sprites animate through the costumes
2
Sprites move and/or change effects
1
 Extra ideas if you want more challenges:
 Use mouse or keyboard to trigger animation
 Have one letter follow the mouse, and each letter follow the one in front of it
 Use ghost effects to create fade-in movie banners
Extra activity
0 Use a variable to keep track of the score in a mini-
game you create.
0 Add and remove from the variable when
appropriate
0 Show the score during the game