Vous êtes sur la page 1sur 7

Log in or Sign up

Forums > GameMaker > Programming >

1. This site uses cookies. By continuing to use this site, you are agreeing to
our use of cookies. Learn More.
Don't repeat the same question (Quiz game)
Discussion in 'Programming' started by Gitu, Aug 12, 2016.

1.
GituMember

Joined:

Aug 12, 2016

Posts:

17

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:

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

Gitu, Aug 12, 2016

#1

AuraPuppeteer of Hail

Joined:

Jun 22, 2016

Posts:

1,426

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.

Aura, Aug 12, 2016

#2

johnwoMember

Joined:

Jun 20, 2016

Posts:

142

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!

johnwo, Aug 12, 2016

#3

Gitu likes this.

GituMember

Joined:

Aug 12, 2016

Posts:

17

It surely helped a lot, johnwo! Thanks a lot!

Gitu, Aug 12, 2016

#4

GituMember

Joined:

Aug 12, 2016

Posts:

17

By the way, if anyone is planning on making a geography game, I'll be sharing my code that
involves every country (+some disputed territories and dependencies)

HERE: http://pastebin.com/WF2kXqps

Gitu, Aug 12, 2016

#5

FredrikMember

Joined:

Jun 21, 2016

Posts:

123

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.

Fredrik, Aug 12, 2016

#6

(You must log in or sign up to reply here.)

Share This Page

Forums > GameMaker > Programming >


Forums
o Recent Posts
YoYo Games
Helpdesk
Dark Skin (Default)

Help
Home
Top
RSS
Terms and Rules
Privacy Policy
Forum software by XenForo 2010-2017 XenForo Ltd.

PASTEBIN
new paste

trends API tools faq

Guest User
-

Public Pastes
Untitled29 sec ago
Untitled31 sec ago
Untitled35 sec ago
Untitled39 sec ago
Untitled44 sec ago
Nexusfont45 sec ago
Untitled47 sec ago
FRIDAY DAY 25-8-1749 sec ago
SHARE

TWEET

Untitled
A GUEST AUG 12TH, 2016 110 NEVER

Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

rawdownloadcloneembedreportprinttext 0.85 KB
1. Create Event:
2.
3. execute code:
4.
5. q_randomizer = 0;
6.
7. //List of questions
8. q1 = "question 1"
9. q2 = "question 2"
10. q3 = "question 3"
11. q4 = "question 4"
12. q5 = "question 5"
13. q6 = "question 6"
14.
15.
16. Alarm Event for alarm 0:
17.
18. execute code:
19.
20. q_randomizer = irandom(6);
21.
22. Draw Event:
23.
24. execute code:
25.
26. if (q_randomizer = 1) {
27. draw_text(x,y,q1)
28. } else
29. if (q_randomizer = 2) {
30. draw_text(x,y,q2)
31. } else
32. if (q_randomizer = 3) {
33. draw_text(x,y,q3)
34. } else
35. if (q_randomizer = 4) {
36. draw_text(x,y,q4)
37. } else
38. if (q_randomizer = 5) {
39. draw_text(x,y,q5)
40. } else
41. if (q_randomizer = 6) {
42. draw_text(x,y,q6)
43. }
44.
45. Key Press Event for Key:
46.
47. execute code:
48.
49. //"Question being answered" simulation
50. //Insert if statements about right or wrong answers in the final version
51.
52. //Set alarm that randomizes
53. alarm[0] = 15

RAW Paste Data


Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!

create new paste / dealsnew! / api / trends / syntax


languages / faq / tools / privacy / cookies / contact / dmca / scraping / go
Site design & logo 2017 Pastebin; user contributions (pastes) licensed under cc by-sa 3.0 -- Dedicated Server
Hosting by Steadfast

Share on Facebook!
Top

Vous aimerez peut-être aussi