Repat for every n-th points

0 favourites
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hi

    I haven't found this anywhere so:

    How to do condition that repeats itself for every let's just say 10 points. I know there are many examples with time, but none with something other then time.

  • So points is a variable?

    System: Compare two values points % 10 = 0

    System: Trigger Once

           Do action

  • Thanks :) I did what You wrote and now it works. Is this like 10% of current value of points equals 0 and why it equals 0. Could You explain to me this more clearly. I'm just starting with Construct 2. Thanks in advance:)

  • % here is the mathematical modulus.

    It makes it so that the value compared is between 0 and 9 in that case (when points = 10 it is actually equal to 0).

    If points=20, it cycle "two times".

    It's not a very good/precise explanation but the idea is that it cycles through this range according to the original value.

  • To expand on what Kyatric said: points % 10 gives you the remainder when points is divided by 10. So for example, if points = 100 then points % 10 = 0 (100/10 = 10 remainder 0). If points = 101, points % 10 = 1 (101/10 = 10 remainder 1).

    Basically, checking if a number % 10 = 0 tells you if the number is evenly divisible by 10. If you wanted something to happen when points = 6,12,18,24,etc you'd check if points % 6 = 0.

  • Ah, good old modulus.

  • I want to thank everyone for Your quick answers and good explantations of modulus. Now i'm begining to understand how modulus works, but can I use it to accelerate falling elements in my game. I want my elements for every 100 points to accelerate so that with every 100 points they would fall down faster and faster.

  • UPDATE:

    Maybe i didn't explain clear enough. I'm making a game where blocks are falling from top to bottom and players catches them, but that is not important. I want those block to accelerate to fall faster with every 100 points but i don't know how to do this. I've got my own movement system if someone wants to know.

    First I made my variable like this:

    • "Falling Block" with variable "speed" that is a number and have value of 0.

    I'm setting my variable in "on start of layout" to

    Sprite11 -> Set speed to Sprite11.Y+1

    and then

    System -> Points %5=0    -> Sprite11 ->Set speed to Sprite11.speed+5

              Trigger Once

    but when Points passes 5,10...and so one blocks are not accelerating.

  • Thank You very much ramones. It was very helpful, but let just say I want to add another block which adds 20 to points. Do i have to write something like:

    System -> Points %100=0

              Points %110=0

              Points %120=0...

    to cover all posible scores for blocks to speed up?

  • I'm not sure what you mean there.

    If you want to add 20 points to the score on a given condition :

    Given condition

    -> Action: System: Add 20 to points

  • In my game when my character catches one type of falling block it adds 10 points to score, and when it catches another it adds 20 points, 15 points whatever.

    But my problem is that i' ve got condition :

    "points % 100=0" so when I let's just say have 90 points and then catch 20 points block the score will be 110 so this condition is not working anymore to speed up falling because it's not 100. I want to speed up those falling blocks regardles if it's 100,110, 220, 350. I just want them to fall faster when score passes another 100 points.

    I hope i described it clear enough.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Every ticks -> set speed to startSpeed + floor(points/100) * 10

    the speed with increase by 10 every 100 points

  • Thanks. Ok what Am I doing wrong, beacuse it almost works, but speed increases with every point not with every 100 points :/ Here is my condition:

    Every ticks ->System -> Set speed to 100+floor(points/5)*100

    I wrote "(points/5)*100" to check faster if this works.

    Is this startSpeed holds somehow first value of speed?

  • Yann I checked Your condition and there is something i don't understand beacuse it speeds up my blocks every time player catches ONE block!

    speed is a global variable

    startspeed is global variable with value of 50.

    Every Tick -> System -> set speed to startspeed+floor(points/5)*100

    And this condition doesn't work for every 5 points but for every 1 point only, so would You be so kind to describe it more clearly.

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