How do I make random questions

Get help using Construct 2

Post » Sun Jul 27, 2014 1:56 pm

Hello,

I am trying to make a game like freaking math but i have a problem. In this game you get questions like (1+2=3 or 1+1=4) and you have to say if they are true or correct. I was thinking to make more events and if the player answers correct to sent them to a random event with another question. But this would not be the best ideea becouse it will take me more than 100 events. Also i was thinkng to make more layers and say if layer X is visible & player press the correct button make layer invisible, make another layer visible and so on. But also this will take a lot of events and layers. Another ideea would be to make a spritefont and change the texts and compare the text to know if the answer is right or no.

All of those ideea would take lots of resources, do you have any other ideea?
Last edited by roteam on Sun Jul 27, 2014 2:13 pm, edited 1 time in total.
B
14
S
3
G
1
Posts: 69
Reputation: 950

Post » Sun Jul 27, 2014 2:01 pm

I'm not quite sure what you're asking - do you want to create randomly generated equations/sums?
B
59
S
21
G
10
Posts: 643
Reputation: 10,293

Post » Sun Jul 27, 2014 2:04 pm

Not necesarely randomly generated. All i want is an easyer way to make the game.
B
14
S
3
G
1
Posts: 69
Reputation: 950

Post » Sun Jul 27, 2014 2:11 pm

that's not random text,but random question each level/section
~Everyone can make GAMEs~
B
56
S
12
G
1
Posts: 414
Reputation: 5,911

Post » Sun Jul 27, 2014 2:14 pm

Hardty wrote:that's not random text,but random question each level/section

yup, my bad
B
14
S
3
G
1
Posts: 69
Reputation: 950

Post » Sun Jul 27, 2014 2:46 pm

Okay, I've just had a quick look at Freaking Math, it's pretty easy to pull off, here's the psuedo.

You're going to want a text that shows an equation, let's set it out like this:

"random(0,50) + random (0,50) ="

And a second text object that shows an answer that's either right or close to it:

"equation.sum+random(-5,5)"

And finally two buttons, a tick and cross.

If the user hits the tick, compare the answer with the equation sum, if it's equal +1 to score. If they hit the cross invert the check. An incorrect answer resets the score to zero. Either answer causes the event to loop so you get a new question.

This was all typed out in a hurry, please ask if you have any questions/ feel free to correct any errors!
B
59
S
21
G
10
Posts: 643
Reputation: 10,293

Post » Sun Jul 27, 2014 2:57 pm

Yes i have a question.
I do not need the text to show me "random(0,50) + random (0,50) =" this. So i made to this //int(random(0,50))& "+" & int(random(0,50)) & "=" //
Now this code will show me 23+4 (for example). But now how do i make the second text to actually make the sum between those numbers ? ( i did not got this part "equation.sum+random(-5,5)")
B
14
S
3
G
1
Posts: 69
Reputation: 950

Post » Sun Jul 27, 2014 3:01 pm

Should be relatively easy to create..

C2 can do math itself so you shouldn't even have that hard a time..
Easiest way would be to create a function to produce the "random" question..

Just a quick and dirty way of doing things, albeit not the best:

You could use global variables for the first, second, RightAnswer, WrongAnswer, RightOrWrong..

set global variable first to choose(1,2,3,4,5,6,7,8,9) (I prefer using choose instead of random, for I find it easier to manipulate)
set global variable second to choose(1,2,3,4,5,6,7,8,9)
set global variable RightAnswer to first+second
set global variable WrongAnswer to first+second+choose(-1,1)
set Global variable RightOrWrong to choose("Right","Wrong")

system compare global variable RightOrWrong = "Right"
set text to first&"+"&second&"="&RightAnswer

system compare global variable RightOrWrong = "Wrong"
set text to first&"+"&second&"="&WrongAnswer

Or something like that..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jul 27, 2014 3:19 pm

@LittleStain thank you
B
14
S
3
G
1
Posts: 69
Reputation: 950

Post » Tue Mar 24, 2015 4:34 pm

roteam wrote:@LittleStain thank you


@roteam would you mind sharing capx with these random math questions and right/wrong answer? thanks
B
5
S
1
Posts: 12
Reputation: 299


Return to How do I....?

Who is online

Users browsing this forum: suzannegrey and 28 guests