Project Folders
Teacher Resources
Student Resources
How Do I?
Site Map
Our Team

critter chat 1 2 3 4 5 6 7
Critter Chat Expert 7
11 KB

Goal:   This guessing game keeps score and gives rewards.


Vocabulary:   run, pick, setpos, seth (setheading), clean, setpensize

Project Map

to startup
set "question "pos [-200 140]
set "announce "pos [-200 140]
setbg 0
t1, setsh "critter
setpos [-234 26]

to conversation
make "mynumber 1 + random 100
make "score 1
question [Hi! Let's play a guessing game! What is your name?]
if empty? answer [stop]
make "yourname answer
question (se :yourname [, guess a number between 1 and 100.] )

to guessing-game
if empty? answer [stop]
if answer > :mynumber [question (se answer [is too high.   Guess again!] ) make "score :score + 1 ]
if answer < :mynumber [question (se answer [is too low.   Guess again!] ) make "score :score + 1 ]
if answer = :mynumber [announce (se "Good, :yourname "! answer [is the right number! It took you] :score [tries to guess the number.] ) reward stop]

to reward
if :score > 10 [stop]
announce (se [Since you guessed the number in only] :score [tries, you get a reward! I will turn into a "creepy critter" and move around the page!] )
t1, run pick [spidermove butterflymove wormmove inchwormmove caterpillarmove beemove]

to spidermove
setbg 35
t1, setsh "spider
repeat 50 [rt random 360
           glide random 150 1]

to butterflymove
setbg 102
t1, setsh [butterfly1 butterfly2]
repeat 50 [rt random 360
            fd random 30
            wait 1]

to wormmove
setbg 39
t1, seth 90
setsh [worm1 worm2]
repeat 120 [fd 5 wait 1]

to inchwormmove
setbg 72
t1, setpos [100 26]
seth 0
setpensize 50
setc 67
pd fd 350 pu
setsh [inchworm1 inchworm2 inchworm3 inchworm4]
repeat 80 [fd 5 wait 2]

to caterpillarmove
setbg 56
t1, seth 90
setsh [caterpillar1 caterpillar2]
repeat 120 [fd 5 wait 1]

to beemove
setbg 92
seth 0
setpos [0 50]
setsh [bee1 bee2 bee3]
repeat 70 [rt random 80
            fd random 60
            wait 1]

to Let's_play_again!


The reward at the end of the game involves changing the shape and position of the little round guy.   So we need to get him back to his normal shape and position at the start of each new game.

  1. Setpos [-234 26] tells the turtle where to go.   Setpos stands for "set position."
    Setpos [0 0] is the very middle of the page.   The first number tells him how far left or right to move.   -234 is a negative number, so he moves a lot to the left.   (He moves 234 pixels to the left.)   The second number tells him how far up or down to move.   (He will move up 26 pixels.)   Of course you may choose your own numbers.

  2. One of the rewards involves drawing a line on the page, so we need a way to erase this line when we start a new game.   Clean erases the page without moving any turtles.

  3. We can keep track of how many guesses a user needs to guess a random number between 1 and 100.   Then we can announce how many guesses it took.   We can give a reward if the user can guess the number in 10 guesses or less.

    We need a new variable, score, to keep track of the number of guesses.   We will give it a starting value of 1.

  4. If the guess is too high or too low, the value of score will increase by 1, using this command:
    make "score :score + 1
    :score is the current value of score.   The command means, "Add 1 to the current value of score."

  5. The reward procedure checks the score.   If it is over 10, it stops.   If it is 10 or less, it will randomly choose a word from a list.   These words are the names of procedures.  
    Pick tells the computer to pick one of these words.  
    Run tells the computer to run the procedure that has been picked.

  6. Each of the procedures in the list animates one creepy critter.   Some of these procedures tell the critter to choose a random direction or to move a random distance.   For instance, rt random 360 means, "Turn right any amount from 0 to 359."

  7. We want to be sure that the worm moves to the right and not straight up.   But we don't know what direction this turtle was already heading before it becomes a worm.  

    Seth 0 means, "No matter what direction you were already heading, point straight up now."   Seth 90 means, "point straight to the right."   The turtle wearing the worm costume will point in that direction.

  8. Pd tells the inchworm turtle to put its pen down, and pu tells it to put its pen up again.   We need it to put its pen down to draw a green stem in inchwormmove.   This line should be thick, so we make the pen thick with setpensize 100.

  9. The bee will seem to move in random circles because the command rt random 80 means that it will keep turning a bit to the right.

What If?
What happens if you add 2 to :score after every guess?
What happens if you change the number 10 to a higher number in the first line of the reward procedure?

Can you write a new procedure and include its name in the guessing-game procedure so that the Critter chooses between several different comments if the guess is wrong?

On Your Own - Project Ideas
Create different reward animations.

© copyright 2001 - 2016  OpenWorld Learning.   All rights reserved.