7. Catch bugs

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.

_images/scratch3-p06-screen.png


  1. We start the Scratch editor.


  2. Press the language button boton-idioma in the top bar and choose English.


  3. We delete the cat object by clicking on the trash can icon.

    borrar-gato


  4. Now we choose a suitable backdrop for our game. Changed the backdrop to a street wall.

    Press the button choose a backdrop seleccionar-fondo.

    We look in the Exteriors section.

    and select the backdrop Wall 1.

    _images/scratch3-fondo-wall1.png


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

    Press the button choose an object seleccionar-objeto.

    We look in the Animals section.

    and select the Ladybug2 object.

    _images/scratch3-objeto-ladybug2.png


  6. Now we will create the variable clones that will count the number of beetles on the screen. When this variable is equal to zero, the program will end.

    Press the variables button boton-variables,

    click on create a variable boton-crear-variable.

    We change the name of the variable to clones

    _images/scratch3-crear-variable-clones.en.png

    Finally, click on the OK button.


  7. We make a program that hides the beetle, reduces its size, resets the number of clones to zero, and places ten clones of the beetle on the screen.

    _images/scratch3-p06-ladybug-01.png


  8. At this point we add the instructions to have each clone of the beetle appear in a random place on the screen and increase the number of beetles by one.

    When the mouse pointer touches the beetle, one is subtracted from the beetle counter and the beetle disappears.

    _images/scratch3-p06-ladybug-02.png


  9. Press the green flag bandera-verde to test the operation of the program.

    Ten beetles should appear on the screen. The beetles should disappear when the mouse pointer touches them, without clicking.


  10. In order for the game to work normally, we programmed the function that will spawn new beetles from time to time. When the number of beetles on the screen is zero, the game ends and the program stops.

    _images/scratch3-p06-ladybug-03.png


  11. Finally we are going to program a character that warns of the end of the game. In this case we can choose Casey.

    Press the button choose an object seleccionar-objeto.

    We look in the People section.

    and select the Casey object.

    _images/scratch3-objeto-casey.png


  12. We select the new character

    _images/scratch3-p06-selecciona-casey.png

    and add the following instructions.

    _images/scratch3-p06-casey-01.png
  13. Press the green flag bandera-verde to test the operation of the program.

    Now, at the end of the program, Casey will appear dancing to congratulate us on winning.



Challenges

  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.
  2. Add more costumes to the beetle character, so that a different costume appears with each clone, using the "next costume" command in the appropriate place.