Sometimes games that have enemies to avoid, but also have prizes to catch. This screencastwill show you how to make a sprite that gives you bonus points if caught.
First, you need to create the bonus sprite. This example will use an apple, but you canselect whatever you would like.
Because this sprite will be a prize, it will start the game hidden.
Then, the apple should appear at random times.
To make something happen randomly, you can use an if statement, a “pick random” block,and an equals operator.
This will say:Well, when the sprite appears… It should glide to a spot...
Then it should hide. In order to keep making new random numbersfor the entire game, place this code inside a forever loop.
This code now reads:That seems right! Try it!
This is a good time to tinker with the values to see how you can change game play.
Play around to see what happens when you change the values.
Looks good so far…Oh! The computer never told the apple to go back to where it started. After the applemoves to the right side of the screen and hides, it needs to go back to the left side of the screen.
To make that happen, add a “go-to” blockjust after the “hide” block, and put another one at the beginning of the program.
That way, the apple always starts in the same spot. Test your code to see if it works.
Looks good! Now that the apple is moving, the player shouldreceive points for touching it. To do that, go back to the fish sprite.
You want the fish to score points if it is touching the apple. To do that, put the ifblock into your my program, then add a “touching” block and set the value to apple.
When the fish is touching the apple, you want the score to change by 5.
Add a "change score by block" that will change the score by 5 points.
When the fish touches the apple, 5 points get added.
Feel free to use your own numbers. This example started at 10,which is kind of small, but it was a good place to start testing.
The bonus sprite can be as rare or as common as you’d like in your game. You can also makethe speed of the sprite slower or faster by changing the timing in the glide block.
Feel free to change the amount of points the bonus sprite gives you.
This is your chance to tinker with the code and make your game exactly the way you want it.
Choose an Add-On
Finish Line Cheer
Program a sound to play if the player touches the finish line.
Play with a Friend Option 1
Add a second player to the game.
Play with a Friend option 2
Challenge a friend by having them control the enemies.
Program the finish line to get smaller as the player scores more points.
Create a sprite that, when touched, gives the player extra points.
Changing Level Design
Program the backdrop to change every time the player scores 5 points.