Using the Random Block

Next, you'll add blocks so that every time he is clicked, Alonzo moves to a random position on the stage.

  1. Find the pick random (1) to (10) block in the green Operators palette, and click it several times to try it out.
  2. Talk with Your Partner What values did the random block report? How can you code "Alonzo moves to a random position on the stage"?
  3. Add a line of code so that every time Alonzo is clicked, he not only turns, but also moves to a random position (between -190 and 190 in the x direction and between -130 and 130 in the y direction). Use two pick random () to () blocks and one go to x=0 y=0 block together at the end of your code to make this happen. The video shows how to snap these together, but you will need to do more than it shows.
    Placing random block in goto block
    The Snap! stage (the white space in the upper right where sprites act out their scripts) is just like the coordinate plane. The x axis goes from -240 to 240, and the y axis goes from -180 to 180.
    Coordinate Grid
    Make Alonzo move to a random position between -190 and 190 in the x direction and between -130 and 130 in the y direction so he doesn't go off the edges of the screen.
  4. Click on Alonzo. If your script works, Alonzo should face the other way and move to a random spot on the stage.