O'Reilly logo

Scratch 2.0 Game Development HOTSHOT by Sergio van Pul, Jessica Chiang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a level generator

We will add a script to the sprite we just created that selects a costume at random and copies it onto the stage. With a double for loop, we will make sure the tile generator steps around the entire stage, so no space is left blank.

Prepare for lift off

To set up this game, we will create a small control script in the Stage object to set everything in motion as follows:

  1. Start a new script with the when <space> key pressed block.
  2. Attach a broadcast message to this.
  3. For the message, type createMaze:
Prepare for lift off

This message will trigger when a new maze should be generated. It can be activated by pressing the Spacebar key and at a later stage, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required