subtract math

Get help using Construct 2

Post » Fri Mar 29, 2013 8:49 am

Score = 100.
Let's set "move"= 34 and "kill"= 30.
If "move" greater than "kill", for each 1 unit(example: 31,32,33), subtract from "score" 5 unit.
Anybody please help me.

B
50
S
12
G
7
Posts: 259
Reputation: 10,371

Post » Fri Mar 29, 2013 10:03 am

anyone ?
B
50
S
12
G
7
Posts: 259
Reputation: 10,371

Post » Fri Mar 29, 2013 4:44 pm

There's no question here.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Fri Mar 29, 2013 5:44 pm

[QUOTE=farsmile90] Score = 100.
Let's set "move"= 34 and "kill"= 30.
If "move" greater than "kill", for each 1 unit(example: 31,32,33), subtract from "score" 5 unit.
How can i subtract 5 unit from score for each 1 unit of "move"greater than "kill"
Anybody please help me.

[/QUOTE]
B
50
S
12
G
7
Posts: 259
Reputation: 10,371

Post » Fri Mar 29, 2013 7:06 pm

It's very hard to recommend any course of action without having a frame of reference. What exactly are you trying to accomplish? What is a unit? Are Score, Move, Kill all variables? If so, global variables or instance variables?

The more info you provide, the easier it is to help.zatyka2013-03-29 19:08:05
B
44
S
13
G
7
Posts: 338
Reputation: 10,379

Post » Sat Mar 30, 2013 1:23 am

@zatyka My english is very bad, and it's so hard to provide.
Try it again, for example, i have 3 global variables. First called "move", second called "kill", and third called "score". I set "move" = 8, "kill" = 5, "score" = 100. How can i subtract 5 score from "score" if global "move" greater than global "kill". If "move" = 7 then "score" = 95, "move" = 6, "score" = 90...
B
50
S
12
G
7
Posts: 259
Reputation: 10,371

Post » Sat Mar 30, 2013 1:38 am

It seems self explanatory. I don't see what the problem is.





B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Sat Mar 30, 2013 1:53 am

[code]score = score - (move - kill) * 5[/code]
or maybe
[code]score = max(0, score - (move - kill) * 5)[/code]
if you don't want it to go below 0.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Sat Mar 30, 2013 3:11 am

@ramones, thank god ! you understand me... it's work. Thank you, thank you.
B
50
S
12
G
7
Posts: 259
Reputation: 10,371

Post » Sat Mar 30, 2013 5:28 am

Next time, tell people what is your main language. There might be people using your language.
HARMLESS SIGNATURE THAT IS VIEWED BY OTHERS AS OFFENSIVE AND CONTROVERSIAL
B
14
S
3
G
3
Posts: 356
Reputation: 4,362

Next

Return to How do I....?

Who is online

Users browsing this forum: randomly and 17 guests