How do I prevent a trivia game from showing duplicate questions?

0 favourites
  • 4 posts
From the Asset Store
Firebase Leaderboard
$2.50 USD
50% off
A small template showing how to build a firebase ranking
  • Hi,

    I'm building a trivia game based off of this tutorial: construct.net/en/tutorials/trivia-game-929/page-2

    I've customized the events a bit, but basic functionality for pulling random questions is the same. However I'm having trouble figuring out how to prevent it from pulling the same question more than once.

    Right now the game pulls a random question and displays it, but sometimes it will pull the same question up 2 or 3 times in a single game, which isn't ideal.

    I did some searching and learned that I could have a question deleted after it was shown, so it wouldn't be pulled up more than once:

    (-> QuestionArray: Delete index randomNumber from X axis)

    But when I put that code in only the first question shows and then the rest are blank.

    Then I found info that said I should reduce the width of the Array by 1 to have the Array table resize to where it wouldn't pull blank spaces where answers used to be:

    (-> QuestionArray: Set size to (-1, 1, 1))

    But it didn't work. So I'm stumped and wondering if anyone else has any insight. This is day 2 after searching & trying different things & reading the manual.

  • The array method should work, but you could also use a permutation table from the Advanced Random object so you don't need to rebuild the array.

    Hope this helps...

    Cheers!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you, but I'm having trouble understanding that. I'm still new to Construct so maybe its a little over my head.

  • Hey desriix!

    I was away for a while, since it was Carnival here in Brazil.

    A permutation table is a randomly ordered list of values with one ocurrence of each value only. For instance, a permutation table with 6 values could look like [1,3,0,5,2,4]. So, if you get the permutation table values in order (1, then 3, then 0...) and use them as indexes for your questions array, you would be actually getting all questions in the array without repetition, in a random order. Is it clear?

    Check this example and let me know if you have any doubts.

    Cheers!

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