00:00
00:00
Newgrounds Background Image Theme

Basalspider just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Checking score if it is divisible?

513 Views | 5 Replies

Hellow fellow TGF2-ers,

I was wondering how I can make an event where it checks to see if the score is divisible by a certain number.

Basically, what I want to do is that every time the score is divisible by 100 and there will be no remainder (for example whenever the score is 100, 200, 300, 400...) then the game switches to a certain frame.

What would be the appropriate way of doing this?

Thanks to anyone who can help.

Response to Checking score if it is divisible? 2011-07-06 09:34:18


You can always create a new event, then click on your player's icon( that icon with a joystick and a number ) and then you'll see a box that says "compare to player's score". Here you can always tell the program to trigger something when the score has reached a certain value. Also, make sure your score is a global object.

THEN, you can set the score in any way that you want. You will have an option to obtain a value from another object in the math-window, you can select the same object( the score ) and then divide it or whatever you feel like.

I don't know if this was the answer you were looking for, but good luck regardless! :)


Still going stånk.

Response to Checking score if it is divisible? 2011-07-07 22:58:52


At 7/6/11 09:34 AM, 0ld5K00l wrote: You can always create a new event, then click on your player's icon( that icon with a joystick and a number ) and then you'll see a box that says "compare to player's score". Here you can always tell the program to trigger something when the score has reached a certain value. Also, make sure your score is a global object.

THEN, you can set the score in any way that you want. You will have an option to obtain a value from another object in the math-window, you can select the same object( the score ) and then divide it or whatever you feel like.

I don't know if this was the answer you were looking for, but good luck regardless! :)

Hi,

Thanks for the reply. What you mentioned is actually what I have been doing. I have been making events for when the score is equal to 100, 200, 300, 400... and so on. But what I want to do instead is make one event that is constantly checking to see if the score is in an increment of 100. That way I don't have to make so many events for the same thing...

Any ideas?

Response to Checking score if it is divisible? 2011-07-08 20:52:46


I think the modulus (Mod) operator is supposed to calculate the remainder of two numbers, like '10Mod5 = 0' or '32Mod10 = 2'.

Response to Checking score if it is divisible? 2011-07-08 22:09:56


At 7/7/11 10:58 PM, enzanblaze wrote:
At 7/6/11 09:34 AM, 0ld5K00l wrote: You can always create a new event, then click on your player's icon( that icon with a joystick and a number ) and then you'll see a box that says "compare to player's score". Here you can always tell the program to trigger something when the score has reached a certain value. Also, make sure your score is a global object.

THEN, you can set the score in any way that you want. You will have an option to obtain a value from another object in the math-window, you can select the same object( the score ) and then divide it or whatever you feel like.

I don't know if this was the answer you were looking for, but good luck regardless! :)
Hi,

Thanks for the reply. What you mentioned is actually what I have been doing. I have been making events for when the score is equal to 100, 200, 300, 400... and so on. But what I want to do instead is make one event that is constantly checking to see if the score is in an increment of 100. That way I don't have to make so many events for the same thing...

Any ideas?

You can create a counter object outside the screen area, then set the maximum value to 100. What you want to do next is making this object rising its value every time the score does it, so they always will be the same. Whenever the counter's value reaches 100, set it back to 0 and trigger anything you would like. This will keep it happening all the time. In other words, let the counter do the work for the score.

Hope this helps, good luck!


Still going stånk.

Response to Checking score if it is divisible? 2011-07-09 04:37:56


I can't believe I didn't think about that! Thank you 0ld5k00l, that is PERFECT.