about summary refs log tree commit diff stats
path: root/Source/Puzzle.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-11-20 20:30:25 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-11-20 20:30:25 -0800
commitd5bce3bba23a5ba4c296f1783ba277bcc206736c (patch)
tree64835daf9aeb54fa779e06426a777861d68195e4 /Source/Puzzle.cpp
parent6f0a34bfb761d965bd961dc1f880b84e35f9959f (diff)
downloadwitness-tutorializer-d5bce3bba23a5ba4c296f1783ba277bcc206736c.tar.gz
witness-tutorializer-d5bce3bba23a5ba4c296f1783ba277bcc206736c.tar.bz2
witness-tutorializer-d5bce3bba23a5ba4c296f1783ba277bcc206736c.zip
Some progress on symmetry.
Diffstat (limited to 'Source/Puzzle.cpp')
-rw-r--r--Source/Puzzle.cpp19
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
30Pos 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
30int Puzzle::Mod(int x) const { 49int 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;