Topic: Convert 1D to 2D
Hi!
Ok.. i hace this question... How i can pass the Unidimensial Array 'TILES' to 2D coords??
2D to 1D
** ny*mMap.w+nx ***
int nx = clamp(static_cast<int>(POSX)/32, 0, mMap.w-1);
int ny = clamp(static_cast<int>(POSY)/32, 0, mMap.h-1);
tTiles[ny*mMap.w+nx].index
1D to 2D (This Not Works) ¿How i can make it??
for (int i=0; i<mMap.w*mMap.h; i++)
{
vec2 posTileMap;
posTileMap.x = i;
posTileMap.y = int(i/mMap.w);
if (i > mMap.w)
posTileMap.x-=mMap.w*posTileMap.y;
}
thx!