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

#1 2010-06-20 00:44:00

minadoan
Scratcher
Registered: 2010-06-06
Posts: 10

Algorithm

Firstly, thanks for supporting me :-) I have somehow finished my Scratch beautifully.
I just want to ask:

If I create a list of questions and ask them (in the game), do i need to write the algorithm for EACH question? If not, do I just write :

    WHILE     Ask Round 1 question
        IF answer =  Round 1 result THEN
                  Change round 1 score by 1
        END IF
    END WHILE
    WHILE    Ask Round 2 question
        IF answer = Round 2 result THEN
                  Change round 2 score by 1
        END IF
    END WHILE

Thanks :-)

Offline

 

#2 2010-06-20 13:32:07

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Algorithm

I think you'd just need to repeat it until all the questions have been answered, rather than repeating it for each question. Make a variable for what question you're on, and change it every time they get the question right; you won't need to repeat the algorithm for each question. For instance:

Code:

When Green Flag clicked
set [question#] to (1)
repeat until <(question#) = ((length of [questions]) + (1))>
  ask (item (question#) of [questions])
  if <(answer) = (item (question#) of [answers])
    change [question#] by (1)
  end if
end repeat

That should continue until all the questions have been exhausted, and repeat the questions if the answer is wrong.

Does that help? I made a project for you with the same general nature, if you'll remember: http://scratch.mit.edu/projects/coolfixit/1108959.

Also, this doesn't seem to belong in Troubleshooting - I'll move it over to All About Scratch for you.

Offline

 

Board footer