You may have seen talent shows
that allow people to vote on a winner.
This screen cast will show you how users
can vote for a winner in your talent show
by clicking on a button sprite.
But you can use any button sprite you want.
When the user clicks on a button
it will instruct the computer to cast a vote for a sprite.
To make that happen, use the when this sprite
is clicked event block.
Now, the program needs to keep track of how many votes
each sprite receives.
In computer science, an element that keeps track of things
such as a score or number of votes is called a variable.
To make a variable in Scratch, choose variable.
Now, choose make a variable.
You need to name your variable using a name
that describes it.
This makes it easier for other people
to understand your code if you work together on a program.
In this example, the variable keeps track
of how many votes the dog gets so it's called dog votes.
Choose a name for your variable that makes sense
for your program.
Every time this sprite is clicked, the sprite vote count
goes up by one.
To make that happen put the change my block
under the when this sprite is clicked block.
In this case, the block is set to dog votes,
but George will be set to the variable that you made.
To see what the variable is holding,
make sure the check mark next to is checked.
Then, the variable and the number it contains
will show up in your program.
Test your code.
When you click on the check mark, the sprite vote
should go up by one.
Do the same for the other sprites in your talent show.
Now it's your turn.
Add sprites that work as buttons so that the user
can vote for their favorite talent show participant
and create a variable of votes for each sprite.
Learn how to earn the "Bust a Move" badge.
Learn how to earn the "Energy Burst" badge.
Learn how to earn the "Multiple Musicians" badge.
Learn how to earn the "Clone Crazy" badge.
Modify your project so you can vote for a talent show contestant.
Make the winning performer celebrate their victory!
Sign in to track your progress and earn badges