diff options
author | cflip <cflip@cflip.net> | 2022-01-24 17:45:49 -0700 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2022-01-24 17:45:49 -0700 |
commit | d82cd8b91a8d155b2d0ed4328f12dc88667cc51c (patch) | |
tree | 22dad0a25341edc97d383778a81eac4e7c16d079 | |
parent | 98e2eb0beed4f57461956a10eeae014bf88a51c6 (diff) |
Automatically align adjacent tracks
-rw-r--r-- | main.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; |