Session 6
IF, SENSING, BROADCAST
IF, SENSING, BROADCAST
Your chickens are ready to race.
The only twist is that we will never know which chicken will win because of each of their random speed.
1. Initialisation
2. When Spacebar is clicked
3. Repeat Until
4. Broadcast & Receive Broadcast
5. Motion & If On Edge, Bounce
6. IF touching colour
7. Stop Other Scripts
10. Add "If On Edge Bounce"
11. Set the Yellow Chicken to rotate horizontally only (so that it does not flip over)
*Why do we need to point the Yellow Chicken 90 degrees?
Save your work as "Index_Class_Name_ChickenRun" in Your Workspace
// random can be found in Operators
Challenge: How do we stop all the other chickens when there is already a winner crossing the line?
Clue: Use Broadcast
Clue: The following codes can be used for the Pink Chicken.
Don't forget to include the IF block inside the Repeat Until Loop to ensure that checking is done all the time.
To prepare for your video uploads to Youtube, you will need a gmail account.