I'm trying to create this Math Quiz project where I construct a sprite to move around randomly ten times. In order to win, I want the users to have to touch the sprite at least 3 times while it moves randomly and answer three simple math questions and give the sum total at the end. Whenever the mouse pointer touches the sprite, I want the sprite to say one of three things: 1) Add (any random number ranging from -10 to 10), 2) subtract (any random number ranging from -10 to 10) or 3) multiply (any random number ranging from -5 to 5).
I want the Sprite to be able calculate the total after being touched by the mouse pointer and randomly assigning 3 random operations (add, subtract, or multiply a random number). When the user puts in the correct answer, I want the sprite to be able to tell the user if his/her answer is right or wrong. If right, I want the sprite to say, "Correct!" and ask the user to advance to the next level (I'd use broadcasting here I suppose?). If the user's answer is wrong, I want the sprite to say "Wrong! Try again!" and start all over again.
I'm having a lot of difficulty creating the correct variables for this and getting the sprite to follow these commands. If someone could give me the step-by-step commands for this, I would greatly appreciate it!
Offline
For the math problems, you could use something like this:
set [level v] to (1) repeat until <(level) = (4)> if <(level) < (3)>//Picks the numbers for the problems. set [number v] to (pick random (-10) to (10)) set [number2 v] to (pick random (-10) to (10)) else set [number v] to (pick random (-5) to (5)) set [number2 v] to (pick random (-5) to (5)) end if <(level) = (1)> ask (join(join(join [What is ] (number)) [ + ]) (join (number2) [?])) and wait if <<(number) + (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) end else say [Wrong. Try again.] end else if <(level) = (2)> ask (join(join(join [What is ] (number)) [ - ]) (join (number2) [?])) and wait if <<(number) - (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) end else say [Wrong. Try again.] end else ask (join(join(join [What is ] (number)) [ x ]) (join (number2) [?])) and wait if <<(number) * (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) end else say [Wrong. Try again.] end end end endSorry about only giving the script. If there's any part of it that you don't understand, just ask and I'll explain it.
Offline
This would require several changes, so again, sorry about only giving the script:
when gf clicked set [level v] to (1)
if (touching [mouse pointer v]?) set [number v] to (pick random (-10) to (10))//This is here to make the script work. repeat until <(number) = [P]> if <(level) < (3)>//Picks the numbers for the problems. set [number v] to (pick random (-10) to (10)) set [number2 v] to (pick random (-10) to (10)) else set [number v] to (pick random (-5) to (5)) set [number2 v] to (pick random (-5) to (5)) end if <(level) = (1)> ask (join(join(join [What is ] (number)) [ + ]) (join (number2) [?])) and wait if <<(number) + (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) set [number v] to [P] end else say [Wrong. Try again.] end else if <(level) = (2)> ask (join(join(join [What is ] (number)) [ - ]) (join (number2) [?])) and wait if <<(number) - (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) set [number v] to [P] end else say [Wrong. Try again.] end else ask (join(join(join [What is ] (number)) [ x ]) (join (number2) [?])) and wait if <<(number) * (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) set [number v] to [P] end else say [Wrong. Try again.] end end end end endI hope that this helps!
Last edited by ErnieParke (2012-11-04 09:17:54)
Offline
ErnieParke wrote:
This would require several changes, so again, sorry about only giving the script:
when gf clicked set [level v] to (1)forever if (touching [mouse pointer v]?) set [number v] to (pick random (-10) to (10))//This is here to make the script work. repeat until <(number) = [P]> if <(level) < (3)>//Picks the numbers for the problems. set [number v] to (pick random (-10) to (10)) set [number2 v] to (pick random (-10) to (10)) else set [number v] to (pick random (-5) to (5)) set [number2 v] to (pick random (-5) to (5)) end if <(level) = (1)> ask (join(join(join [What is ] (number)) [ + ]) (join (number2) [?])) and wait if <<(number) + (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) set [number v] to [P] end else say [Wrong. Try again.] end else if <(level) = (2)> ask (join(join(join [What is ] (number)) [ - ]) (join (number2) [?])) and wait if <<(number) - (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) set [number v] to [P] end else say [Wrong. Try again.] end else ask (join(join(join [What is ] (number)) [ x ]) (join (number2) [?])) and wait if <<(number) * (number2)> = (answer)>//Checks the answer. ask [Correct! Do you want to move on? (Y/N)] and wait if <(answer) = [Y]> change [level v] by (1) set [number v] to [P] end else say [Wrong. Try again.] end end end end endI hope that this helps!
Need that forever.
Offline