How do I make random questions

0 favourites
  • 10 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm not quite sure what you're asking - do you want to create randomly generated equations/sums?

  • Not necesarely randomly generated. All i want is an easyer way to make the game.

  • that's not random text,but random question each level/section

  • that's not random text,but random question each level/section

    yup, my bad

  • 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!

  • 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)")

  • 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..

  • LittleStain thank you

  • LittleStain thank you

    roteam would you mind sharing capx with these random math questions and right/wrong answer? thanks

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)