Page 4: Giving the Player Feedback
Unit 1, Lab 1, Page 4
Now the game is challenging, but players can’t tell how well they’re doing because Alonzo jumps around whether the player clicks him or not. On this page, you will create a way for the player of your game to know how well they are doing.
Confirming Whether Alonzo Was Clicked
First, the person playing your game wants to know right away whether they succeeded at clicking Alonzo before he moved out of the way.
: Sprites and Costumes
The Alonzo character is named after Alonzo Church, a major contributor to early computer science. In this project, there are three objects related to Alonzo:
- One is a sprite, which is like an actor on the stage who knows how to do many different things, such as walk around the stage and speak the lines of the play.
- The other two are costumes, picture that can be “worn” by a sprite.
Program Alonzo to face the other way when clicked.
- The project you loaded has two Alonzo costumes—one facing right and the other facing left—so you can use the block to make the sprite face the other way. Add the
next costume
block to the place in your program where the user has just clicked on Alonzo. - Test your program. Make sure Alonzo faces the other way when he is clicked but not when he jumps without being clicked.
Keeping Score
The player will also want to know how much progress they have made in the game. The command can control Alonzo’s transparency.
The transparency of an image is how much you can see what’s behind it. For example, here is the Alonzo sprite shown with three different transparencies (which have been set using the ghost effect
block).
Use transparency to tell the user how close they are to winning: every time they click, Alonzo gets more invisible, and when he disappears completely, they win the game.
- Drag the
change (ghost) effect
block into the center scripting area, and experiment with different input numbers (clicking it repeatedly after each change) to see exactly what it does. At what ghost effect value does Alonzo become completely invisible? You can use the command to make Alonzo fully opaque again. - Then, modify your script so that every time Alonzo is clicked, he gets a little more ghostly. Think about how the input you use affects the length of the game. Try out your game.
Making the Game More Challenging
So far, even a bad player will eventually make Alonzo disappear. The game will be much more interesting if the player is penalized for missing a click.
- Figure out where to add a
change (ghost) effect by (-5)
block to your script to make Alonzo get less transparent any time he moves without being clicked. - Play your game a few times, and adjust your code to get a level of difficulty that you like.
You can change the change effect
input number (for either instance of the block) and/or the wait
time to make the game easier or harder.
Ending the Game
When Alonzo is completely transparent, the game should stop.
Add this code to the right place in your script to end the game.