Theory
🤔 20. Play Tag
🐱🐶 Program the cat and dog to play tag.
🏷️ The dog’s script starts when tagged by the cat.
🔄 The dog tags the cat, initiating the game.
🔄 They continue playing tag until the program stops
📚 What You’ll Learn
🔄 Introduction to the Start on Bump block.
Start on Bump Block
- 🚀 Initiates a character’s script upon collision with another character.
How to Make It:
🖼️ Select the farm background.
➕ Add the dog character.
📏 Position the cat and the dog about five steps apart on the stage.
🔄 Adjust their positions as needed during script testing.
🐱 Move towards the 🐶 and say “Tag!”
↩️ Move back and pause for 2 seconds.
🔁 Add a Repeat Forever block to the cat’s script.
The dog’s script uses the Start on Bump block so that it starts when the dog is bumped by the cat.
After the dog is bumped, it will wait 2 seconds to give the cat a chance to run away. Then the dog will move to the cat, say “Tag!” and run away.
Create the following script for the dog:
- 🐶 No need for Repeat Forever block for the dog, as Start on Bump block triggers whenever tagged.
- ▶️ Tap Green Flag button to see characters play tag!
- ⏹️ Press Stop button to end the game.