Guess number game in scratch
- User
Guess number game in scratch
- Assistant
Here’s a simple Guess the Number Game in Scratch that you can create step-by-step. This game generates a random number, and the player has to guess it within a limited number of tries.
🎮 Scratch Guess the Number Game
Difficulty: Beginner
Time to Build: ~10 minutes📌 Step 1: Set Up the Sprites & Backdrop
- Delete the default Cat sprite (right-click → delete).
- Add a new sprite (e.g., a button or character) for the "Guess" button.
- Choose a backdrop (e.g., "Wall1" or "Xy-grid").
📌 Step 2: Create Variables
-
Click "Variables" → "Make a Variable" and create:
Secret Number(hidden from player)Guesses Left(starts at 5-10)Player Guess(stores the player’s input)
(Check "For this sprite only" for
Secret Numberto hide it.)
📌 Step 3: Initialize the Game
Add this code to your main sprite (e.g., the "Guess" button):
when green flag clicked set [Secret Number v] to (pick random (1) to (100)) set [Guesses Left v] to [5] say [I'm thinking of a number between 1 and 100. Guess it!] for (2) secs
📌 Step 4: Ask for Player Input
when this sprite clicked ask [What's your guess?] and wait set [Player Guess v] to (answer) change [Guesses Left v] by (-1)
📌 Step 5: Check the Guess
Add these conditional blocks after setting
Player Guess:if <(Player Guess) = (Secret Number)> then say [You win! :D] for (2) secs stop [all v] else if <(Player Guess) > (Secret Number)> then say [Too high! Try again.] for (1) secs else say [Too low! Try again.] for (1) secs end end
📌 Step 6: Handle Game Over
Add this after the
ifblocks:if <(Guesses Left) = [0]> then say (join [Game over! The number was ] (Secret Number)) for (3) secs stop [all v] end
🎉 Final Touches
- Add sound effects (e.g., "pop" for correct guesses).
- Customize sprites (e.g., add a celebration animation when the player wins).
- Test the game and adjust difficulty (e.g., change the
randomrange orGuesses Left).
📥 Example Project
You can remix a working version here:
🔗 Scratch Guess the Number Template(Or search "Guess the Number" in Scratch’s Explore section.)
🚀 Challenge Ideas:
- Add a score system (e.g., +10 points per correct guess).
- Let the player choose difficulty (e.g., 1-50, 1-100, or 1-1000).
- Use broadcasts to trigger animations.
Let me know if you’d like help expanding the game! 😊
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.