How do I make something happen in increments.

0 favourites
  • 6 posts
  • How do I make something happen in increments.

    So I have a global variable, set it to zero and each time you click the mouse button it adds 1 to the variable on the 5th click "pew pew" something happens. Do I then set the veritable back to zero and then count the clicks backup to 5 so "pew pew" something happens or can I say the 5th click the 10th click the 15th click and so on.

    I want to do the same thing with scoring say 5000 you get a free man, 10,000 you get a free man.

    Any ideas?

  • You could do it that way or, you could use the Modulus operator (%). You can see more about it if you look it up but this is what you would use for your condition:

    Use a System "Compare 2 Values" event and set the 2 values to the following

    Value 1:

    CurrentCount % 5

    Value 2:

    0

    CurrentCount is the name of your variable and you will want it to start at 1 because 0 % anything is always equal to 0.

  • I will this a try and read up on Modulus, thanks FragFather.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tried it but not working, so lets say I wanted to give a extra life every 100 points would I write it:

    First Value: VarScore % 100

    Comparison: = Equal to

    Second Value: 0

    VarScore is the name of the Score variable, and are you saying VarScore should start out as having a value of 1 and not 0?

  • Using this method for the score/new life will be much more difficult than the every Nth click event you mentioned in your first post. Scores rarely hit exactly on the value you earn a bonus for. You usually get it when your score is greater or equal to the necessary score. For this situation, I would suggest you set a LastBonus variable and check where Score >= LastBonus + 100.

    I was suggesting the method again for the click iteration situation. In that case, the user will always click a 5th, 10th or 15th time. You can't skip from clicking 4 times to 8 times. The (VarScore % 100 = 0) means the score has to be an exact multiple of 100.

    For the last question, yes. If the variable you are testing starts at 0, the Modulus will start as true so the user would get a new life immediately. There is however, a way around this by adding a condition that says score != 0.

  • Thanks for the lesson, I learn a bit more every day one of these days I might even finish a project.

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