Home
Project Folders
Teacher Resources
Student Resources
En ESPAÑOL
How Do I?
Vocabulary
MWForum
Site Map
Search
Our Team

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


Goal:   Change the Critter himself into a ball!


Screenshot


Vocabulary:   member?, char 32 (char), setsh (setshape), new use of stop (stop)

Code
Shapes
Project Map

to startup
set "question "pos [-200 140]
set "announce "pos [-200 140]
text1, ct hidetext
setbg 0
t1, setsh "critter
conversation
end

to conversation
question [Hi! Do you want to talk? (Type YES or NO.)]
if answer = "no [stop]
question [What is your name?]
text1, ct insert "Hi, insert char 32 insert answer insert "! showtext
question [I don't have a name.   Please give me a name.]
text1, ct insert "I'm insert char 32 insert answer insert "!
question [What color do you like best: red, yellow, orange, green, blue, or violet?]
changecolor
question [Which sport do you like best: football, baseball, basketball, or soccer?]
insist
announce [I like that sport best, too! Watch me turn into a ball!]
setsh answer
text1, ct insert [I'm a] insert char 32 insert answer if answer = "soccer [insert "ball] insert "!
end

to changecolor
if answer = "red [setbg "red]
if answer = "yellow [setbg "yellow]
if answer = "orange [setbg "orange]
if answer = "green [setbg "green]
if answer = "blue [setbg "blue]
if answer = "violet [setbg "violet]
end

to insist
if member? answer [basketball baseball football soccer] [stop]
question [Which sport do you like best: football, baseball, basketball, or soccer? (Spell carefully!)]
insist
end

to Let's_talk_again!
startup
end



Notes

In this project, the computer responds to more answers.   In the last question of the conversation, if the visitor types one of the listed sports, then the name of that sport will appear in the text box and the "critter" will turn into that type of ball.

  1. Since your "critter" will be changing shape, you'll need to be able to turn it back into its original shape.   Be sure that its original shape has a name.   In this sample, the shape is named critter.  

  2. In the startup procedure, t1, setsh "critter sets the critter's shape back to its original shape.   Setsh stands for "set shape."   Be sure to use just one quotation mark before the name of the shape.   (If you have used a different name for your shape, use that same name here.)

  3. Draw or import ball shapes.   Name each ball shape for its sport.   (When you draw a baseball, name the shape baseball.)  

    If you wish, click on the "Shapes" button and copy and paste the balls from the Shapes page into shapes in your project's Shapes center.   The balls included with this project are used with: basketball, baseball, football, and soccer.

  4. You can include your visitor's answer in a sentence in the text box.  

    Insert char 32 places an empty space in the text box when needed.
    Place one quotation mark (") before each word you want to insert.   If you would like to include a string of words, place them in brackets.   You may also insert a punctuation mark such as an exclamation mark, like this:
    insert "!

  5. In the insist procedure, we use member? to see if the answer is one of the "members" of a list of sports.   If it is, we use stop to stop just the insist procedure, and we continue with the rest of the conversation procedure.   But if the answer is not a member of the list, then we ask the question again.   We will need to check this new answer again.   The word insist is the last command, and it is the name of this procedure.   This command sends us back to the beginning of the insist procedure again so that we can check the answer.   This procedure will keep on running until the visitor types one of the four words in the list.   You are "insisting" that the visitor answer the question with one of the sports in the list.

    A procedure which calls itself like this is called a recursive procedure.   Be sure that you always include a way to stop the procedure, or it will run forever!

  6. Write a procedure named Let's_talk_again! with one command: startup.   This will run the startup procedure again and will set the project back to its starting appearance if your visitor wants to have another conversation.

  7. Make a button named Let's_talk_again! and try it!




What If?
When you try out your conversation, what happens if you misspell a word in answering the questions about your favorite color or sport?
What happens if you answer with a sport that is not included in the list?


Challenge
Set up your own question-answer conversation where the critter responds to the actual answers of the user.


On Your Own - Project Ideas
Set up a question-answer conversation or a quiz where the user gets feedback on his or her answers.





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