Quote:Original post by codeman_nz
Thanks for that, it is very useful. How would I modify this to handle a tilemap with 10x10 pixel tiles?
First, read the comments in my code. ;) Those comments do not exist outside of this thread and were made for you. Follow them.
As LorenzoGatti mentioned, the size of your tiles is completely irrelevant. The important thing is the dimensions of your tile map. Think of your tile map as a bitmap (it is, actually). If you are using an array of chars, you have an 8-bit bitmap, an array of longs would give you a 32-bit bitmap. I have successfully used a tile map as the image pointer to a Win32 GDI bitmap and used GDI calls to set tiles.
Anyway, the point is that no matter what you use to set the tile IDs in your tile map, make sure you stay within the array bounds.
Quote:Original post by superpig
As a general theory about this - similar to MarkS's solution but without the Bresenham approximation
Of course there are other ways and I know that the Bresenham algorithm is looked down on, but it really is fitting here. Since a tile map is a 2D array of integers, there are no "half tiles", so an integer approximation is the best.
Anyway, I never could get adjacency to work, so I caved and just drew lines to fill the gaps. There is very little to no overdraw and the lines drawn are typically either very short of near vertical/horizontal, so the curve is nearly pixel perfect and far smoother than the typical polyline approximation.