Trivia Game

Get help using Construct 2

Post » Mon Jan 14, 2013 12:40 pm

Hi everyone!

I am struggling to set up a simple trivia game. I am struggling with Text Boxes and Text objects and how to set local and global variables.

I assume the Text Object where a Question would be held would have instance variables with actual questions.

I just need an example of how to then pass a value from the Text box into a global variable and do an if, then check and display correct or not.

Finally a randomizer function to mix up the question order on each play.
B
5
S
1
Posts: 16
Reputation: 790

Post » Mon Jan 14, 2013 11:41 pm

I have something working, but the tracking questions already asked is a bit buggy. Let me fix that either tonight or tomorrow (my sense of logic is out the window right now) and I'll put it up for you. If you want as is, let me know.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Tue Jan 15, 2013 12:47 am

That would be great! I will take either. I appreciate the effort and look forward to seeing it! It is much appreciated as I am a new designer and want to thank you much.
B
5
S
1
Posts: 16
Reputation: 790

Post » Tue Jan 15, 2013 1:27 am

TRIVIA GAME

Hope you can understand most of it. I wouldn't setup a trivia game like that since there'd probably be well over 100 questions, but just did it that way to show you how arrays work for something like this. I'll probably look into getting AJAX to load a questions file and go from there, once the jumbling part is fixed so it doesn't ask the same questions.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Tue Jan 15, 2013 1:32 am

To explain quickly..

Questions array holds the questions (index 0 - 4)
Answers array holds the answers (array index 1 - 4, question index)
Answers array (0, question index) holds the correct answer which is referred to later on.

TrackQuestions array stores each question's array index when a question is asked. This should be looped through to make sure the current ranom question isn't already asked but is flawed. I tried different methods so the code looks a mess there. Just ignore that. I'll fix it when I don't have so much on the go ;p

The textbox that shows WRONG and CORRECT, also shows debugging info in the QuestionsTracked array.procrastinator2013-01-15 01:33:51
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Tue Jan 15, 2013 2:01 am

I tried to open the Capx file and it wont open as it says its from a newer version greater than r114.
B
5
S
1
Posts: 16
Reputation: 790

Post » Tue Jan 15, 2013 2:11 am

Download r115.

I've never had a problem with it, even if it is beta. You can install to a different directory to the stable release anyway.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Tue Jan 15, 2013 2:22 am

Thank you again! The new version loaded the project. I will check it out and I very much appreciate your help! Is there a way to create a global variable to make a score?

I assume I can add up to as many questions as long as I dont go over 100 events?
B
5
S
1
Posts: 16
Reputation: 790

Post » Tue Jan 15, 2013 2:41 am

No problem!

Yep. Adding questions won't affect how many events you have since storing in the array is actions, not events ;) Although I wouldn't want to be you adding questions in that manner. I'll get AJAX loading done probably tomorrow as it's a simple thing really, but still takes a bit of time. It'll make it much easier to add your own questions in a text file. I wouldn't mind having an engine like this anyway ;)

You can add a score very easily.

global variable score = 0

Then where it changes the text box to "CORRECT!" just add 1 to the score and go from there.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Tue Jan 15, 2013 2:43 am

Your very helpful and I again thank you! If i can offer something back to you since your developing the ajax version with the score function. I write instrumental music, you are free to use any of it license free in your work. The entire catalogue is at http://kevinyoutube.com and I can email you the tracks you like.
B
5
S
1
Posts: 16
Reputation: 790

Next

Return to How do I....?

Who is online

Users browsing this forum: MarkThomas and 17 guests