I\'m currently working on project of where 2d terrain maps are saved into a one-dimensional array. Each block in the map is indexed by xy coordinates. So, to save the map in
To calculate indices you should be using something like this:
index = X + Y * Width;
So, to reverse this you can take advantage of integer division truncation to get Y, and then X is just what's left over after what Y "used up":
Y = (int)(index / Width) X = index - (Y * Width)