summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2022-01-24 17:45:49 -0700
committercflip <cflip@cflip.net>2022-01-24 17:45:49 -0700
commitd82cd8b91a8d155b2d0ed4328f12dc88667cc51c (patch)
tree22dad0a25341edc97d383778a81eac4e7c16d079
parent98e2eb0beed4f57461956a10eeae014bf88a51c6 (diff)
Automatically align adjacent tracks
-rw-r--r--main.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
index 8af8922..9e3b621 100644
--- a/main.cpp
+++ b/main.cpp
@@ -91,6 +91,11 @@ int main(int argc, char **argv)
window.onMouseDown([&](int button, int x, int y) {
if (button == 1) {
+ static const auto update_direction = [&](int xt, int yt) {
+ if (level.get(xt, yt) > 0)
+ level.set(xt, yt, ChooseDirection(level, xt, yt));
+ };
+
float mx = x / Scale + xOffs;
float my = y / Scale + yOffs;
Point2D tilePos = screenToTile({ mx, my });
@@ -102,6 +107,11 @@ int main(int argc, char **argv)
else tile = ChooseDirection(level, tilePos.x, tilePos.y);
level.set(tilePos.x, tilePos.y, tile);
+
+ update_direction(tilePos.x - 1, tilePos.y);
+ update_direction(tilePos.x + 1, tilePos.y);
+ update_direction(tilePos.x, tilePos.y - 1);
+ update_direction(tilePos.x, tilePos.y + 1);
}
} else if (button == 2 && !isDragging) {
xDrag = x;