6. Break bricks

_images/scratch-p07-juego.png

In this practice we are going to program a game that consists of breaking bricks with a ball that bounces off a bar. Each broken brick will give us a point.


  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. We added three new characters. A blue button, a tennis ball and a gray button.

    _images/scratch-p07-barra.png


  4. Next we will change the names of the three new characters by pressing the blue "i" button of each of the characters.

    We will name the blue button bar.

    We will call the tennis ball a ball.

    We will name the gray button brick.


  5. Now we will create the variable Points.

    Within the Data datos tab,

    press create a variable crear-variable

    We change the name of the variable to Points

    _images/scratch-variable-puntos.png

    Finally we press the button OK

    This variable will store the points we get by breaking each brick.


  6. Now we will create the variable position.

    Within the Data datos tab,

    press create a variable crear-variable

    We change the name of the variable to position

    This variable will store the position of each of the bricks when starting the program.


  7. Now we will add the Bar program.

    First we select the Bar and then the programs tab.

    We add the following blocks.

    _images/scratch-p07-prog1.png


  8. Next we will add the Ball program.

    First we select the Bar and then the programs tab.

    We add the following blocks.

    _images/scratch-p07-prog2.png _images/scratch-p07-prog5.png


  9. Finally we will add the Brick program.

    First we select the Brick and then the programs tab.

    We add the following blocks.

    _images/scratch-p07-prog3.png _images/scratch-p07-prog4.png


  10. Now we will test that all the programs work correctly by playing a game.


Exercises

  1. Modify the program so that more bricks appear on top.