Eerr, you may already know of it, and I might not understand what your issue is, but have you looked at Bresenham's line algorithm? It seems to be the standard raster line drawing algorithm, although it doesn't naturally allow for the double-width walls that most roguelikes require.
I think I just implemented my version by hand.
public static loc[] makeline(loc l, loc V)
{
double slope = ((double)l.X-V.X) / ((double)l.Y-V.Y);
//int x =
int dx = (l.X - V.X);
int absdx = Math.Abs(dx);
int dy = (l.Y - V.Y);
int absdy = Math.Abs(dy);
int i;
loc[] array;
slope = (((double)dy) / ((double)dx));//dx/dy
double altslope = (((double)dx) / ((double)dy));//dx/dy
if (absdx > absdy)
{
array = new loc[absdx+1];
if (dx <= 0)
{
//i = dx;
for (i = dx; i <= 0; i++)
{
loc G;
G.X = i;
G.Y = (int)((double)i * slope -.5);
array[Math.Abs(i)] = G+V;
}
array[0] = V;
array[array.Length-1] = l;
}
else
{
//absdx = dx;
for (i = 0; i <= absdx; i++)
{
loc G;
G.X = i;
G.Y = (int)((double)i * slope +.5);
array[i] = G+V;
}
array[0] = V;
array[array.Length - 1] = l;
}
}
else
{
array = new loc[absdy+1];
if (dy <= 0)
{
for (i = dy; i <= 0; i++)
{
loc G;
G.Y = i;
G.X = (int)((double)i * altslope -.5);
array[Math.Abs(i)] = G+V;
}
array[0] = V;
array[array.Length - 1] = l;
}
else
{
for (i = 0; i < absdy; i++)
{
loc G;
G.Y = i;
G.X = (int)((double)i * altslope +.5 );
array[i] = G+V;
}
array[0] = V;
array[array.Length - 1] = l;
}
//return Math.Abs(l.X - V.X);
}
return array;
}
You can substitute point for loc
without any changes if you sub
array[i] = G+V; for array[i].X = G.X+V.X; and array[i].Y = G.Y+V.Y;
. I slowed down the algorithm further by operator overloading loc+loc. The last two points are copied over by hand. I am currently in fear of using mouse.x and mouse.y because I screwed up something which hung the computer. And then later the IDE crashed.
Actually, Bresenham's algorithm looks really good for making thick walls. Whenever the y increases, you either need an extra wall next to that point or at the point before.
Edit 2: Algorithm fixed for center-ness.
Edit 3: Algorithm fixed for further center-ness.