diff options
Diffstat (limited to 'Source/Puzzle.cpp')
-rw-r--r-- | Source/Puzzle.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/Puzzle.cpp b/Source/Puzzle.cpp index d0ede27..2f399a7 100644 --- a/Source/Puzzle.cpp +++ b/Source/Puzzle.cpp | |||
@@ -27,6 +27,25 @@ void Puzzle::NewGrid(int newWidth, int newHeight) { | |||
27 | for (int x=0; x<width; x++) grid[x].resize(height); | 27 | for (int x=0; x<width; x++) grid[x].resize(height); |
28 | } | 28 | } |
29 | 29 | ||
30 | Pos Puzzle::GetSymmetricalPos(int x, int y) const { | ||
31 | if (symmetry != Symmetry::NONE) { | ||
32 | if (pillar) { | ||
33 | x += width/2; | ||
34 | if (symmetry & Symmetry::X) { | ||
35 | x = width - x; | ||
36 | } | ||
37 | } else { | ||
38 | if (symmetry & Symmetry::X) { | ||
39 | x = (width-1) - x; | ||
40 | } | ||
41 | } | ||
42 | if (symmetry & Symmetry::Y) { | ||
43 | y = (height-1) - y; | ||
44 | } | ||
45 | } | ||
46 | return Pos{x, y}; | ||
47 | } | ||
48 | |||
30 | int Puzzle::Mod(int x) const { | 49 | int Puzzle::Mod(int x) const { |
31 | if (!pillar) return x; | 50 | if (!pillar) return x; |
32 | return (x + width * height * 2) % width; | 51 | return (x + width * height * 2) % width; |