How do I make C2 do simple math using equations?

0 favourites
  • 9 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hello guys!

    First of all I'm new to Construct 2 and I my knowledge of programming is nearly zero. Also I'm not good in English but I'll try to make this as simple and clear as possible.

    So I decided to make this kind of game which currently I'm stuck when it comes to calculate simple mathematics using 3 Variables.

    For Example:

    there are 3 variables

    Value1

    Value2

    Value3

    I want C2 to calculate Value1 + Value2 = Value3 , where the Value1, Value2, and Value3 only contain numbers between 0-9, not more not less.

    For example: An enemy is destroyed, the instance the enemy is destroyed, then all the Values Value1, Value2 and Value3 are set between 0-9 but also using the equation Value1 + Value2 = Value3 at the same time and the Value3 is the reference because it is the answer in the equation. The value for Value1 and Value2 must be pick at random. For example:

    2 + 5 = 7

    5 + 2 = 7

    3 + 4 = 7

    The Variable3 is set to be 7, my question is, can C2 randomly pick any value between 0-9 for Value1 and Value2 and add these two values together so that the Value1 + Value2 will be 7?

    I'm beginning to think that C2 cannot decide the variables automatically to match with the equations, which is going to be difficult if I have to write all the possibilities of the equation manually, which is quite a lot of work. But if you guys have any idea, please do share with me, I really need this to make my game.

    Thank you

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, I see

    Thanks korbaach

    I only need these four equations for my game

    Value1 + Value2 = Value3

    Value1 - Value2 = Value3

    Value1 x Value2 = Value3

    Value1 / Value2 = Value3

    The equation for addition is settled. But what about the other 3?

    Value1 - Value2 = Value3

    Value1 x Value2 = Value3

    Value1 / Value2 = Value3

  • Is this game meant to teach yourself math?

    Seeing korbaach 's example can't you think of a way to create at least the "Value1 - Value2 = Value3" one?

  • LittleStain

    Yes, one of this game challenges is to solve math within a limited amount of time, let's say when the player kill an enemy, the enemy leave behind a weapon, to acquire that weapon the player need to solve math question, and the stronger the weapon, the harder the equation is going to be, for now I want to test the number 0-9, maybe even harder question might include higher numbers or even number with fractions.

    And yes I did figure out how to make all the equations work, including multiplication and division but then the Value1 could be anything, when I just want it be between 0-9 (whole number only, not fraction) in the beginning. After I solve this problem, I would want the Value1 and Value2 not only between 0-9, maybe I can include fraction numbers, or maybe even decimal places, only I wonder if I can control how many decimal places that the Values can hold? For example I only just want all the Variables has only 2 decimal places, but before I go the that problem, I want to solve the fixed 0-9 (whole number) numbers thingy for the equation, where the Value1 could be anything instead of only 0-9.

  • Oh thank you so much for the capx korbaach

    I'm going to have some time to figure out what have you did in the capx, because I'm not so good in mathematics.

    Thanks anyway, I really appreciate your sharing

  • Question: Say you wanted to make this mathematic game where the player gets 3 options. Obviously 2 of them are incorrect and only 1 is the correct answer. How would this be possible with your capx Korbaach ??

    e.g this game:

    https://itunes.apple.com/us/app/nush/id890596846?mt=8

    i want to make one like that.

    Only thing i can't figure out, is how to insert 3 buttons showing 3 different result were only one of them is the correct answer.

  • Chansen

    1. Create 3 incorrect results (use while loop to make sure there's no correct result).

    2. Pick a random result and make it the correct result.

    3. Profit.

    Well i hope there's a easier way than this.

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