Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more


Sometimes games that have enemies to avoid, but also have prizes to catch. This screencast will 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 can select 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 numbers for 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 apple moves 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” block just 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 should receive 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 if block 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 make the 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.

Choisir une extension
Hourras de la ligne d'arrivée
Programme un son à jouer si le joueur touche la ligne d'arrivée.
Jouer avec un ami
Ajoute un second joueur au jeu.
Défier un ami
Défie un ami en le laissant contrôler les ennemis.
Programme la ligne d'arrivée pour qu'elle rapetisse à mesure que le joueur marque des points.
Points bonus !
Crée un lutin qui, lorsqu'il est touché, apporte au joueur des points supplémentaires.
Changer la conception des niveaux
Programme l'arrière-plan pour qu'il change chaque fois que le joueur marque 5 points.
arrow_backward Retour
Suivant arrow_forward
  1. Clique sur l'une des fenêtres pour accéder à la vidéo sur les extensions.
  2. Quand tu as fini, reviens à la page des extensions et essaies-en une autre !