I'm probably missing some very easy mathematical equation, but, I want to check if the player is on level 10,20,30, and so on. If that happens, a boss will appear, but how do I check if a level is a multiple of 10?
How Do Yo Check if a Level is a Multiple of 10?
Blitz3D Forums/Blitz3D Beginners Area/How Do Yo Check if a Level is a Multiple of 10? IF X MOD 10 = 0 Then X divides by 10 evenly, with no remainder.
IT works, thanks! I didn't know about mod
the thing I don't like of mod is that it does not work for negative numbers: when I write "-7 mod 10" I expect to get 3, not -7. Anyway its easy to code one's mod.
Anyway the syntax is
IF X MOD 10 = 0 Then makebossappear(cool, powerfull, supemissiles)
Anyway the syntax is
IF X MOD 10 = 0 Then makebossappear(cool, powerfull, supemissiles)
I am still shakey on MOD squad myself so I would divide the number by 10 and then by itself... if the answer was exactly 1 then viola! you have achieved another level of base 10.
RZ
RZ
MOD just gives you the remainder after dividing by the specified number - if it's 0 then the number divides into the original exactly.
just use ABS(X) MOD 10 to avoid probs with negative numbers, but then you shouldn't have a level numbered below 1 anyway I would think.
just use ABS(X) MOD 10 to avoid probs with negative numbers, but then you shouldn't have a level numbered below 1 anyway I would think.
Najdorf:
MOD still gives a zero answer on multiples of -10, i.e.,
IF X MOD 10 = 0 Then makebossappear(cool, powerfull, supemissiles)
will still work at -10, -20, etc, for multiples of 10
the thing I don't like of mod is that it does not work for negative numbers: when I write "-7 mod 10" I expect to get 3, not -7.
MOD still gives a zero answer on multiples of -10, i.e.,
IF X MOD 10 = 0 Then makebossappear(cool, powerfull, supemissiles)
will still work at -10, -20, etc, for multiples of 10
Regardless you could use
If MOD abs(10) = o then makebossappear(cool, powerfull, supemissiles)
abs is absolute value.. makes a neg number a pos and leaves pos as pos.
If MOD abs(10) = o then makebossappear(cool, powerfull, supemissiles)
abs is absolute value.. makes a neg number a pos and leaves pos as pos.
function qWrap(Quick,low,high)
if quick>high then quick=low
if quick<low then quick=high
return quick
end function
works for me. if your using whole numbers
if quick>high then quick=low
if quick<low then quick=high
return quick
end function
works for me. if your using whole numbers
Neo, What happens when you Qwrap(15,0,10)? You get 0, not 5 :P
ABS(X) MOD 10 as Vorderman said.... will do :)
ABS(X) MOD 10 as Vorderman said.... will do :)