Initial attempt at road generation

This commit is contained in:
2015-05-26 19:36:44 +03:00
parent b6b2dce32e
commit 22f1905b1b
10 changed files with 239 additions and 10 deletions

View File

@ -68,5 +68,35 @@ namespace TransportGame.MapViewer.Model
return 3 * (x + y * Width);
}
public void DrawLine(int x0, int y0, int x1, int y1, Color color)
{
int dx = Math.Abs(x1 - x0);
int sx = x0 < x1 ? 1 : -1;
int dy = Math.Abs(y1 - y0);
int sy = y0 < y1 ? 1 : -1;
int err = (dx > dy ? dx : -dy) / 2, e2;
for (; ; )
{
this[x0, y0] = color;
if (x0 == x1 && y0 == y1)
break;
e2 = err;
if (e2 > -dx)
{
err -= dy;
x0 += sx;
}
if (e2 < dy)
{
err += dx;
y0 += sy;
}
}
}
}
}