This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-08-15 01:02:14

Meian
Scratcher
Registered: 2009-08-13
Posts: 3

How to do Multiple Choice Answers to a Question

Hello,

I tried asking this in the newbie section but now that I think about it it may have been an inappropriate place to ask this type of question. Hoping here will work better.

I saw a video of Human Body RPG and rather enjoyed how it used a game to help learn the human body in the form of questions.

I wished to do something similar and have been using another video to help me get started.

My question is how do you create questions with multiple choice answers during a rpg action (similar to how the Human Body RPG did with choosing an attack/spell or enemy attacking). I downloaded the project to try to interpret what was done but found it a bit more complicated than I imagined. I have mostly the rest down besides this ;;

The video of the Human Body RPG is here: http://www.scratch.mit.edu/ext/youtube/?v=13Sa2AMBRh8&NR=1

--Diego

Offline

 

#2 2009-08-15 01:18:12

WeirdF
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: How to do Multiple Choice Answers to a Question

Just ask the question, and then do this:
[blocks]
<if><( answer <=> << <<  <or>  >> <or> <<  <or>  >> >> )>
[/blocks]
Just put the possible answers in the spaces.


http://i.cr3ation.co.uk/dl/s1/gif/847032b8a331def77529b6a0384db1fe_handfingers.gif

Offline

 

#3 2009-08-15 01:46:07

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: How to do Multiple Choice Answers to a Question

I made this kind of game a while ago in flash http://entrepreneurparty.co.nr/

Its not too difficult. First thing you need to do is make a box with the questions and answers like in the video. Each costume in the box will have a question then multiple choice answers. The answers to these questions (a,b,c, or d) are keep in a list.  The costume number of the question box sprite is the number of the value in your list of answers that corresponds with the question being shown. You also want to have 4 sprites with ghost set to 100 (invisible) that go over the questions and these will be what the user clicks to enter a answer.

Here is the code you should put on the questionbox sprite

When I recieve (ask question){
show
set costume to random (0 to length of list answers) //Pick  a random question
set useranswer to 0 //a blank value, don't use blank spaces, it messes scratch up
wait until not( user answer=0) // This means the user has chosen an answer
if user answer= item costume num of list (answers){
set correct to 1 //1 means true and 0 means false
}
else{
set correct to 0 }
hide
}

Last edited by archmage (2009-08-15 01:46:31)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#4 2009-08-15 14:59:58

Meian
Scratcher
Registered: 2009-08-13
Posts: 3

Re: How to do Multiple Choice Answers to a Question

Thanks for the responses thus far.

WeirdF, you mention putting them in the spaces but not quite sure what to put in the other 4 after the answer.


archmage, your advice has helped well but I am a bit stuck. I have made a question sprite with two costumes so far then made 4 seperate sprites as small black squares with ghost 100 overlapping where a, b, c, d would be. I attempted to put in the code you suggested and I am unsure if I did it correctly:

<when I receive[ ask question ]
<show>
<switch to costume[ <pick random( 1 )to( 2 )
<set{ useranswer }to( 0 )
<wait until><<  <not>  >><( <{ useranswer }> <=> 0 )>
<if><( useranswer <=> not sure what you mean here )>  ******
<set{ correct }to( 0 }
<hide>

I think one of the issues is the variables such as "useranswer." I know of variables in counters such as scoring but not quite sure what you meant here. There is also the matter of the clicking of answers ;;

Sorry for the questions and trouble,

--Diego

Offline

 

Board footer