From 0e54014bc2b599620ced6ecd2c4e4144b734c7bb Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 26 Jan 2025 23:20:47 +0500 Subject: upd: remove null tiles --- src/editor.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/editor.c b/src/editor.c index b10da62..d12d31b 100644 --- a/src/editor.c +++ b/src/editor.c @@ -15,6 +15,24 @@ const char *EDITOR_MAIN_TABS[] = {"Build"}; const int EDITOR_MAIN_TABS_SIZE = sizeof(EDITOR_MAIN_TABS) / sizeof(EDITOR_MAIN_TABS[0]); +void removeNullTiles(Editor *editor) { + int i, j = 0; + EditorTile **tiles = editor->state.cache.tiles; + int *count = &editor->state.cache.tilesCount; + + for (i = 0; i < *count; i++) { + if (tiles[i] != NULL) { + tiles[j++] = tiles[i]; + } + } + + *count = j; + + for (i = j; i < *count; i++) { + tiles[i] = NULL; + } +} + void SE_DrawEditor(Editor *editor, Camera2D *camera) { Vector2 mousePos = GetScreenToWorld2D(GetMousePosition(), *camera); float zoom = camera->zoom; @@ -91,6 +109,8 @@ void SE_DrawEditor(Editor *editor, Camera2D *camera) { } } } + + removeNullTiles(editor); } void drawBuildTab(Editor *editor, int x, int y, int width, int height) { -- cgit v1.2.3