Difficulties getting random without duplicates

0 favourites
  • 3 posts
From the Asset Store
In this template the music plays without looping in your game
  • Hi everyone !

    I know that the question I'm going to ask has already been asked several times. I've tried the techniques I found on the forum, but the way I want to randomize my data is a bit more complicated (I guess it's not, but I can't figure out what I'm doing wrong).

    First, I'm new to game programming and I'm probably making terrible mistakes, please forgive my incomptence.

    What I want to do

      I want to make a trivia game that takes the form of several mini-games. But that is not important. I want to load the questions (and their related answers) from an external .txt and randomize them in a way that the same question doesn't appear twice.

    I get the logic behind both techniques :

      I successfully get my questions and answers from the .txt I successfully randomize them I don't manage to avoid duplicates

    Here is a link to my .capx : drive.google.com/file/d/0B8I4fWcKPnzhZDVoMXdsbzdtTk0/view?usp=sharing

    If someone can help me in another way than giving me a link to the following tutorials, I would be grateful forever.

      randomize-array_p587279?#p587279 how-do-i-get-a-random-nr-not-to-repeat_p808042?#p808042

    Thank you.

    Edit : sorry for the links, it seems like I don't have the permission to post well-formated URLs.

    Edit2 : ok now I understand why I can't post URL.

  • Sorry none of your links work.

    But, this is how you do it. In the tutorial section there are a number examples on random, none duplicates using array.

    So the array randomizes pulls a number and deletes the number (so impossible to get duplicate)

    You now have a number. Use that number to get your question from txt however you do that.

    Edit: okay you put links in

    What you want is to have array for numbers (number questions you trying to randomize) have that array in a function that spits out the number, which is deleted as I said previously.

    Use that number to fetch your questions.

    Or shuffle it into array at start of game, then delete on at a time

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for you answer DUTOIT.

    I'll try to focus and get this thing done, I've spent hours testing stuff...

    Edit: Finally got it! Thanks DUTOIT, your explanation helped me to see what I was doing wrong.

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