Step 1: Checking for equality ( = )
In this first level you'll need to move the chicken to collect all 5 coins to win. Use the arrow keys on your keyboard to control the chicken.
>Click Play to see if you can win the first level.
The chicken collects all 5 coins but you don't win. We'll have to program that in.
>Click Close to go back to viewing the level.
>Right-click on the chicken and select Edit Script.
This chicken already has code to make it move around, but we need to add something extra to check how many coins have been collected. We'll do this by checking if the number of coins collected = 5, and we'll keep checking this forever. Once the number of coins collected does equal 5, then we'll tell the game we've won by broadcasting the message "you win".
>Open Events, and drag `When the level starts` underneath the other blocks in the work space.
>Then open Control Flow and drag `forever` into the `When the level starts` block.
>Also grab `if do` from Control Flow and drag that inside `forever`.
Now we need to check if a number is equal to another number. This is a comparative operator because it makes a comparison between two things. This particular comparative operator is an equality operator, because it is checking if two things are equal to each other.
>Open Operators and drag `_=_` so that it connects to the `if` block.
>Open Variables and drag `number coins collected` into the left side of the `_=_` block.
>Then open Operators and drag `0` into the right side of the `_=_` block. Click on the 0 and type 5.
This will now check if coins collected = 5, so we just need to broadcast a message to tell the game that "you win".
>Open Events and drag `broadcast message` into the `if do` block.
>Click on "message" and type in "you win".
Click Play and then select Level 1 to test it out. Move on to the next step when you've collected all 5 coins and seen the "Good job" screen.