Beginners Scratch – Guessing Game

This week we decided to give everyone a little breather after the marathon that was last week!! The Guessing Game covers a lot of the same ideas as the Maths Game and reinforces the use of decisions and variables.

For this game we need: 1 sprite (to tell the player what to do and if their guess is correct or not), 2 backdrops and 2 variables (THE NUMBER and GUESS). The SPRITE holds most of our scripting.

FIRST: Scripting in the SPRITE, pick a random number and store it in the variable: THE NUMBER. Tell the player (use SAY block) that you are thinking of a number between 1 and 30….

CDA-S5-Challenge_11-Guessing Game-set random number

SECOND: ASK (yes, use the ASK block!) what the player’s GUESS is and store their guess in the Variable GUESS. !!!!NOTE: when you use the ASK command, the user input (their guess) is always stored in the variable ANSWER, until you reassign it to your own variable GUESS with the SET command in DATA)!!!

CDA-S5-Challenge_11-Guessing Game-ask for guess

THIRD: TEST whether the GUESS is TOO HIGH, TOO LOW or CORRECT using the IF decision block and OPERATORS: >(greater than), <(less than) or =(equal to).Also, TELL the player (use the SAY command) if they are TOO HIGH, TOO LOW or CORRECT.

CDA-S5-Challenge_11-Guessing Game-test guess

FOURTH: LOOP IT!! Use a REPEAT 5 times to give your player 5 chances to get the guess right. Check your work!! Go through each of the possibilities one time to be sure you get the correct response. What if they get it WRONG 5 times?? Tell them what the number was!

CDA-S5-Challenge_11-final script with loop

Use your own imagination to add new sprites that react to a broadcast you could send out after they guess the right answer or wrong answer. Get your backdrop to change after they guess correctly. (Hint: BROADCAST correct before STOP ALL and have the backdrop SWITCH costume when it RECEIVES the BROADCAST)CDA-S5-Challenge_11-Guessing Game-more to do

My copy of this game is up on http://scratch.mit.edu. Search for the cdathenry1516 coder name and check it out! Here is a copy of the notes: CDA-S5-Challenge_11-GuessNumbers.

We are taking a break for the next few weeks for mid-winter break! We will be back on February 27th! Happy Coding!

Julie

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s