I have a tile system written in XNA, and there is problems with tiles fitting together.
What I mean is, sometimes tiles are separated by 1 pixel (maybe 2 pixels? can’t tell), and they are suppose to fit together perfectly. I am certain the math I did to get them together is right, I don’t know what is causing the issue.
Surprisingly this issue is fixed when I raise the size of my tiles (a double) to 1000. Size is only relative to my camera zoom, so this does not affect game play at all, but it bothers me I have to do this.
Any ideas on what could be causing this?
edit: infact anything below a tile size of 995 has the issue, but anything above is good, this is some kind of weird precision issue. Is double math more accurate with high numbers or something?
Well, pixels are integers, and if the size of your tiles are in doubles, that means you must be doing some sort of conversion to get the pixels, which in turn is probably where you are getting the separation.
For example if tile A starts at 0, and is 9.9 in length, where do you put the next tile?