From ebddc0dfe2288de67ceb64b716e56233a0d15743 Mon Sep 17 00:00:00 2001 From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com> Date: Fri, 28 Feb 2025 16:16:21 +0100 Subject: [PATCH] add random rotation option --- src/main.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 477aae7..f43ac2e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -844,7 +844,7 @@ int main(int argc, char **argv) { if (available >= 32) ImGui::SameLine(); - if (SelectableImage("##tile", selected_tile == i, &texture_binding, ImVec2(32, 32), uv0, uv1, selected_rotation)) + if (SelectableImage("##tile", selected_tile == i, &texture_binding, ImVec2(32, 32), uv0, uv1, SDL_max(selected_rotation, 0))) selected_tile = i; ImGui::PopID(); @@ -876,6 +876,9 @@ int main(int argc, char **argv) { if (SelectableImage("##270", selected_rotation == 3, &texture_binding, ImVec2(32, 32), uv0, uv1, 3)) selected_rotation = 3; + + if (ImGui::Selectable("Random", selected_rotation == -1)) + selected_rotation = -1; } } ImGui::End(); @@ -980,8 +983,14 @@ int main(int argc, char **argv) { if (selected_tile != -1) { if(0 <= tile_x && tile_x < map_width && - 0 <= tile_y && tile_y < map_height) - map_tiles[tile_x + map_width * tile_y] = (selected_rotation << 16) | selected_tile; + 0 <= tile_y && tile_y < map_height) { + if (selected_rotation == -1) { + Sint32 rotation = SDL_rand(4); + map_tiles[tile_x + map_width * tile_y] = ((rotation & 3) << 16) | selected_tile; + } else { + map_tiles[tile_x + map_width * tile_y] = ((selected_rotation & 3) << 16) | selected_tile; + } + } } SDL_Keymod modifiers = SDL_GetModState();