In this add-on, you will create a sprite that says random phrases to cheer on the racer.
To start, add a new sprite using the “Choose sprite from library” button. Select anysprite you want to be the cheerleader. This example uses Dan.
Now, create a list of phrases for the sprite to say. To do this, open the “data” menuand click “make a list.” Name the list something descriptive, like “Happy Cheers.”
After creating the list, two items appeared: a bunch of blocks and a grey box with thelist name on the stage. To add a phrase to the list, click the “plus” sign in thegrey box, and start typing. Add at least 4 phrases to the list.
Next, make the sprite say a random phrase from this list. Open the “looks” menu,and add a “say for 2 seconds” block. Then, open the “data” menu, and add an “itemof” block to the “say” block. Open the dropdown menu, and select “random.” Theblock now reads “say item random of Happy Cheers for 2 seconds.”
Click on the block and watch what happens. Great! The sprite says a random phrase fromthe list every time the block is clicked. Next, make the sprite say phrases at randomtimes. To do this, put a “forever” loop around the “say” block, and add a “wait”block. Insert a “pick random” block from the “operators” menu inside the “wait”block, and set the wait time to whatever you want. This example will wait a random timebetween 2 and 5 seconds. Then, add a “when flag clicked” block to the top of the “forever”loop.
Test out your code by clicking the flag. Great! The cheerleading sprite says phrases at randomtimes! However, the list and the sprite are in theway of the game. To hide the list from view, open the “data” menu and uncheck the boxnext to the list name.
Hide the cheerleading sprite when it’s not saying anything by adding a “show” blockbefore the “say” block and a “hide” block after the “say” block. Move thesprite to where you want it to appear.
Now test out your game. Nice! It works! Here’s the gameplan:Add a sprite to be the cheerleader. Create a list of phrases for the sprite tosay. Make the sprite say random phrases at randomtimes using a “say for 2 seconds” block, an “item of” block, a “when flag clicked”block, a “forever” block, a “wait” block, and a “pick random” block.
Hide the list and the sprite from view so they don’t cover up the game.
Choose an Add-On
Add a starting screen with instructions for your game.
Keep track of how long a racer stays alive and display the score.
Create a sprite that cheers on the racer.
Program your racer to do a cool trick at the press of a button.
Create a power up that shrinks the racer.
Add a sound that plays when the racer crashes into an obstacle.