How do I randomize questions in a quiz game?

Get help using Construct 2

Post » Thu Mar 13, 2014 2:15 pm

I am trying to make a quiz game for kids with construct 2 for an assignment.
The client wanted to randomize the questions so the order of questions is always random.
I would like to know if it's possible to do this with construct 2. I have tried to Google it but I couldn't find any examples.

Any help is greatly appreciated!
B
3
Posts: 9
Reputation: 195

Post » Thu Mar 13, 2014 2:22 pm

Sure it's possible.
One solution:
Create a text object (or SpriteFont, whatever you prefer).
Make as many instances of this object as you need questions.
and then System-> Pick Random Text
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Thu Mar 13, 2014 2:30 pm

Thank you for your quick reply.

I don't have time to test this today anymore, but I will tomorrow and will get back to you if it worked.
B
3
Posts: 9
Reputation: 195

Post » Thu Mar 13, 2014 2:33 pm

I would use a 1D array. Each value containing the ID of the question.


Setting up the array:

On start of layout

-array for each element X

-set X value at array.CurX to array.CurX


Choosing a random question:

question=round(random(array.width))

if question=0 ... array delete index 0 on X axis / set text "Question one?"

if question=1 ... array delete index 1 on X axis / set text "Question two?"

if question=2 ... array delete index 2 on X axis / set text "Question three?"

if question=3 ... array delete index 2 on X axis / set text "Question four?"


And so on. You delete each question out of the array because you don't want it to appear more than once.
B
10
S
2
Posts: 135
Reputation: 1,090


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests