How to make a quiz game

Get help using Construct 2

Post » Sat Feb 01, 2014 2:53 pm

Sure, you have different options for separation.

For example tag each question. (a new field for each line)
You could use a different z-index for different text files/subjects. (I think I would prefer that one)
You could use more than one array, one for each subject.
You could use one text file and use another separator to divide subjects and you'll save the info somewhere which x-index-range contains which subject.

Ofc depending on the way you separate the questions in your array(s), you must modify the algorithm that shows the questions.

You can also add a tag to questions for their difficulty level.
So a text file could look like this;
Question 1?;right answer;wrong answer 1;wrong answer 2; wrong answer 3;1
Question 2?;right answer;wrong answer 1;wrong answer 2; wrong answer 3;2
Question 3?;right answer;wrong answer 1;wrong answer 2; wrong answer 3;2
Question 4?;right answer;wrong answer 1;wrong answer 2; wrong answer 3;3

1 would be easiest, 2 easy, 3 normal, and so on...

And then let the game increase the difficulty over time.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sat Feb 01, 2014 3:34 pm

By means of tokenat you can make tons of self made array approaches.

simple approach:

a text variable:

you can create an array by using a comon character like a comma or pipe sign on which you can itterate through the sections.

like

text = 1,2,3,4,5,6,7

tokenat arrays start counting at 0, so keep that in mind.

tokenat(text, 0 , ",") = 1   
tokenat(text, 1 , ",") = 2   
etc


This would all be sinle level arrays without keys, but straight up pieces of content.

Extending this, making each piece alse have a list of options by means of a different comon character.

text = 1,2,3,4 | 5,6,7,8,9 | 45,46,47


This takes the second chunk of data from text:

tokenat(text, 1, "|") = 5,6,7,8,9


now, if I want the 8 from the second chunk of data, we simply nest the tokenat calls:

tokenat(tokenat(text, 1, "|"), 2, ",") = 7

tokenat(tokenat(text, 1, "|"), 3, ",") = 8

tokenat(tokenat(text, 1, "|"), 4, ",") = 9



this way it references single pieces from the second chunk, but you could easily loop through it:

for each "looptokes"
from: 0
to: tokencount(tokenat(text, 1, "|"), ",")

create text,
set text tokenat(tokenat(text, 1, "|"), loopindex ,",")


With the above approach, if you keep a uniform structure, like adding a question type first, then a question, then which of the following anwsers is correct, then some awnsers: either one or more. You have a full system that can dynamically expand as you add more.
Or you could use objects having a text variable with these sets.

example:

obect questiontext, has instance variable awnser int()
obect awnsertext, has instance variable awnser int()

textvariable = multiplechoicetext,which is faster,0,train,horse,man|multiplechoiceimage,which color is red,2,image0,image1,image2,image3|inputquestion,how many cm are in a M,0,100


The above variable shows examples of 3 type of questions.

Looping through them with
for each "looptokes"
from: 0
to: tokencount(textvariable, "|")

sub of loop
compare 2 variables
tokenat(tokenat(textvariable, loopindex, "|"), 0 ,",")
equals
"multiplechoicetext" : action spawn questiontext, set text: tokenat(tokenat(textvariable, loopindex, "|"), 1 ,",") //Set question
set questiontext instance variable awnser: tokenat(tokenat(textvariable, loopindex, "|"), 2 ,",") // Text instance variable now holds correct awsner

set tempvariable: tokenat(textvariable, loopindex, "|") //use a temp to avoid loopindex issues in the next loop

sub of compare

for each loop to create the questions awnsers:
from: 3 // First three entries were type, question and awnser
to: tokencount(tempvariable, ",")

action: spawn awnsertext, set text = tokenat(tempvariable, loopindex, ",") // sets the questions
set awnsertext instance variable awnser: loopindex


Onclick awnsertext
compare 2 variables
questiontext.awsner
equals
anwerstext.awnser

action: awnser correct


else: action: incorrect




A bit advanced, but can work really well without any further extras.









lennaert2014-02-01 15:40:01
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,592

Previous

Return to How do I....?

Who is online

Users browsing this forum: Diamond Dino 64 and 3 guests