How do I invert this calculation?

Get help using Construct 2

Post » Wed Jan 14, 2015 6:05 am

I have an explosion which as closer as the object B are, more points will be earned.

I've established that every 5px closer, 1 point will be added and 200px is the explosions edge. So, in order to do an automatic comparison between these two objects, I came up with this:

Within 200px radius, I have 40 points (200/5 = 40 points)

I want to invert this, so I can get the right point measure. So, if I'm 5px close to the explosion, I get 40 points. If i'm 200px far, I get 1 point. If I'm 100px far, I get 20 points and so on

I'm not good with math so would be nice if someone could help me on that.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Wed Jan 14, 2015 6:59 am

max points = 40
radius = 200

( radius - distance(objectb.x,objectb.y,explosion.x,explosion.y)) / radius * max points


for example 200 - 50 = 150 , 150/200 = 0.75 , 0.75 * 40 = 30 points
B
67
S
23
G
9
Posts: 166
Reputation: 7,339

Post » Wed Jan 14, 2015 6:43 pm

neverk wrote:max points = 40
radius = 200

( radius - distance(objectb.x,objectb.y,explosion.x,explosion.y)) / radius * max points


for example 200 - 50 = 150 , 150/200 = 0.75 , 0.75 * 40 = 30 points


Thank you. You've saved me.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Thu Jan 15, 2015 8:38 pm

kossglobal wrote:
neverk wrote:max points = 40
radius = 200

( radius - distance(objectb.x,objectb.y,explosion.x,explosion.y)) / radius * max points


for example 200 - 50 = 150 , 150/200 = 0.75 , 0.75 * 40 = 30 points


Thank you. You've saved me.


You are very welcome. I'm glad that I could help.
B
67
S
23
G
9
Posts: 166
Reputation: 7,339


Return to How do I....?

Who is online

Users browsing this forum: db3344, leena222, mindragon73, Yahoo [Bot] and 18 guests