How do I make C2 do simple math using equations?

Just started using Construct 2? Post your questions here

Post » Thu May 28, 2015 6:24 pm

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 :)
B
3
Posts: 5
Reputation: 177

Post » Thu May 28, 2015 6:26 pm

B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Thu May 28, 2015 6:49 pm

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
B
3
Posts: 5
Reputation: 177

Post » Thu May 28, 2015 7:54 pm

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?
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 » Fri May 29, 2015 4:51 am

@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.
B
3
Posts: 5
Reputation: 177

Post » Fri May 29, 2015 8:38 pm

B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Sat May 30, 2015 3:00 pm

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 :)
B
3
Posts: 5
Reputation: 177

Post » Tue Aug 11, 2015 11:51 pm

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.
B
11
S
3
Posts: 31
Reputation: 814

Post » Mon Aug 17, 2015 3:50 am

@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.
B
24
S
4
G
2
Posts: 41
Reputation: 1,543


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest