Level Up! Designing Power-Up Systems in Scratch
Lesson Overview
In this lesson, Will will move beyond basic movement and learn how to implement a "Power-Up" system. We will explore how variables and conditional logic can change a character’s behavior temporarily, making a game more dynamic and exciting.
Materials Needed
- Computer or laptop with internet access
- A Scratch account (free at scratch.mit.edu) or the Scratch Desktop offline editor
- Brainstorming notepad or digital document
Learning Objectives
By the end of this lesson, you will be able to:
- Create and use Variables to control sprite attributes (like speed).
- Use Conditional Logic (If-Then statements) to trigger events.
- Implement a Timer Mechanism to make effects temporary.
- Design a functional "game loop" where power-ups spawn and disappear.
1. Introduction: The "Secret Sauce" of Gaming
The Hook: Think about your favorite games—Mario, Minecraft, or even Fortnite. What happens when you pick up a Star, a Potion, or a specific Item? The rules of the game change. You might run faster, jump higher, or become invincible. This is called a Power-Up System.
Discussion:
- What is your favorite power-up in any game?
- How does it change the gameplay? (Does it make the game easier, or just more chaotic?)
- What visual cues tell the player the power-up is active? (Color changes, sparks, music changing?)
2. "I Do": Understanding the Logic (The Teacher/Guide Model)
Before jumping into the code, let’s look at the "logic flow" of a power-up. To make a "Speed Boost," we need three things:
- A Trigger: The player touches the item.
- An Effect: The player's speed variable increases.
- A Reset: After 5 seconds, the speed goes back to normal.
Key Concept: Variables. Think of a variable like a labeled box. We can put a number inside (like "5"), and whenever the code asks for "Speed," it looks inside that box. To make a power-up, we just swap the number in the box for a bigger one, then swap it back later.
3. "We Do": Building the Framework (Guided Practice)
Follow these steps to set up the base game together:
Step 1: Setup the Player
- Pick a Sprite (the Player).
- Create a Variable named
PlayerSpeedfor all sprites. - Set
PlayerSpeedto 5 when the Green Flag is clicked. - Code the movement:
When [Right Arrow] pressed, change X by (PlayerSpeed). (Do this for all four directions).
Step 2: Create the Power-Up
- Pick a new Sprite (e.g., a Lightning Bolt or a Potion).
- Add this logic to the Power-Up Sprite:
When Green Flag clicked->Forever loopIf touching [Player] then:Set PlayerSpeed to 12Hide(The item "disappears" because you ate it)Wait 5 secondsSet PlayerSpeed to 5(The boost wears off!)
4. "You Do": Creative Customization (Independent Practice)
Now it’s your turn, Will! Your mission is to create your own unique Power-Up. Choose one of the following challenges to add to your project:
- The "Ghost" Power-Up: Change the player's Ghost Effect (transparency) to 50 so they can pass through certain obstacles.
- The "Size Shifter": Use the
Change Sizeblocks to make the player tiny (to fit through small gaps) or giant (to stomp enemies). - The "Multi-Point" Potion: Create a variable called
Score. While the power-up is active, every point you get is doubled.
Success Criteria:
- The power-up must be "collectible" (disappear when touched).
- The effect must be noticeable (the player clearly changes).
- The effect must be temporary (it must reset after a few seconds).
5. Conclusion: Recap & Showcase
Recap:
- What block did we use to make the power-up wear off after a certain time? (The
Waitblock). - Why is using a
Variablefor speed better than just typing the number "5" into every movement block? (Because you only have to change the variable in one place to update the whole game!)
Demonstration: Playtest your game. Does the power-up make the game more fun? Is it too short or too long? Adjust your "Wait" seconds to find the "Sweet Spot" of game balance.
Differentiation & Extensions
- Scaffolding (If stuck): If the movement code is too complex, start with a "Clicker" style game where the power-up increases the points gained per click instead of movement speed.
- Extension (Advanced): Create a "Spawn System." Instead of the power-up being there at the start, make it appear at a
Random Positionevery 10 to 20 seconds using clones. - Visual Flair: Add a "Sound Effect" when the power-up is collected and a "Blinking" effect when the power-up is about to expire.