How do I Add values to global Variable after each Score

  • Hey,

    I want to Add a Specific value each time player gets some specific points.

    Example:

    On each 10 points(Global Variable) --> Add 1 to health(Global Variable)

    So i just want to add a specific value to global variable every time player gets a specific amount of points which is also a global variable.

  • Hey, I'd use a separate variable to do this

    If variable = 10

    once while true -> Add 1 to player health

    set variable to 0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey, I'd use a separate variable to do this

    If variable = 10

    once while true -> Add 1 to player health

    set variable to 0

    Hey ultrafop Thanks for the reply but i want the the player health should get additional 1 point on every 10 score so basically if the player gets score like 10,20,30,40,50,60, and so on it will add 1 to health.

  • For sure. I think we're saying the same thing. I'm suggesting you add another counter variable, in addition to the score variable, which adds one to the player every time it hits 10, (then resets to 0). You can add 1 to the variable in the same event you use to add one to your score overall. This way you have a total score and can get your mechanic in.

    Another option could be if score/10 = round(score/10) -> once while true -> add 1 to player health

  • For sure. I think we're saying the same thing. I'm suggesting you add another counter variable, in addition to the score variable, which adds one to the player every time it hits 10, (then resets to 0). You can add 1 to the variable in the same event you use to add one to your score overall. This way you have a total score and can get your mechanic in.

    Another option could be if score/10 = round(score/10) -> once while true -> add 1 to player health

    Hey Thank you for explaining it again.

  • My pleasure! Best of luck with the project!

  • some example based on ultrafop 1st suggestion.

    2nd suggestion will just work at value of 0 other than, will work at weird points like 0, 7, 15 etc.

  • some example based on ultrafop 1st suggestion.

    2nd suggestion will just work at value of 0 other than, will work at weird points like 0, 7, 15 etc.

    That's weird, the second idea works fine for me over here. Here's a link to check it out:

    https://www.dropbox.com/s/5h1c77s9u2qp9 ... .capx?dl=0

  • > some example based on ultrafop 1st suggestion.

    >

    > 2nd suggestion will just work at value of 0 other than, will work at weird points like 0, 7, 15 etc.

    >

    That's weird, the second idea works fine for me over here. Here's a link to check it out:

    https://www.dropbox.com/s/5h1c77s9u2qp9 ... .capx?dl=0

    that is weird ... i had tested that code 1st try exactly same thing you did... based on your suggestion... i think c3 doesn't play well with that formula. not sure why i got different results. but that simplifies things <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> thanks

  • For sure! That's odd that c3 gives a different result...possible bug?

  • For sure! That's odd that c3 gives a different result...possible bug?

    nah i update the c3p file i uploaded i added the 2nd formula you sent, works good in C3 not sure why i got a random number poping up back then, something in the logic probably how i coded and i was thinking i did it the right way or something. im a bit tired my brain works weird haha

    again thanks always learning haha

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