2. Number Guessing Game
◦ https://scratch.mit.edu/projects/61353942
◦ Use above link to go to scratch and play the game.
◦ Guess the secret number between 1 to 100 in 5 attempts.
4. Inside code block
Variables
◦ High : Maximum number
◦ Low : Lowest number
◦ Select Number is a random number used to
generate based on Low and High value
◦ NumberOfChoice : This is used to set in how
many attempts do we want user to guess the
number
◦ Attempted : Going to be increased by 1
Declaring variables
5. Start game
• Speak : It's a number
guessing game.
• What's your name?
• Wait for player to enter his
name
• Greet player : Hello MK
• Guess the secret number
between 1 to 100 in 5
attempts
6. Enter your name and give your secret number
choice
Ask player to enter his name Please enter your choice
7. Repeat block
◦ No of choice is set to 5 so program is going to
5 run five times if any if block condition like
secret number guessed or 5 attempts done
then game is going to be stopped and user
must click on green flag again to start the
game.
◦ Ask : Your choice is :
◦ Set value of High and Low based on every
wrong choice made by player so that limit for
guess range gets short.
8. First if block
If number entered by user is the
secret number, then display
Won!! On the screen and speak
as “Congratulations You took 4
guess to win”
Stop the script from further
running.
12. 3rd if block : If secret number is less then asking player
to enter a number higher than low and lower than
high.
13. 4th if block : If number is higher then asking player to
enter a number lower than high and higher than low
value.
14. Scratch code is configurable
◦ You can make it as per your choice i.e. in which range do you want to guess the secret number and in how many guess. Everything is
configurable.
◦ Just set variable as per your preference and start playing this awesome game.
◦ High and Low number variable is going to be used to generate a random secret number.
◦ No Of Choice = In how many choice, do you want user to guess the secret number.
◦ Default setup:
◦ High = 100
◦ Low = 1
◦ No Of Choice = 5