Junkbots - Spawning some rocks

 Activity 6 - Spawning rocks

In this part we’ll start to spawn some rocks. When the green flag is pressed, our code will run. Try to guess what it does. Make sure you click on the “Rock” sprite before coding this part, as the code here will belong to the rock.

In this example, the rock is invisible to the user at first, it then goes to a random position. If the rock is touching the edge of the screen it goes to another position, this bit is in a loop. It then becomes visible to the user. All of this happens instantly, so the user won’t be waiting for the game to start.

Your task:

  • Spawn a rock onto the screen, in a random position

  • Make sure the rock is not off the screen

  • Try change the code so that the rocks spawn in a place you want.


Comments

Popular posts from this blog

Junkbots - Conclusion

Junkbots - Introduction