Step 7

Goal:


Let’s define each of our IF statements for our rules.

We will also program Scratch to broadcast information and reset his position when he fails or wins.

Steps:

  1. From Sensing, drag 2 touching color blocks into the IF blocks.
  2. From Events, drag 2 broadcast blocks to each IF block.
  3. Select win and try again! for each broadcast.
  4. From Motion, drag 2 go to X/Y blocks to each IF block.

Code:


Click to replay

We will now select the colors to use for our IF statements.

These colors can be later customized or new rules can be added using the same blocks of code.

Steps:

  1. Click on the touching color block.
  2. Select the last option in the window the opens.
  3. In the game window, click on the color you want.

Remember:

The first color needs to be the color of the lines that make up the maze (black).

The second color needs to be the color used for the end of the maze (bright green).

Code:


Click to replay