Explore the Scratch program Data Tab which allows you to create and modify your own variables.
Keeping Score
Objectives
-
Create and modify variables using the Data Tab.
Materials
-
Per Student:
1 computer (**at least one computer per two students**) -
Per Class:
Computer with projector or SMART board.
Key Questions
- What does the program in step 4 do? (It counts the number of times you press the space bar to make the sprite move forward. When the sprite reaches the edge, it turns 180 degrees and moves back the opposite way.)
What To Do
Preparation:
Ensure that all the computers work, and are connected to the internet.
Set up the instructor computer and projector or SMART board. Log in to the Scratch website.
Activity:
Instructor:
- Explain that you are going to make it possible to count or keep score during a game
- On the screen or SMART Board, open a new scratch project and select the Data tab.
- Demonstrate how to make a new variable called Score.
- Have students follow along on their own computers as you assemble this logic.
- Have students run the program to discover what it does.
Students:
- Go to scratch.mit.edu/starter_projects and open Maze Starter.
- Modify this program so that it counts the number of times the user hits the blue obstacle.
Extensions
- A possible solution to the student program is posted at https://scratch.mit.edu/projects/97636203/A more complicated score-keeping game is posted at https://scratch.mit.edu/projects/97633211/