add random rotation option

This commit is contained in:
Sven Balzer 2025-02-28 16:16:21 +01:00
parent 0d875d23ae
commit ebddc0dfe2

View File

@ -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();