diff options
Diffstat (limited to 'src/editor.c')
| -rw-r--r-- | src/editor.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/editor.c b/src/editor.c index 7d7c04f..b10da62 100644 --- a/src/editor.c +++ b/src/editor.c @@ -39,7 +39,8 @@ void SE_DrawEditor(Editor *editor, Camera2D *camera) { DrawRectangleLines(rx, ry, zoom, zoom, BLACK); if ((rx < mousePos.x && mousePos.x < rx + zoom) && - (ry < mousePos.y && mousePos.y < ry + zoom)) { + (ry < mousePos.y && mousePos.y < ry + zoom) && + GetMousePosition().x < EDITOR_TOOLKIT_X) { // rendering selected tile if (editor->state.selectedTile != NULL) { EditorTileData *t = editor->state.selectedTile; @@ -49,8 +50,7 @@ void SE_DrawEditor(Editor *editor, Camera2D *camera) { DrawTexturePro(t->texture, s, d, (Vector2){0, 0}, 0.0f, WHITE); // placing tiles - if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) && - GetMousePosition().x < EDITOR_TOOLKIT_X) { + if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) { EditorTile *t = NULL; // checking for existing tiles on the position for (int i = 0; i < editor->state.cache.tilesCount; i++) { @@ -73,6 +73,20 @@ void SE_DrawEditor(Editor *editor, Camera2D *camera) { t->tile = editor->state.selectedTile; } + + // removing tiles + if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) { + for (int i = 0; i < editor->state.cache.tilesCount; i++) { + EditorTile *tt = editor->state.cache.tiles[i]; + if (tt == NULL) continue; + + if (tt->position.x == x && tt->position.y == y) { + free(tt); + editor->state.cache.tiles[i] = NULL; + break; + } + } + } } } } |
