# Repat for every n-th points

Get help using Construct 2

### » Mon Aug 20, 2012 8:21 pm

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.
B
4
Posts: 17
Reputation: 334

### » Mon Aug 20, 2012 8:35 pm

So points is a variable?

System: Compare two values points % 10 = 0
System: Trigger Once
Do action

B
55
S
29
G
19
Posts: 1,520
Reputation: 25,780

### » Tue Aug 21, 2012 8:51 am

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:)
B
4
Posts: 17
Reputation: 334

### » Tue Aug 21, 2012 10:26 am

% 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.

New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
304
S
123
G
99
Posts: 7,358
Reputation: 73,460

### » Tue Aug 21, 2012 11:51 am

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. ramones2012-08-21 11:52:12
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,780

### » Tue Aug 21, 2012 12:00 pm

Ah, good old modulus.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,739

### » Tue Aug 21, 2012 7:04 pm

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.sled2012-08-23 13:32:21
B
4
Posts: 17
Reputation: 334

### » Thu Aug 23, 2012 1:32 pm

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.
B
4
Posts: 17
Reputation: 334

### » Thu Aug 23, 2012 2:29 pm

B
55
S
29
G
19
Posts: 1,520
Reputation: 25,780

### » Thu Aug 23, 2012 11:21 pm

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?

B
4
Posts: 17
Reputation: 334

Next