Scratch Exercise 3: Something to Eat.  Conditionals, Variables, Hiding, and Sound.

Step 1:  Create the food!

1. Select a New Sprite from file.  I used a tennis ball, but you can select or draw anything.

step4a

2. Use the "shrink sprite tool" to make the food smaller in relation to the rest of the world.

step4c
step4d

3. Rename the sprite.  (I chose "Ball.")

step4b



Step 2:  Create the scripts for score and hiding.

1. Click on "Variables" and "Make a Variable" and name it "Score."  Click "Ok."

step4e

2. Drag a "When Green Flag Clicked" and a "Forever If" into the Ball's scripts field.

step4f

3. Add the following scripts:
a. Set "Score to 0" between the Green Flag and the Forever if.
b. "Change Score by 1" inside the "forever if."
c. Blue Hexagon "touching 'Eater'" inside the forever if.

step4g

4. Add a "show" and "hide" to the script.  Put the "show" underneath the "when Green Flag Clicked" and the "hide" inside the forever script.

step4h

5. Check your program.  Click the green flag and run your Eater over the food.  It should hide and change your score by 1.  Click the Green Flag again, the score should set to zero and the food should show again.

Step 3:  Add a Sound when the Eater touches the ball.

1. Make sure you are on the Eater sprite.  Click the "Sounds" tab.

step5a

2. Select "Import Sound" and select a sound from the folder list.

step5b1

step5b

step5c

3. You can test your sound by clicking the blue play triangle under the sound name.

step5d

4. Click on the Scripts Tab. Drag a purple "play sound and wait" block into the Ball's script.

step5e

5. Click the Green Flag and test your program.  When the Eater touches the Ball you should hear a sound and the score should increase by 1.

Step 4: Copy objects.

1. Once you are satisfied with the Ball sprite and its scripts, click the "Stamp" tool and then click on the sprite you wish to copy.  Use the "Stamp" tool to copy your Ball sprite. 

step6a

2. Copy and arrange the ball sprites around the maze.

step6b

Step 5: Add background music.

1. You may add background music to your game.  Scratch will play any .mp3 or .wav files. 

2. Click on the stage icon.

3. Click on Sounds and import a sound like Step 3.

4. Drag a "When Green Flag Clicked" into the the Scripts pane.

5. Drag a "forever" and a "play sound and wait" block and arrange like below.

step7

6. Click the green flag and test your game.

Back to Nebo Scratch Programming Projects Page