-
Introduction
-
Introducing Scratch
- Scratch Ideas
-
Activities Overview
- Scratch Activities Project
-
Algorithms and Programs
-
Write an Algorithm
-
- Sequences
- Loops
- Data: Variables
- User Input
- Conditionals
- Conclusion
Adding a Step Counter to Our Program
Adding a Step Counter to Our Program
Let's imagine that the Cat wants to know how many movements it makes when it is dancing.
This would work similarly to a pedometer that keeps track of how many steps you take each day.
We will create a variable called number of movements that will keep track of how many movements the cat makes.
To create the variable, follow these steps:
- Go to the Data blocks section of the Scripts tab
- Click the Make a Variable button
- Name the variable number of movements
- Tick the For this sprite only checkbox
- Click the OK button
We want to add 1 to this variable every time the Cat moves, using the change variable block Our Dancing Cat program is shown below.
How many change variable blocks should be added below and where do you think those blocks should be placed?
Two change variable blocks should be added to your Dancing Cat program and each of these should be placed after one of the move blocks, as shown below:
Click the stack of blocks and watch the number of movements variable's Stage monitor. Notice that the number of movements variable increases by 8 every time the Cat does its dance from start to finish.
Views | |
---|---|
1 | Total Views |
1 | Members Views |
0 | Public Views |
Share by mail
Please login to share this webpage by email.