Guess number game in scratch
- User
Guess number game in scratch
Assistant
Below is a simple Guess the Number Game designed in Scratch. This project is beginner-friendly and teaches basic concepts like variables, loops, and conditional statements.
Scratch Project: Guess the Number Game
Objective:
The player tries to guess a randomly generated number between 1 and 100. The game provides hints ("Too high!" or "Too low!") until the player guesses correctly.
Step-by-Step Guide
Sprites:
- Sprite 1: A cat (default) for user interaction.
- Sprite 2: A "Number Guesser" sprite (optional, for visual feedback).
Backdrop:
A simple background with the title "Guess the Number!"
Scratch Code
Stage Scripts:
when green flag clicked hide delete all of [guesses v] set [secret number v] to (pick random (1) to (100)) say [Let's play! Guess a number between 1 and 100.] for (2) seconds showSprite 1 (Cat) Scripts:
when I receive [start game v] set [guesses v] to (0) forever wait for [guess v] change [guesses v] by (1) if <(guess) = (secret number)> then say [Correct! The number was (secret number). You won in (guesses) guesses!] for (5) seconds stop [this script v] else if <(guess) > (secret number)> then say [Too high! Try again.] for (2) seconds else say [Too low! Try again.] for (2) seconds end end endUser Input:
Add a text input for the player to enter their guess:
when green flag clicked ask [Enter your guess:] and wait broadcast [guess v]
How to Play
- Click the green flag to start.
- Enter a number between 1 and 100 when prompted.
- The cat will respond with hints until you guess correctly.
- Win and see your total guesses!
Enhancements (Optional):
- Limit Guesses: Add a counter for max attempts (e.g., 10 tries).
- Score System: Track fastest wins or fewest guesses.
- Visual Feedback: Use a thermometer sprite to show "hot" or "cold" hints.
Scratch Project Link Template:
Guess the Number GameLet me know if you'd like help publishing or adding features! 🎮
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.