import 'dart:typed_data';

typedef Matrix<T> = List<List<T>>;
typedef SpriteMap = Matrix<int>;

class Sprite {
  final Uint8List pixels;

  Sprite(this.pixels);

  // Factory to convert your 2D matrices into a 1D array during load time
  factory Sprite.fromMatrix(Matrix<int> matrix) {
    final pixels = Uint8List(64 * 64);
    for (int y = 0; y < 64; y++) {
      for (int x = 0; x < 64; x++) {
        pixels[x * 64 + y] = matrix[x][y];
      }
    }
    return Sprite(pixels);
  }
}
