• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Don't repeat the same question (Quiz game)

G

Gitu

Guest
Hello GMC.

I'm trying to make a quiz game, but I've stumbled across a problem wherein sometimes, the same question appears, even if it already appeared earlier.

I need some help so that, if the question already appeared and got answered (either right or wrong), it will never appear for the rest of the test until the game is replayed.

I don't have sprites yet as I am testing questions using text drawing, once I get this fixed I can start making real questions.

NOTES:
  • Since it's only testing, the press <ctrl> event simulates the question being "answered"; but in the actual game, it will be replaced by the answer button objects, which the press ctrl event simulates.
  • I use variable q_randomizer to pick random numbers, these numbers represent questions.

You can find my sample code in this PasteBin link: http://pastebin.com/tApJ8L9y
 
A

Aura

Guest
I'd suggest putting that sort of data in a DS list that you can retrieve it from when needed and delete that particular index from the list, so that the same question doesn't get asked again.
 

johnwo

Member
This is a much better approach, as opposed to what you're doing:

In the create event:
Code:
randomize(); // Randomize the randomizer seed

questionCount = 0;
questions = ds_list_create();

questions[| questionCount++] = "Question "+string(questionCount );
questions[| questionCount++] = "Question "+string(questionCount );
questions[| questionCount++] = "Question "+string(questionCount );
questions[| questionCount++] = "Question "+string(questionCount );
questions[| questionCount++] = "Question "+string(questionCount );
questions[| questionCount++] = "Question "+string(questionCount );

ds_list_shuffle(questions);
questionCurrent = 0;
In the alarm event (go to next question):
Code:
questionCurrent++;
In the draw event:
Code:
draw_text(x,y,questions[| questionCurrent]);
This is a better approach, as you'll be able to add questions just by adding questions[| questionCount++] = "SomeQuestion"; in the create event.
Saves a lot of typing, and easier to manage.

Hope it helps!

Cheers!
 

Fredrik

Member
I'd give each question a variable set by default to zero, and if the question have appeard it'll be one (?) depends how many questions you have tho.
 
Top