Advice needed for quiz game

For questions about using Classic.

Post » Sun Aug 01, 2010 9:50 pm

I want to create a quiz game.Here is how i want to do it.I must type the correct answer into the text box and after i typed the answer into the text box i have to click a button.After i pressed the button the game must show me if the answer is correct or not.Please tell me how to do this.Im creating a maths game for my son , please help.
B
22
S
3
G
6
Posts: 1,356
Reputation: 7,141

Post » Sun Aug 01, 2010 10:23 pm

If it's just simple maths questions like addition and multiplication then it'd just be a case of taking the values and comparing the expression to the value that is in the text box when the button is pressed.

I've not got construct installed atm so can't really throw anything together but I imagine this is really simple to do if you use a couple of text objects to display your numbers... but of course it depends how complex the whole thing needs to be, a more detailed description of what you have in mind will be useful to anyone who might help
B
15
S
6
G
6
Posts: 103
Reputation: 2,968

Post » Sun Aug 01, 2010 10:28 pm

You should have an array, INI, or hashtable of the correct answers. More specifically, the key words for the answer. Then when the user inputs their text and clicks the button you then parse the input text and check the text against your stored right answer.

For example, for the question, "What is the longest river in the world?" The answer, Nile will be stored in some type of data structure mentioned previously that is indexed to the question. When the user types their answer, use the text manipulator object to grab each input text and compare to "Nile". That way answers like, "the Nile" will be correct as well.

You can also do this with Python and regular expressions but I think you might be able to get by fine with just Construct objects.

Edit: Oh.. for math then just compare the integers etc...
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Mon Aug 02, 2010 2:23 am

I like Construct's TokenString system expressions for things like this. They are just string variables with different fields separated by some character or string. In this case, I'd use a TokenString with NewLine separators, where each field is another TokenString with a '|' separator, containing each question and answer pair.

I made a quick example of such a method, here:

[url:1biu5524]http://dl.dropbox.com/u/5868916/MathQuiz1.cap[/url:1biu5524]

It's not commented, and quickly written, but it should get the idea across. It's fairly dynamic, and can help keep the number of events down. If anything in it sparks your interest, and you have any questions, I'll check back when I have more time.

Basically, you can just double-click the text object above the layout, and enter each 'question|answer' pair on a new line in the popup editor, then run it to test it out. You can end the question list with a NewLine or 'END'.

Also, You can also just read 'enter key pressed' instead of using a button if you like.

It assumes all answers are numbers, and converts the strings to floating-point numbers. This can be a bit tricky, if you work with floats. This example uses the system expression FormatDecimal to round off the numbers, but I'm not sure that it works as I would expect it to. May just have to specify that all answers follow a certain format at the beginning of the quiz...

The data structures that scidave mentioned can also be used in much the same way, though setting them up may require more steps.
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Mon Aug 02, 2010 10:27 am

Wow! Thanks Silent that's exactly what i wanted. :mrgreen:
B
22
S
3
G
6
Posts: 1,356
Reputation: 7,141


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests