Multiples of a number
Blitz3D Forums/Blitz3D Programming/Multiples of a number
| ||
I know there is probably an extremely easy way to do this, but I never think clearly around this time. Anyway, what I'm trying to do is find out a multiple of a number. In my game, there are 25 levels, and 5 level skins. All the levels are identical, except for the skins? How would I make levels 1, 6, 11, 16, 21 all have skin 1, and levels 2, 7, 12, 17, 22 all have skin 2, etc? |
| ||
Graphics 200, 400, 0, 2 For n = 1 To 25 tx = n Mod 5 If tx <= 0 Then tx = tx + 5 Print LSet(n,4) + tx Next WaitKey tx is always in the range 1 to 5, even if you allow negative level numbers. |
| ||
So to check if the current level was 1, 6, 11, 16, or 21, I would do this:If level = level Mod 5 ;make level EndIf I've never used Mod before. I have no clue how it works. |
| ||
I've never used Mod before. I have no clue how it works. That's what the help files are for. Basically, this will divide your number as many times as possible by the divisor, then return you the remaining amount. Ergo: 26/5 1*5=5, 2*5=10, 3*5=15, 4*5=20, 5*5=25, 1 LEFT OVER, so return that. Print 26 Mod 5 |
| ||
Thanks. |