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

#1 2012-05-17 16:24:31

Gary-Tyler
New Scratcher
Registered: 2012-05-17
Posts: 1

Math Game

I have created a pretty simple math game for my class. all i need is a script that will help me shuffle the answers so the answer isnt always in the same place. PLEASE HELP!!!!!

Offline

 

#2 2012-05-17 18:22:05

poemon1
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Math Game

First of all, is it a sprite, or stored in a variable/list?


http://i47.tinypic.com/rrqe13.gif

Offline

 

#3 2012-05-17 20:31:10

parcheesidude
Scratcher
Registered: 2009-10-07
Posts: 500+

Re: Math Game

EDITING

I think you need:

[scratchblocks]
repeat (question)


My signature is trying to find itself :3

Offline

 

#4 2012-05-17 22:22:45

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Math Game

Let's say you have the questions stored as elements in a list.  If you want to shuffle them, do something like this. 

when I receive [shuffle v]
delete (all v) of [QuestionCopies v] // Stores a copy of the questions
delete (all v) of [QuestionRandom v] // Stores a randomly-ordered set of questions
set [i v] to [0]
repeat (length of [Questions v]) // Copies the questions to a new list
change [i v] by (1)
add (item (i) of [Questions v]) to [QuestionCopies v]
end
repeat until <(length of [QuestionCopies v]) = [0]>
set [InsertIndex v] to (pick random (1) to (length of [QuestionCopies v]))
add (item (InsertIndex) of [QuestionCopies v]) to [QuestionRandom v]
delete (InsertIndex) of [QuestionCopies v]
end

Offline

 

#5 2012-05-21 03:03:23

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Math Game

Did that work for you?

Offline

 

#6 2012-05-21 06:27:23

poemon1
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: Math Game

If it's in a variable, do:

when gf clicked
set [Varrandom v] to (pick random (1) to (# of questions))
if <(Varrandom v)=(number)> 
ask [question] and wait
end
And repeat for all of your questions.

Last edited by poemon1 (2012-05-21 06:27:45)


http://i47.tinypic.com/rrqe13.gif

Offline

 

Board footer