Page 1 of 1

### Stacks of variables

Posted: 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!

### Re: Stacks of variables

Posted: Mon Feb 17, 2014 8:06 pm

### Re: Stacks of variables

Posted: 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.

### Re: Stacks of variables

Posted: Mon Feb 17, 2014 10:01 pm
True, I didn't read closely enough. Here's a sample of the working solution:
LifeScoring.capx

### Re: Stacks of variables

Posted: Tue Feb 18, 2014 3:12 pm
thank you :)