4. Catch bugs

_images/scratch-p04-juego.png

In this practice we are going to program a game that consists of catching all the beetles that appear on the screen. Once trapped, we win the game and a character tells us about it.


  1. We start the Scratch editor.


  2. We delete the cat by clicking on it with the right mouse button and then pressing delete.

    borrar-gato


  3. Next we add a new character, a beetle.

    Press the new object button nuevo-objeto

    Then click on Animals Category.

    Then we select the Ladybug2 object.

    _images/scratch-ladybug2.png


  4. Now we will create the variable Clones

    Within the Data datos tab,

    press create a variable crear-variable

    We change the name of the variable to Clones

    _images/scratch-p04-variable-clones.png

    Finally we press the button OK

    This variable will count the number of beetles on the screen. When this variable is equal to zero, the game will end.


  5. In the program tab we will create a new function called Start

    First click on the button more blocks

    mas-bloques

    Then click on create a block crear-bloque

    Then we change the name of the new block to Home

    _images/scratch-bloque-inicio.png

    Finally we press the button OK


  6. Now we program the Start function with the following commands.

    _images/scratch-p04-bicho-prog1.png

    This program hides the beetle, clears the screen, and places five clones of the beetle on the screen.


  7. At this point we add the instructions so that each clone of the beetle appears in a different place on the screen with small size. When the mouse pointer touches a beetle, it will disappear.

    _images/scratch-p04-bicho-prog2.png


  8. To check that everything works correctly, double-click start and five beetles will appear on the screen. The beetles should disappear when the mouse pointer touches them.


  9. In order for the game to work normally, we programmed the function that will spawn beetles from time to time until the game ends.

    _images/scratch-p04-bicho-prog3.png


  10. Now we have to choose a suitable background for the game. Changed the background to a street wall.

    Click on the New Background button.

    cambia-escenario

    Then click on City Theme.

    Then we select the background brick wall 1.

    The screen will be as follows.

    _images/scratch-p04-06.png


  11. Finally we are going to program a character that warns of the end of the game. In this case, a dancer has been chosen.

    Press the new object button nuevo-objeto

    Then click on People Category.

    Then we select the Ballerina object.

    _images/scratch-ballerina.png


  12. In the program tab of the new character

    _images/scratch-p04-ballerina.png

    We add the following instructions.

    _images/scratch-p04-bicho-prog4.png

    Now at the end of the program the dancer will appear to congratulate us.



Exercises

  1. Add a new rule to the game. If the number of beetles is greater than 25, then we lose the game. The program stops and a new character tells us that we have lost.