From 6fc06012b675383946873cadf8735d1bcd8d662b Mon Sep 17 00:00:00 2001 From: Sara Date: Tue, 11 Apr 2023 08:11:56 +0200 Subject: [PATCH] updated ui input function --- src/game.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/game.cc b/src/game.cc index b4d28ea..5c6de38 100644 --- a/src/game.cc +++ b/src/game.cc @@ -131,16 +131,15 @@ void load_game() { add_mouse_button_listener(SDL_BUTTON_RMASK, &on_erase); add_mouse_button_listener(SDL_BUTTON_MMASK, &on_middle_mouse); add_mouse_listener(0, &on_drag_world); - } void start_game() { g_active_view.width = 21; + on_clear_key(1); } void update_game() { if(drawing == 1) drawing = 2; - update_input(); mouse_world_position(&cursor.x, &cursor.y); cursor.x += 0.1f; cursor.y += 0.1f; @@ -175,26 +174,27 @@ void update_game() { } void update_ui() { - rectshape_t shape = (rectshape_t){ - 0.0f, 0.0f, 1.f, 0.015f, 0, RLAYER_UI, - {100,100,100,255}, {0,0,0,0} - }; - int w = world_sheet.w / world_sheet.tile_width, - h = world_sheet.h / world_sheet.tile_height, - offset_selected = cursor_tile - 1; + update_input(); + + const int offset_selected = cursor_tile - 1; + rectshape_t selected_tile_rect = (rectshape_t) { offset_selected * 0.015f, 0.f, 0.015f, 0.015f, 0.001f, RLAYER_UI-10, {0,0,0,0}, {255, 255, 255, 255} }; draw_rect(&selected_tile_rect); + + rectshape_t shape = (rectshape_t) { + 0.0f, 0.0f, 1.f, 0.015f, 0, RLAYER_UI, + {100,100,100,255}, {0,0,0,0} + }; draw_rect(&shape); - int i = 0; float mx, my; mouse_screen_position(&mx, &my); - for(auto& original: g_tilemap.tileset.set) { + for(int i=0;i