π Module 7: Advanced Game Features β Broadcasting & Cloning
βTaking your games to the next level.β
π Module Introduction
In Module 6, we learned how to create simple games. Now it's time to make them more advanced.
Two powerful features in Scratch are broadcasting and cloning. Broadcasting lets sprites send messages to each other β like saying "Hey, something happened!". Cloning lets you create copies of a sprite β like making multiple enemies or obstacles.
Think of broadcasting like a walkie-talkie β one sprite sends a message, and another sprite receives it. Cloning is like a photocopier β you make many copies of the same sprite.
In this module, we will learn how to use these features to create more complex and exciting games. Let's dive in!
π― Learning Objectives
- Understand what broadcasting is and how to use it.
- Send and receive broadcasts between sprites.
- Use broadcasting to control game events (win, lose, level change).
- Understand what cloning is and how to use it.
- Create clones of sprites for enemies, obstacles, and effects.
- Combine broadcasting and cloning to create advanced games.
π Warm-up Story: The Advanced Game
Imagine you are creating a game where a character collects stars while avoiding enemies. You want many enemies to appear, and you want the game to end when you collect all the stars.
You use cloning to create multiple enemies. You use broadcasting to send a message when all stars are collected β the message tells the game to say "You Win!".
Your game is now more advanced, fun, and challenging. This is the power of broadcasting and cloning!
π Main Lessons
Lesson 1: What is Broadcasting?
Definition: Broadcasting is sending a message from one sprite to all sprites.
Why important: It allows sprites to communicate and coordinate actions.
Simple explanation: It's like a school announcement β one person speaks, and everyone hears it.
Real-life example: A teacher says "Time for lunch!" and everyone goes to the cafeteria.
School example: A student sends a message to the class to start a group activity.
Home example: A parent says "Dinner is ready!" and everyone comes to the table.
Nigerian example: In a market, a vendor shouts "Fresh yams!" and customers come to buy.
Broadcasting:
βββββββββββββββββββββββββββββββββββββββββββββββ
β Sprite 1 β sends "message" β
β Sprite 2 β hears "message" and responds β
β Sprite 3 β hears "message" and responds β
βββββββββββββββββββββββββββββββββββββββββββββββ
β
Mini summary: Broadcasting sends messages between sprites.
Lesson 2: How to Broadcast
Why important: You need to know how to send a broadcast.
How to broadcast:
- Add "broadcast message1" from the Events category.
- Choose "New message" and give it a name (e.g., "win").
- When this block runs, it sends the message.
Nigerian example: A game broadcasts "level complete" when you finish a level.
β
Mini summary: Use "broadcast" to send a message.
Lesson 3: How to Receive a Broadcast
Why important: You need to know how to respond to a broadcast.
How to receive:
- Add "when I receive message1" from the Events category.
- Choose the same message name you broadcast.
- Add blocks below it to respond.
Nigerian example: When a game broadcasts "game over", the sprite says "You lost!".
β
Mini summary: Use "when I receive" to respond to a message.
Lesson 4: Using Broadcasting for Game Events
Why important: Broadcasts are perfect for game events.
Common uses:
- Win condition: Broadcast "win" when the player wins.
- Lose condition: Broadcast "lose" when the player loses.
- Level change: Broadcast "next level" to change scenes.
- Power-up: Broadcast "power-up" when a power-up is collected.
Nigerian example: A game broadcasts "win" when all stars are collected.
β
Mini summary: Use broadcasts for win, lose, and level changes.
Lesson 5: Broadcasting Example β Win Condition
Steps:
- Create a "score" variable.
- When score reaches 10, broadcast "win".
- Add "when I receive win" β say "You Win!".
Nigerian example: A quiz game broadcasts "win" when you get all answers correct.
β
Mini summary: Broadcast "win" when the player wins.
Lesson 6: What is Cloning?
Definition: Cloning creates copies of a sprite.
Why important: Cloning lets you create multiple enemies, obstacles, or effects without adding many sprites manually.
Simple explanation: It's like a photocopier β you make many copies of the same sprite.
Real-life example: A factory makes many copies of the same toy.
School example: A teacher makes copies of a worksheet for the whole class.
Home example: You make multiple copies of a photo to give to friends.
Nigerian example: A baker makes many loaves of the same bread.
Cloning:
βββββββββββββββββββββββββββββββββββββββββββββββ
β Original Sprite β
β β β
β Clone 1 Clone 2 Clone 3 Clone 4 β
βββββββββββββββββββββββββββββββββββββββββββββββ
β
Mini summary: Cloning creates copies of a sprite.
Lesson 7: How to Create Clones
Why important: You need to know how to make clones.
How to clone:
- Add "create clone of myself" from Control.
- Use a loop to create multiple clones.
- Each clone behaves like the original.
Nigerian example: A game creates 5 enemy clones at the start.
β
Mini summary: Use "create clone of myself" to make copies.
Lesson 8: When I Start As a Clone
Definition: This block runs whenever a clone is created.
Why important: It tells the clone what to do.
How to use:
- Add "when I start as a clone" from Control.
- Add blocks below it β like "go to random position" or "move".
Nigerian example: Each enemy clone starts at a random position.
β
Mini summary: "When I start as a clone" tells clones what to do.
Lesson 9: Deleting Clones
Definition: Clones can be deleted when they are no longer needed.
Why important: Too many clones can slow down your game.
How to delete:
- Use "delete this clone" from Control.
- Use it when a clone touches something or reaches the edge.
Nigerian example: An enemy clone deletes itself when it hits the player.
β
Mini summary: Delete clones to keep your game fast.
Lesson 10: Cloning Example β Enemy Spawning
Steps:
- Create an enemy sprite.
- Add "when green flag clicked".
- Add "forever" loop.
- Inside the loop: "create clone of myself", "wait 2 seconds".
- Add "when I start as a clone" β go to random position, move, and delete when touching the edge.
Nigerian example: Enemies appear every 2 seconds in a game.
β
Mini summary: Use clones to spawn enemies.
Lesson 11: Combining Broadcasting and Cloning
Why important: Together, they create powerful games.
Example:
- When you collect a power-up (broadcast "power-up"), all enemies freeze.
- When you win (broadcast "win"), all clones delete themselves.
Nigerian example: A game where collecting a star gives you a speed boost (broadcast) and enemies appear (cloning).
β
Mini summary: Combine broadcasting and cloning for advanced games.
Lesson 12: Creating a Complete Game with Broadcasting and Cloning
Steps:
- Design your game β e.g., a character collecting stars while avoiding enemies.
- Use cloning for enemies.
- Use broadcasting for win, lose, and power-ups.
- Add score, lives, and levels.
- Test and improve.
Nigerian example: A game where you collect Nigerian flags while avoiding obstacles.
β
Mini summary: Create complete games using both features.
π Key Vocabulary
Broadcast β Sends a message.
Receive β Responds to a message.
Clone β A copy of a sprite.
Spawn β Create a clone.
Power-up β A special ability.
Win condition β When the player wins.
Lose condition β When the player loses.
Level β A stage in a game.
Message β A broadcast signal.
Delete β Remove a clone.
π§ Important Concepts
- Communication: Broadcasting allows sprites to talk to each other.
- Replication: Cloning creates multiple copies without extra work.
- Performance: Delete clones to keep your game fast.
π’ Steps to Perform Key Tasks
Task 1: Broadcast a Message
- Add "broadcast message1".
- Choose "New message" β name it "win".
- Place it in your code when the player wins.
Task 2: Receive a Message
- Add "when I receive win".
- Add blocks below it β like "say You Win!".
Task 3: Create Clones
- Add "create clone of myself" in a loop.
- Add "when I start as a clone" β add "go to random position".
Task 4: Delete a Clone
- Add "delete this clone".
- Use it when the clone touches the edge.
β
Mini summary: Follow these steps to use broadcasting and cloning.
π’ Step-by-step: Creating a Game with Clones and Broadcast
- Create a player sprite β control with arrow keys.
- Create a star sprite β clone it.
- Create an enemy sprite β clone it.
- Add score variable β increase when you collect a star.
- Broadcast "win" β when score reaches 10.
- Receive "win" β say "You Win!".
- Clone enemies β spawn every 2 seconds.
- Delete clones β when they touch the edge.
- Test your game β play and improve.
π§Έ Fun Examples for Children
- Pet game: Clone pets that run around the screen.
- Space game: Clone stars and enemies in space.
π Everyday Examples
- Family game: Make a game where you collect things and avoid obstacles.
- School quiz: Broadcast a message when you get a question right.
πͺ Parent Tips
- Help your child understand how broadcasting works β like a walkie-talkie.
- Explain cloning β like making photocopies.
- Encourage them to create advanced games.
π‘ Interesting Facts
- Broadcasting is used in many professional games.
- Cloning saves memory β instead of adding many sprites.
- Advanced games use both features together.
β Did You Know?
- You can broadcast to all sprites at once.
- Clones can create more clones β but be careful not to slow down your game.
π Remember This
- Broadcasting sends messages between sprites.
- Cloning creates copies of sprites.
- Use broadcasting for game events (win, lose, level).
- Use cloning for enemies, obstacles, and effects.
- Delete clones to keep your game fast.
- Combine both for advanced games.
β οΈ Common Mistakes
- Forgetting to receive a broadcast. β Make sure you have "when I receive".
- Creating too many clones. β Too many clones slow down your game.
- Not deleting clones. β Clones that don't delete stay forever.
- Using the wrong message name. β The broadcast and receive names must match.
β
Best Practices
- Use clear message names (e.g., "win", "lose", "power-up").
- Limit the number of clones β 50 is a good maximum.
- Delete clones when they are no longer needed.
- Test your broadcasts β make sure they work.
- Combine broadcasting and cloning for complex games.
π Comparison: Broadcasting vs Cloning
| Feature | Broadcasting | Cloning |
| Purpose | Communication | Replication |
| Used for | Sending messages | Creating copies |
| Examples | Win, lose, level change | Enemies, obstacles, effects |
| Performance | Fast | Slower with many clones |
π End-of-Module Summary
Excellent work! You have learned advanced game features:
- Broadcasting: Send messages between sprites.
- Receiving: Respond to messages.
- Cloning: Create copies of sprites.
- Deleting clones: Remove clones to keep performance.
- Combining: Use both for advanced games.
You can now create complex, exciting games in Scratch!
β Frequently Asked Questions
- Q1: What is broadcasting?
Sending messages between sprites.
- Q2: How do I send a broadcast?
Use "broadcast message1".
- Q3: How do I receive a broadcast?
Use "when I receive message1".
- Q4: What is cloning?
Creating copies of a sprite.
- Q5: How do I create a clone?
Use "create clone of myself".
- Q6: How do I tell a clone what to do?
Use "when I start as a clone".
- Q7: Why delete clones?
Too many clones slow down your game.
- Q8: Can clones create more clones?
Yes β but be careful not to slow down your game.
- Q9: What are good uses for broadcasting?
Win, lose, level change, power-ups.
- Q10: What are good uses for cloning?
Enemies, obstacles, falling objects.
π Matching Exercise
Match the term with its description.
| Term | Description |
| 1. Broadcast | A. Create copies of a sprite |
| 2. Clone | B. Send a message to all sprites |
| 3. Receive | C. Respond to a message |
| 4. Spawn | D. Create a clone |
(Answers: 1-B, 2-A, 3-C, 4-D)
π Scenario-based Exercise
Scenario: A student wants to create a game where a character collects coins while avoiding monsters. The game should have 3 lives and a win condition when 20 coins are collected.
Question: How would you use broadcasting and cloning to create this game?
π₯ Group Activity
In groups of 4, each person creates a different part of an advanced game β one does the player, one does the enemies (cloning), one does the scoring and broadcasting, and one puts it together.
βοΈ Individual Activity
Create a project with at least 3 clones and 1 broadcast. Save your project.
π οΈ Mini Project
Create a game that uses cloning for enemies and broadcasting for win/lose conditions. Share with the class.
π Practical Assignment
Create an advanced game using broadcasting and cloning. Write a reflection on what you learned.
π Key Takeaways
- Broadcasting sends messages between sprites.
- Cloning creates copies of sprites.
- Use broadcasting for game events.
- Use cloning for enemies and obstacles.
- Delete clones to keep performance.
- Combine both for advanced games.
π¬ Classroom Discussion Questions
- How can broadcasting make a game more interactive?
- What are the benefits of using clones?
- How can you combine broadcasting and cloning creatively?
- What kind of game would you create with these features?
π Preparation for Module 8
In Module 8, we will explore Capstone Project β Creating a Complete Game. You will use everything you've learned to create a complete, polished game.
Practice with broadcasting and cloning β we will build on these skills in the next module!
You have completed Module 7 β you are now an advanced game designer! π