How do I randomize answer order in a trivia game

0 favourites
  • 5 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • I know I should post my file but have not gotten 300 reputation points so cannot post image or file however, I am stymied. I have my Q&A game done and working - questions randomize but I am now trying to randomize the answers i.e. appear in a different order than imported. I have tried different techniques such as using a temp array, loading numbers in randomly (between 1 and 4) and using it to load the answer choices but have not gotten that far - seems I get caught in an infinite loop and without the paid version, not sure where it is getting stuck.

    I am going to buy the personal license which will help debugging but wondering if there are any ideas and/or tutorials that someone can point me to (I have search a lot and have come up with shuffling arrays etc... but when I try to incorporate. still getting stuck). I will re-post with file once able but have been struggling for over a week and just looking for some direction.

    Thanks!

    Bill

  • jbcreger2

    if your array looks like this

    I think this is the simplest way

    randomizeAnswerOrder.capx

    so... if you set the first answer is always the correct answer

    after you randomize question order capx should look similar to this

    Example.capx

    EDIT:

    if you use sprite for answers...basically its the same thing..

    just one "spriteAnswer"..write frames in array and set variable correctAnswer to number

    randomizeAnswerFrames.capx

    EDIT2: ...that is one way.

    .if you have specific frames as answers and just want to randomize frames position...

    another way is if you want to set one correct frame and three random frames..

    you can then use one dimensional array for questions

    just be sure your "spriteAnswer" frame 0 is correct answer on first question- Array.At(0),

    frame 1 is answer on Array.At(1) etc...

    and use another array for frames...

    Example2.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for your response - right now I have the questions reading into the array as rows (each question/answer set is its own row). Is there any advantage (or disadvantage) in importing my questions so that each question/answer set is its own column as indicated in your example?

    Thanks again for your help!

    Bill

  • ...I am now trying to randomize the answers i.e. appear in a different order than imported. I have tried different techniques such as using a temp array, loading numbers in randomly (between 1 and 4) and using it to load the answer choices but have not gotten that far...

    Is there any advantage in importing my questions so that each question/answer set is its own column as indicated in your example?

    Yes..you can easily randomize answers..

    and you would noticed that..if you've looked at any of the four examples that I set here...

  • AFAICT there's no difference between using rows or columns, unless you want to be compatible with the code example already given. You could stick with rows, but you'd have to rework the example code to accommodate that.

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