Custom Variables

Customization

If Scratch were limited to the three variable attributes of x position, y position, and direction that the interface provides, manipulating sprites on the screen would become boring very quickly. Anyone who has played a role-playing game (RPG) is familiar with a variety of attributes and skills typically available to characters. Because Scratch allows the creation of custom variables, we can create new attributes for our characters.

Your current Game of Tag program dictates how fast each character moves (e.g., 10 steps per movement). We could instead vary each sprite’s speed according to its “skill level.” In order to do that, let’s create a new variable called speed:

In the Variables tab, click Make a Variable, and enter speed as the name. We will want each sprite in our program to have its own speed, so make sure that the button For this sprite only is selected. Create one speed variable for each character. What would happen if For all sprites were selected? Experiment!

The Variables tab supplies two blocks to change the value of speed:

Now that you know about speed variables, make use of them for your Game of Tag program. For each move [10] steps block, replace the numerical value 10 with the variable speed by dragging it from the Variables tab into the slot.

For example, you should have something resembling the following:

Instructions

Add the following functionality to your Game of Tag program:

  1. When the green flag is clicked, have each sprite ask for an initial speed. Set the speed of each according to the answer given.
  2. When the second sprite is caught (e.g., when the cat touches the mouse, and the mouse says “OH NOs!!!”), increase the second sprite’s speed by 5.
  3. Pretend that the first sprite is a vertical kind of guy—whenever the first sprite moves up or down, increase his speed by 1. Whenever he moves right or left, decrease his speed by 1.
  4. Make your speed variables visible on the screen so you can test your program to ensure it works correctly.
  5. Personalize your program in at least three other ways.
  6. Provide documentation for your program (describe what it does) as the Instructions. Be sure to describe how your program is original.

When you are satisfied with your work, submit a link to your program or the program itself. Your work will be reviewed by a peer, and in turn, you will review one of your peers’ projects. You should base your evaluation on the assignment rubric.

Rubric

Criteria Points
Characters move properly 2 pts
Mouse says “OH NOs!!!” when characters touch 2 pts
Speed is determined by user input 2 pts
Mouse speed is conditioned on collisions with Cat 2 pts
Cat’s speed is conditioned on directional movement 2 pts
Displays speeds on the screen 1 pt
Documentation, usability, and personalization 1 pt
TOTAL 12 pts