I am trying to make a simple quiz with a character asking a question and the player pressing a or b to choose an answer. If the answer is right I want it to go to the next question but if it is wrong I want it to stop the game so the player can follow the instructions they recieve when the answer is wrong.
I am having problems sequencing things correctly. This is the first time I have used scratch and when I try to sequence and question then a script such as "when a is pressed say: ...." everything keeps going out of order when I play the game.
Any suggestions?
Project: Bio game
Author:
Scratch: 1.4 of 30-Jun-09
History:
2012-10-1 17:18:12 save Bio game
2012-10-1 18:12:40 save Bio game
2012-10-1 18:15:33 save Bio game
2012-10-1 18:17:07 save Bio game
2012-10-1 20:31:58 save Bio game
2012-10-1 20:54:55 save Bio game
2012-10-1 21:09:00 save Bio game
2012-10-1 21:20:51 save Bio game
2012-10-1 21:28:58 save Bio game
2012-10-1 21:57:51 save Bio game
Totals:
Sprites: 1
Stacks: 7
Unique costumes: 2
Unique sounds: 1
--------
Sprite: Stage
Costumes (1):
background1 (480x360)
Sounds (1):
pop (0:00:00)
No stacks.
--------
Sprite: teacher
Costumes (1):
costume1 (117x199)
Sounds (0):
Stacks (7):
when b key pressed
say "Correct!" for 2 secs
end
when a key pressed
say "Please review link and try quiz again:http://www.tumblr.com/blog/mspoole" for 20 secs
stop all
end
when b key pressed
say "Correct!" for 2 secs
say "Which organelle allows plants to photosynthesize? Press a for vacuole press b for chloroplast" for 30 secs
end
when green flag clicked
move 0 steps
say "Today we are going to ask some questions about cells and their organelles. Lets see how much you all know!" for 4 secs
say "Which organelle is responsible for protecting the DNA in the cell? Press a for nucleus, press b for cell wall." for 30 secs
end
when b key pressed
say "Please review link and try the quiz again:http://www.tumblr.com/blog/mspoole" for 20 secs
stop all
end
when a key pressed
say "Correct!" for 2 secs
say "Which organelle makes the proteins essential for the cell to function? Press a for nucleus press b for ribosome." for 20 secs
end
when a key pressed
say "Please review link and try the quiz again:http://www.tumblr.com/blog/mspoole" for 20 secs
stop all
end
--------
Offline
Welcome to Scratch!
In programming in general, you need to think like the computer. Imagine you're giving a complete and total idiot instructions. The computer knows nothing, makes no assumptions; if you don't tell the computer exactly what to do it won't do it.
In this case, you need to think. What is the first thing the teacher needs to do? Ask the question. Therefore, you need to ask the question first.
when gf clicked say [Question 1: What is red and bad for your teeth?] for (5) secsWhat then, you ask? Your players need to know what they're answering. In any TV show, before asking "A or B" they say what a and b correspond to. So, following this:
when gf clicked say [Question 1: What is red and bad for your teeth?] for (5) secs say [A: A brick OR B: An alarm clock] for (5) secsSo what then? Well, they're presented with two options. A or B. Only after you have told the question should you expect an answer. So, from this logic, we add the answers to the code.
when gf clicked say [Question 1: What is red and bad for your teeth?] for (5) secs say [A: A brick OR B: An alarm clock] for (5) secs if < key [a v] pressed? > say [Correct!] for (2) secs end if < key [b v] pressed? > say [Wrong. Bye.] for (2) secs. stop script endSo you may think it's all done now. Let's have one last check, and read as a computer would. So, when the green flag is clicked:
when gf clicked say [Question 1: What is red and bad for your teeth?] for (5) secs say [A: A brick OR B: An alarm clock] for (5) secs wait until < < key [a v] pressed? > or < key [b v] pressed? > > if < key [a v] pressed? > say [Correct!] for (2) secs end if < key [b v] pressed? > say [Wrong. Bye.] for (2) secs. stop script endSo now the computer waits until we press A or B, and then checks which one it is.
Offline
jmpoole wrote:
So how do i sequence three questions per level? I understand how to do one question but now I am confused how to make multiple questions flow correctly and how to make multiple levels??
Here:
when gf clicked set [questionNumber v] to [0] add [q1] to [questions v] add [q2] to [questions v] add [q3] to [questions v] add [a1a] to [answersA v] add [a1b] to [answersB v] add [a2a] to [answersA v] add [a2b] to [answersB v] add [a3a] to [answersA v] add [a3b] to [answersB v] broadcast [start v] when I receive [start v] change [questionNumber v] by (1) if <(questionNumber) > [3]> say [End of quiz.] stop all else say (item (questionNumber) of [questions v]) for (5) secs say (item (questionNumber) of [answersA v]) for (5) secs say (item (questionNumber) of [answersB v]) for (5) secs wait until < < key [a v] pressed? > or < key [b v] pressed? > > if < key [a v] pressed? > say [Correct!] for (2) secs end if < key [b v] pressed? > say [Wrong. Next question.] for (2) secs broadcast [start v] end end
Offline