Scratch Part 2: Control

Hat Blocks

The yellow zone includes 'Hat' blocks that have no links above them. These are used to wait for events

We are initially interested in the first two. We could make a simple program using the third option. Option 4 is more advanced.

Selection Blocks

Selection is done in Scratch/BYOB through if blocks.

The condition is an expression that can be either true or false. For example:

timer > 60 (more than 60 seconds has elapsed since the timer was reset)

We build the conditions through either the sensing section or by using an expression from the Operators section using '<', '=', '>', 'and', 'or' and 'not'.

For example: if <yspeed > 5> <make y = y - 0.5>

For example: if <touching sprite 2> and <mouse down?> <do something>

For example: if <not <touching sprite 2>> <do something>

Repeat Blocks

We use these when we want to do something more than once. Blocks include:

Wait Blocks

Use wait blocks to pause actions in a program.

Wait n seconds: self-explanatory!

Wait until: some condition e.g. timer > 10

Stop Blocks

Stop script and Stop All are fairly self-explanatory.

Broadcast Blocks

One use for the Broadcast mechanism is to switch levels in a game. Say that you have created a series of backgrounds and sprites so that a game can be played at more than one level: how do you get Scratch to move from one level to the next? One way is:

The code for the When I receive block can then be a change of background.

Conditions

A condition is created by using one of the Boolean tests in Operators - less than, equal to or greater than (<, =, >).

This typically goes inside an if block or in another block that uses a condition such as while or forever.