Add correct array rotation code
This commit is contained in:
parent
04b580b22c
commit
b91f3097f2
@ -269,11 +269,11 @@ class Vault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Actually test this logic.
|
// 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() {
|
Vault rotateRight() {
|
||||||
List<LevelTile> tiles2 = [
|
List<LevelTile> tiles2 = [
|
||||||
for (var x = 0; x < vx; x++)
|
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());
|
return Vault(tiles2, vy, vx, smooth.rotateRight());
|
||||||
@ -282,7 +282,7 @@ class Vault {
|
|||||||
Vault rotateLeft() {
|
Vault rotateLeft() {
|
||||||
List<LevelTile> tiles2 = [
|
List<LevelTile> tiles2 = [
|
||||||
for (var x = vx - 1; x >= 0; x++)
|
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());
|
return Vault(tiles2, vy, vx, smooth.rotateLeft());
|
||||||
|
Loading…
Reference in New Issue
Block a user