Extra Life per So Many Points?

This forum is currently in read-only mode.
  • I'm having some difficulty coming up with a way to create an extra life every 20,000 points.

    I'm a little weak in the math department, but I shouldn't have much trouble figuring out how to turn a good algorithm into an expression if somebody would be kind enough to offer one.

    Anyway, if anybody knows of a great way to accomplish this, I would greatly appreciate any assistance. Thank you!

  • You could use mod function "%" and trigger once while true event.

    made an example

    http://dl.dropbox.com/u/888303/Caps/score_life.cap

  • Hope this helps.

    I mis-read your post and gave a life at 2000 exp not 20,000. Just change my 2000 to 20000 in the code

    http://www.box.net/shared/5r3090p9yl

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • + Points greater or equal to 20000

    -> Add 1 to lives

    -> Subtract 20000 from points

  • + Points greater or equal to 20000

    -> Add 1 to lives

    -> Subtract 20000 from points

    Problem is if he wants to keep his Score then he would need to make two counters.

  • No... Just look at my example, it is all in the math

    EarnedLives:

    int(global('EarnedExp') / 20000)+1

  • No... Just look at my example, it is all in the math

    EarnedLives:

    int(global('EarnedExp') / 20000)+1

    That method won't work properly. Since the amount of lives you have is directly tied to the amount of experience(or points) you have, losing lives won't work properly. You'll just gain back any lives you lost the instant that expression is used again.

    Doppel's method is the best. However, the more conventional way of using modulus in this case would be:

    If Score % 20000 = 0

  • If Score % 20000 = 0

    What if you are at 19999 points and gain 10 points? It skips over 20000, which means the above condition is only run if you hit exactly 20000, 40000 or 60000 score.

    If the score doesn't decrease, I'd suggest something like this:

    + if Score/20000 > var

    Lives = Lives +1

    Var = Var +1

    What does this do? Well, it tracks how many times you gained life by scores! When you hit 20000 score for the first time, the above condition is true since var = 0 at the start and Score/20000 = 1 > 0. Once the event is processed, it also increases var by 1, so that it won't run again until you pass the next milestone.

    Meanwhile, you can abuse lives all you want!

  • Doppel's method is the best. However, the more conventional way of using modulus in this case would be:

    If Score % 20000 = 0

    Free Bonus life at start of the game? Sweet.

  • What if you are at 19999 points and gain 10 points? It skips over 20000, which means the above condition is only run if you hit exactly 20000, 40000 or 60000 score.

    Heh, I had never even considered that.

  • Thank you very much everybody. All of your info was very helpful, so I should be able to make something out of it! Time to try it out...

  • > No... Just look at my example, it is all in the math

    >

    > EarnedLives:

    >

    > int(global('EarnedExp') / 20000)+1

    >

    That method won't work properly. Since the amount of lives you have is directly tied to the amount of experience(or points) you have, losing lives won't work properly. You'll just gain back any lives you lost the instant that expression is used again.

    Doppel's method is the best. However, the more conventional way of using modulus in this case would be:

    If Score % 20000 = 0

    Actually my expression works great. When you RP you need to know the MAX lives for a a set Experience lever so. But you also set a TempLives up.

    This way you can subtract TempLives, but say you get a potion to gain lives back. My way you will still see the ceiling for how may lives you can gain back.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)