Add correct array rotation code

This commit is contained in:
Pyrex 2023-09-19 21:58:31 -07:00
parent 04b580b22c
commit b91f3097f2

View File

@ -269,11 +269,11 @@ class Vault {
}
// TODO: Actually test this logic.
// It feels right in my head but that doesn't mean it's right
// This worked in Python, so it might even be right!
Vault rotateRight() {
List<LevelTile> tiles2 = [
for (var x = 0; x < vx; x++)
for (var y = 0; y < vy; y++) tiles[y * vx + x]
for (var y = 0; y < vy; y++) tiles[(vy - 1 - y) * vx + x]
];
return Vault(tiles2, vy, vx, smooth.rotateRight());
@ -282,7 +282,7 @@ class Vault {
Vault rotateLeft() {
List<LevelTile> tiles2 = [
for (var x = vx - 1; x >= 0; x++)
for (var y = vy - 1; y >= 0; y++) tiles[y * vx + x]
for (var y = vy - 1; y >= 0; y++) tiles[y * vx + (vx - 1 - x)]
];
return Vault(tiles2, vy, vx, smooth.rotateLeft());