diff options
| author | ilotterytea <iltsu@alright.party> | 2025-01-31 01:24:39 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-01-31 01:24:39 +0500 |
| commit | ea1c0a112de752ef9dea2d9bfabcbf5ea3254be7 (patch) | |
| tree | 9375f291a759009d6e8ee2d8ab5ea4b3fdce9bb5 /src/editor.c | |
| parent | a15f24294d5113fec767fb9007d906f534dc0485 (diff) | |
feat: tile rotation
Diffstat (limited to 'src/editor.c')
| -rw-r--r-- | src/editor.c | 32 |
1 files changed, 32 insertions, 0 deletions
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}; |
