Fixes #12.
@ -51,6 +51,7 @@ namespace SemiColinGames {
}
// This creates and populates a new array. It's O(n) and should probably only be used for tests.
// TODO: restrict visibility so that it can only be used by tests.
public T[] ToArray() {
T[] result = new T[items.Length];
for (int i = 0; i < items.Length; i++) {
@ -22,6 +22,7 @@ namespace SemiColinGames {
int errorXY; // Error value e_xy from the PDF.
// The size of the output is the size of the longer dimension, plus one.
int resultSize = Math.Max(dx, -dy) + 1;
// TODO: an array or list should be passed in by the caller.
var result = new Point[resultSize];
int i = 0;
@ -83,6 +83,8 @@ namespace SemiColinGames {
bool harmedByCollision = false;
// TODO: pass in movePoints to Line.Rasterize instead of having that function allocate a
// new array.
Point[] movePoints = Line.Rasterize(0, 0, (int) movement.X, (int) movement.Y);
for (int i = 1; i < movePoints.Length; i++) {
int dx = movePoints[i].X - movePoints[i - 1].X;