summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-02-02 13:48:11 +0500
committerilotterytea <iltsu@alright.party>2025-02-02 13:48:11 +0500
commit1bb2be007fb9eb2bb9f8aada2781c9f975f9627e (patch)
tree089194d24f31593e43eb35ecc24e254d8c86ab10
parent0b04d57ba473cd4024ef4a522861340a672b19d2 (diff)
feat: wall building
-rw-r--r--src/level.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/level.cpp b/src/level.cpp
index efc2038..4fc7d2c 100644
--- a/src/level.cpp
+++ b/src/level.cpp
@@ -6,6 +6,7 @@
#include <SFML/System/Angle.hpp>
#include <SFML/System/Vector2.hpp>
#include <algorithm>
+#include <cstdlib>
#include <iterator>
#include <string>
@@ -48,6 +49,17 @@ namespace silly::editor {
for (auto it = layer.tiles.begin(); it != layer.tiles.end(); ++it) {
if (it->position != position) continue;
+ float r = it->rotation;
+
+ if (rotation == 270.0f && r == 0.0f) {
+ r = 360.0f;
+ }
+
+ // wall building
+ if (it->tile->type == TILE_WALL && std::abs(r - rotation) == 90.0f) {
+ break;
+ }
+
it->rotation = rotation;
it->tile = tile;
placed = true;