Académique Documents
Professionnel Documents
Culture Documents
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:
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.
#1
AuraPuppeteer of Hail
Joined:
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.
#2
johnwoMember
Joined:
Posts:
142
Code:
questionCount = 0;
questions = ds_list_create();
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!
#3
GituMember
Joined:
Posts:
17
#4
GituMember
Joined:
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
#5
FredrikMember
Joined:
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.
#6
Help
Home
Top
RSS
Terms and Rules
Privacy Policy
Forum software by XenForo 2010-2017 XenForo Ltd.
PASTEBIN
new paste
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
Share on Facebook!
Top