Skip to content

Please update your browser



In the previous video, you programmed lightning to flash.

The lightning isn't that predictable, and it doesn't flash on command.

In this video, you'll learn how to program the lightning to flash randomly throughout your story.

To start, place a forever block around the repeat block.

This should make the lightning repeat for the entire story.

Click the green flag to test it.

Whoa, that's way too much lightning!

You told the lightning strike to repeat over and over forever, and it did.


Now, you'll add a wait block before the repeat block.


Click the flag to try it again.

Great, when you click the green flag, the computer enters this forever loop.

Its first action is to wait four seconds and then it runs this repeat block to make the lightning strike.

Once it has completed the inner loop, the computer goes back to the outer loop, waits four seconds, and then starts again.

Lightning now strikes every few seconds in your story.

In nature, however, lightning doesn't strike in a pattern.

Sometimes there might be one second between strikes, other times the interval may be much longer.

To make your story setting more realistic, make the computer wait for a random amount of time between lightning strikes.

From the Operators menu, choose a pick random block and place it inside the wait block.


Test this and tinker with the values.

You might feel like a 10 second wait is too long, or that waiting one second is too short.

This example will use two and six seconds.

This means that the lightning strikes could occur at any interval between two seconds and six seconds.

Great, in the next video, you'll program a story to take place within this rainy day setting.

Now it's your turn.

First, add a forever loop to make lightning strikes keep happening forever.

Second, add a wait block to wait between strikes.

Third, add a pick random operator to make the lightning random.

  1. Make the lightning strikes happen forever.
  2. Put time between lightning strikes.
  3. Make the time between lightning strikes random.