Randomly Generating Equations

Hi, guys, I wanted to randomly spawn equations where you can input an answer. I know I am making this sound overly simple, but is there anywhere or anyone who can help me with this info. For example, after a certain event 3+4=______ would appear and then an input would be allowed to be entered. Please let me know and thank you:)

Chris

Answers

  • carlblanchetcarlblanchet Member Posts: 755
    edited December 2012
    You could Make 5 integer attributes.
    First one will be for the first number.
    Second one will be for the +,-,*,/.
    Third one will be for the second number.
    Fourth one will be for the answer of the equation.
    Fifth one will be for the player's answer.

    Every time you want to generate a new equation:
    Change attribute FirstNumber to random(1,100)
    Change attribute SecondNumber to random(1,100)
    Change attribute +,-,*,/ to random(1,4)
    -If +,-,*,/ = 1 it'll be an addition
    -If +,-,*,/ = 2 it'll be an subtraction
    -If +,-,*,/ = 3 it'll be an multiplication
    -If +,-,*,/ = 4 it'll be an division
    For the Equation's answer:
    -If +,-,*,/ = 1 change attribute Equation's Answer to FirstNumber+SecondNumber
    -If +,-,*,/ = 2 change attribute Equation's Answer to FirstNumber-SecondNumber
    -If +,-,*,/ = 3 change attribute Equation's Answer to FirstNumber*SecondNumber
    -If +,-,*,/ = 4 change attribute Equation's Answer to FirstNumber/SecondNumber

    To display this:
    Use 3 display texts and position them accordingly
    First one display FirstNumber
    Second one display + if +,-,*,/ =1, - if +,-,*,/ =2, etc
    Third one display SecondNumber

    After the player types his answer:
    If attribute Player's Answer = Equation's Answer -> Correct answer and generate new one and add points.

    Hope this helps!
  • mrchris317mrchris317 Member Posts: 78
    That was super helpful. Thank you:) Two things, how do I create the actual images of the numbers, are they 1 actor each? Second how does the player input the answer, do I put an additional actor as like an answer box? Thanks again. Appreciate your time.
  • mrchris317mrchris317 Member Posts: 78
    Also are all of these change attributes in the same actor or are they all different actors? Thanks.
  • mrchris317mrchris317 Member Posts: 78
    Finally how do I make the If statements, what do I use to create these. Thanks.
  • carlblanchetcarlblanchet Member Posts: 755
    edited December 2012
    You're welcome! :)

    So instead of using a display text behaviour like i had previously said, you would follow this video to have custom numbers.


    Yes make an actor that will have to be pressed to answer, either an answer box, or an ANSWER ME button, or an invisible actor that covers the whole screen except the HUD.
    -In this actor make a rule, when touch is pressed, Keyboard Input and change Player'sAnswer attribute.

    All the change attribute rules can indeed go in one actor.

    The if statement is created by making a rule.
    Here's a rules tutorial:
  • mrchris317mrchris317 Member Posts: 78
    Awesome, watched vids, gonna try it after work tomorrow:) Thanks for all your help. I really appreciate it.
  • carlblanchetcarlblanchet Member Posts: 755
    No problem! Let me know if there's something else your not sure about.
  • mrchris317mrchris317 Member Posts: 78
    I have a few more questions carlblanchet, I will post them. Thanks again for your help:)
Sign In or Register to comment.