Calculating an ODD or EVEN square.

BlitzMax Forums/BlitzMax Beginners Area/Calculating an ODD or EVEN square.

Takis76(Posted 2012) [#1]
Hello again my friends,


Now I am trying to make one algorithm which calculates if you are on ODD square or on EVEN square.

The modulus Function MOD make this.

if you calculate each number with mod 2 and this equals to 0 then the remain of division if even else is odd.

The code example to calculate if some of my square is even or odd.


If camera.x Mod 2 = 0 Then print even
if camera.x mod 2 = 1 then print odd



camera.x is the horizontal coordinates
camera.y is the vertical coordinates

My Idea says , there is a chess board 40x40 and the white squares are the EVEN and black squares are the ODDs.

How to calculate and know when my camera.x or camera.y is on an odd or even square.

if you didn't understand what I mean , I will upload my source code to see what I want to do.

I am near to the solution , but something is missing.


skidracer(Posted 2012) [#2]
try (camera.x+camera.y) Mod 2


Takis76(Posted 2012) [#3]
It worked perfectly. :) Thank you very much AGAIN.