Initial attempt at road generation
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user