I am trying to code collision with a tile map.
The problem I have is that the tile map is by array location, but player movement is by pixel.
I need a way to make this calculation to determine whether a tile is passable (array location value 0).
bool tilePassable(){ if(map[guyPosX / 32][guyPosY / 32] == 0) { return true; } else { return false; }}
The problem I have is that naturally the precise pixel the character is sitting on will not necessarily be a multiple of 32, so I will end up with a decimal resule when I divide its location by 32.
Is there a way to make this calculation to the nearest whole number, ie ignoring any remainder, so that, for example 100 / 32 = 3 (ignoring the remaining 4).
Is there a way to make this calculation in code?
Thanks
[Edited by - Zahlman on August 31, 2010 4:08:40 PM]