Stacks of variables

Get help using Construct 2

Post » Mon Feb 17, 2014 7:35 pm

Hi,

I am wondering how to write a condition: for each 10 score (score is a global variable) add 1 life.
How i write for each stack of 10 in the condition?

Basically the player earns points and i want to give him a bonus life when he reaches 10 points, 20, 30, 40..

Thanks!
B
13
S
4
G
1
Posts: 241
Reputation: 1,724

Post » Mon Feb 17, 2014 8:06 pm

Add to life: int(score/10)
ImageImageImage
B
71
S
22
G
257
Posts: 3,788
Reputation: 142,692

Post » Mon Feb 17, 2014 9:12 pm

I'm not sure it this works in C2, but everytime you add score, I would try a comparison between two values, score%10 and 0, if true add a life. score%10 returns the rest of the equation, so if score is a multiple of 10 it adds a life.

@blackhornet, this solution would end up giving the player, 1 life, then 2, then 3 and so on if he doesn't subtract 10 from score.

You can also use blackhornet's solution together with a 'hidden score', everytime it reachs 10, add a life and subtract 10 from it.
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Mon Feb 17, 2014 10:01 pm

True, I didn't read closely enough. Here's a sample of the working solution:
LifeScoring.capx
ImageImageImage
B
71
S
22
G
257
Posts: 3,788
Reputation: 142,692

Post » Tue Feb 18, 2014 3:12 pm

thank you :)
B
13
S
4
G
1
Posts: 241
Reputation: 1,724


Return to How do I....?

Who is online

Users browsing this forum: dop2000, max2612 and 6 guests