From ea1c0a112de752ef9dea2d9bfabcbf5ea3254be7 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 31 Jan 2025 01:24:39 +0500 Subject: feat: tile rotation --- src/editor.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/editor.c') diff --git a/src/editor.c b/src/editor.c index 73164f5..425dc64 100644 --- a/src/editor.c +++ b/src/editor.c @@ -25,6 +25,14 @@ void SE_UpdateEditor(Editor *editor) { state->activeTileLayerId = state->activeTilesetTile->type; SE_LOG_INFO("Changed selected layer"); } + + // update tile rotation + if (IsKeyPressed(KEY_R)) { + state->tileRotation += 90.0f; + if (state->tileRotation >= 360.0f) { + state->tileRotation = 0.0f; + } + } } void drawBuildTab(Editor *editor, Tileset *tileset, int x, int y, int width, @@ -60,6 +68,30 @@ void drawBuildTab(Editor *editor, Tileset *tileset, int x, int y, int width, 24.0f}, selectedTileLabel); + // Drawing rotation + GuiLabel((Rectangle){x + padding * 7.0f, y + padding * 2.0f, + width - padding * 2.0f, 24.0f}, + "Rotation"); + + DrawCircle(x + padding * 7.0f + 10.0f, y + padding * 3.0f + 10.0f, 10.0f, + LIGHTGRAY); + + DrawCircleSector( + (Vector2){x + padding * 7.0f + 10.0f, y + padding * 3.0f + 10.0f}, 10.0f, + 0.0f, editor->state.tileRotation, 4, GRAY); + + int rotationTextLength = + snprintf(NULL, 0, "%.0f", editor->state.tileRotation); + char *rotationText = malloc(rotationTextLength + 1); + snprintf(rotationText, rotationTextLength + 1, "%.0f", + editor->state.tileRotation); + + GuiLabel((Rectangle){x + padding * 7.0f + 25.0f, y + padding * 3.0f, + width - padding * 2.0f, 24.0f}, + rotationText); + + free(rotationText); + // Rendering Rectangle controlBounds = {x + padding, y + padding + 20.0f * 8.0f, width - padding * 2.0f, 200.0f}; -- cgit v1.2.3