Imagine a classic game of hide-and-seek brought to life on Scratch, the popular block-based programming platform! In this game, your goal is to find Scratchy, the iconic Scratch cat, through four exciting rounds.
The game typically involves:
The Seeker (You!): You'll control a sprite (perhaps a magnifying glass, or even a different character) that you'll move around the screen to search for Scratchy.
The Hider (Scratchy): Scratchy will be programmed to hide in different, random locations in each round.
Four Rounds: The game progresses through four distinct rounds, each presenting a new challenge.
Here's a breakdown of how a Scratch hide-and-seek game with Scratchy might be programmed:
Setting the Scene:
Backdrops: Each round could feature a different backdrop to represent a new hiding environment. Think of a cozy living room, a bustling park, a mysterious forest, or even outer space! This adds visual variety and keeps the game engaging.
Instructions: Before the game starts, clear instructions would appear, explaining the objective and how to play.
Scratchy's Hiding Behavior:
Random Positioning: At the start of each round, Scratchy would use the go to random position block to quickly move to an unpredictable spot on the stage.
Hiding: Scratchy might then use the hide block to become invisible or change size by to become very small, making him harder to find.
Sound Effects: When Scratchy hides, a subtle "whoosh" or "giggle" sound could play to indicate he's hidden.
Your Search:
Player Control: You would control your seeker sprite using arrow keys or the mouse to explore the stage.
Finding Scratchy: The core of the game lies in detecting when your seeker sprite "touches" or "clicks on" Scratchy. This would be achieved using a touching [sprite name] or when this sprite clicked block.
Revealing Scratchy: Once found, Scratchy would show himself or change size to [100%] to reveal his location. A happy sound effect could play, and a message like "You found me!" might appear.
Managing Rounds:
Variables: A variable named round would be crucial. It would start at 1 and increment after each successful find.
Conditional Logic: If...then blocks would be used to check the round variable and change the backdrop, reset Scratchy's position, and potentially add new challenges for each round.
Win Condition: After four rounds, if you've found Scratchy every time, a "You Win!" message or animation would celebrate your success!
Time Limit: To add difficulty, a timer could be introduced for each round. If you don't find Scratchy within the time limit, you might lose the round or the game.
Hints: For younger players, a "hint" button could be added that briefly reveals Scratchy's location or gives an audio cue.
Sound Clues: Scratchy could occasionally make a soft meow or purr to give a subtle hint about his general whereabouts, especially in later rounds.
Obstacles: Imagine sprites acting as obstacles that you have to navigate around to find Scratchy.
Score: You could keep track of how quickly you find Scratchy in each round, with a high score recorded at the end.
This kind of hide-and-seek game on Scratch is an excellent way to learn about:
Event Handling: Responding to clicks, key presses, and sprite interactions.
Variables: Keeping track of rounds and scores.
Conditional Logic: Making decisions in your code (e.g., "if touching Scratchy").
Motion and Looks: Changing sprite positions, sizes, and backdrops.
Randomness: Making the game unpredictable and replayable.
It's a fun and interactive project for anyone getting started with game development on Scratch!
Advanced:
This tutorial will guide experienced Scratch users through creating a more sophisticated and challenging "Hide-and-Seek" game featuring Scratchy. We'll move beyond simple random positioning and introduce concepts like dynamic hiding, AI-driven seeking, advanced scoring, and customizable difficulty curves.
Begin by establishing your basic game structure. We'll use a single "Game Manager" sprite or global variables for state management to maintain clean code.
Sprite Initialization (Game Manager):
Create an empty sprite named Game Manager. This sprite will handle game states, round progression, and global variables.
Variables:
roundNumber (starts at 1, increments to 4)
timePerRound (e.g., 30 seconds, adjusts per difficulty)
foundCount (tracks successful finds)
difficultyLevel (e.g., Easy, Medium, Hard, controls hiding complexity)
seekerSprite (the sprite controlled by the player)
hiderSprite (Scratchy)
Snippet de código
when green flag clicked
set [roundNumber v] to [1]
set [foundCount v] to [0]
set [difficultyLevel v] to [Medium] // Or prompt user for input
broadcast [Initialize Game v]
Scratchy (Hider) Refinements:
Scratchy should initially hide and prepare for instructions from the Game Manager.
Custom Block: go to valid hiding spot: Instead of go to random position, create a custom block that checks for specific conditions (e.g., not overlapping with specific "obstacle" sprites, not too close to the seeker's starting position). This requires careful scene design with designated hiding zones or collision detection logic.
Snippet de código
// In Scratchy sprite
when I receive [Initialize Game v]
hide
go to x: (0) y: (0) // Placeholder, actual hiding occurs per round
set [hidingNow v] to [false] // Custom variable to prevent re-hiding mid-search
This is where Scratchy gets clever. Instead of pure randomness, we'll introduce calculated hiding.
Hiding Spot Arrays (Lists):
Create a list named hidingX and another hidingY. Populate these lists with precise x and y coordinates of optimal hiding locations in your various backdrops.
Tip: Design multiple backdrops, each with its own set of pre-defined hiding spots.
Snippet de código
// In Game Manager, on "Initialize Game" or when switching backdrops
delete all of [hidingX v]
delete all of [hidingY v]
// Add specific coordinates for current backdrop
add [100] to [hidingX v]
add [-50] to [hidingY v]
// ... add more coordinates
Strategic Hiding (Scratchy Sprite):
When a new round starts, Scratchy selects a hiding spot from the list. Add logic to prevent him from using the same spot twice in a row.
Difficulty Integration:
Easy: Selects a random spot from the list.
Medium: Selects a random spot, but prioritizes spots furthest from the seeker's last known position (requires storing seeker's end position).
Hard: Selects a random spot, then introduces a small, timed "wobble" or "peeking" animation to briefly reveal himself, requiring quick reflexes from the seeker.
Snippet de código
// In Scratchy sprite, custom block "Hide for Round"
define Hide for Round
set [hidingNow v] to [true]
set [chosenSpotIndex v] to (pick random (1) to (length of [hidingX v]))
go to x: (item (chosenSpotIndex) of [hidingX v]) y: (item (chosenSpotIndex) of [hidingY v])
if <(difficultyLevel) = [Hard]> then
hide // Fully hidden at first
wait (pick random (1) to (3)) secs // Random delay
show
set ghost effect to (70) // Semi-transparent "peek"
wait (0.2) secs
hide
set ghost effect to (0)
else
hide
end
// Potential: Change costume to a "hidden" state if applicable
set [hidingNow v] to [false]
Your seeker sprite needs refined controls and detection.
Smooth Movement:
Use change x by and change y by blocks within a forever loop, controlled by if <key [arrow] pressed?> blocks, rather than go to mouse-pointer. This provides more precise player control.
Precise Detection:
Instead of just touching [Scratchy], use a small, designated "detection zone" on your seeker sprite. This could be a tiny invisible sprite parented to the seeker, or a specific costume point.
When the detection zone touches Scratchy, trigger the "found" event.
Snippet de código
// In Seeker sprite (e.g., Magnifying Glass)
when green flag clicked
forever
if <key [right arrow v] pressed?> then
change x by (10)
end
// ... add other arrow keys
if <touching [Scratchy v] ?> and <not <(Scratchy's [hidingNow v]) = [true]>> then // Prevent immediate re-finding
broadcast [Scratchy Found v]
end
end
Implement a visual timer and a more nuanced scoring system.
Countdown Timer:
Create a timer variable and a Timer sprite that displays the time.
Use a broadcast to start/stop the timer for each round.
If the timer reaches 0 before Scratchy is found, the round is lost.
Snippet de código
// In Game Manager
when I receive [Start Round Timer v]
set [timeRemaining v] to (timePerRound)
repeat until <[timeRemaining v] = [0]> or <(foundCount) = (roundNumber)> // or found for current round
wait (1) secs
change [timeRemaining v] by (-1)
end
if <[timeRemaining v] = [0]> then
broadcast [Round Lost v]
else
broadcast [Round Won v]
end
Scoring & Difficulty Multipliers:
Award points based on timeRemaining when Scratchy is found (faster finds = more points).
Apply a multiplier based on difficultyLevel.
Snippet de código
// In Game Manager, when Scratchy is found
when I receive [Scratchy Found v]
change [foundCount v] by (1)
set [roundScore v] to ([timeRemaining v] * (10)) // Base points
if <(difficultyLevel) = [Medium]> then
change [roundScore v] by (50)
else if <(difficultyLevel) = [Hard]> then
change [roundScore v] by (100)
end
change [totalScore v] by (roundScore)
broadcast [End Round v]
Control the game's progression using broadcasts and variables.
Round Progression:
After Scratchy Found or Round Lost, the Game Manager checks roundNumber.
If roundNumber < 4, increment roundNumber, change backdrop, and broadcast Start New Round.
If roundNumber = 4 and all rounds are won, broadcast Game Over - Win.
If a round is lost, broadcast Game Over - Lose.
Snippet de código
// In Game Manager
when I receive [End Round v]
if <(foundCount) = (roundNumber)> then // Successfully found in current round
if <(roundNumber) = [4]> then
broadcast [Game Over - Win v]
else
change [roundNumber v] by (1)
broadcast [Change Backdrop v] // Handle backdrop change based on roundNumber
broadcast [Start New Round v]
end
else // Round lost (timer ran out)
broadcast [Game Over - Lose v]
end
User Interface (UI):
Display roundNumber, totalScore, and timeRemaining clearly on the stage.
Add "Game Over" screens for win/lose conditions, with options to restart.
Obstacle Sprites: Create sprites that block the seeker's path, forcing more strategic movement. These could be cloned and positioned randomly per round.
Decoys: Introduce "decoy" Scratchy sprites (different costumes or slightly off-color) that, if clicked, penalize the player or reveal the true Scratchy's position for a brief moment.
Sound Clues: When Scratchy "peeks" on Hard difficulty, play a very subtle, almost subliminal sound effect (e.g., a faint purr or rustle). This rewards acute listening.
Player Speed Power-ups: Hidden power-ups that temporarily increase the seeker's movement speed.
Difficulty Customization: At the start, allow the player to choose their difficultyLevel using a simple sprite-based menu.
By implementing these advanced techniques, you'll create a hide-and-seek game on Scratch that's not just functional, but genuinely challenging and engaging for experienced players. Remember to rigorously test each new feature to ensure smooth gameplay!