0 Favourites

How do I randomize questions in a quiz game?

  • 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!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)