Original Post
I have a 2d overhead tile based program I am working on. When I draw my tiles, I basically have some code like this:
dxleft = xloc-4.2 + ((xtilenumber-1) * 0.4);
dxright = xloc-4.2 + (xtilenumber * 0.4);
dytop = yloc+4.2 - ((ytilenumber-1) * 0.4);
dybottom = yloc+4.2 - (ytilenumber * 0.4);
Draw the quad with these corners.
Basically, this sets up tiles that are 0.4 units wide. However, consider this:
if (keys[''W'']) yloc -= .2;
if (keys[''S'']) yloc += .2;
if (keys[''A'']) xloc += .2;
if (keys[''D'']) xloc -= .2;
At first, I had it moving .4 each time, which I thought would move the screen exactly one tile, but it moves it exactly 2 tiles, so I had to make it .2 instead. It works how I want with .2, but it bothers me that the numbers don''t line up. I at least want to know why so I can understand whats going on. Plus, when I start doing collision detection I want to know if I am dealing with .2 or .4, etc.