From 1ea2ccda9596582c6c212a8e1c9c077753701ad8 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 18 Apr 2025 13:47:00 +0200 Subject: [PATCH] roads: Added road building Roads now will need to check adjacent tiles to draw the correct tile. --- src/buildings.s | 6 +++++- src/player.s | 18 +++++++++--------- src/state.s | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/buildings.s b/src/buildings.s index 92fca86..021dd92 100644 --- a/src/buildings.s +++ b/src/buildings.s @@ -1,3 +1,7 @@ +#define BUILDING_ROAD_NORTH_SOUTH 0x77 +#define BUILDING_ROAD_WEAT_EAST 0x78 + + ; places a building at the current cursor position ; performs pre-checks and displays an error ; if pre-conditions for building fail @@ -16,7 +20,7 @@ build_road: call cursor_get_cell call cursor_get_tile - ld a, UI_TILE_ROAD + ld a, BUILDING_ROAD_NORTH_SOUTH call bg_update_queue_push ldnull bc diff --git a/src/player.s b/src/player.s index f4e1935..37e9e63 100644 --- a/src/player.s +++ b/src/player.s @@ -80,6 +80,15 @@ player_draw_cursor: ret handle_inputs: + input_held BTNA + jr z, @not_a REL + + ; next state: building state + call building_build +@not_a: + + ; movement keys with cooldown + input_held BTNDOWN jr z, @notdown REL @@ -151,15 +160,6 @@ handle_inputs: ld bc, st_ui_building_selector ret @not_select: - - input_just BTNA - jr z, @not_a REL - - ; next state: building state - call building_build - ldnull bc - ret -@not_a: @done: ldnull bc ret diff --git a/src/state.s b/src/state.s index 914e081..d3d93af 100644 --- a/src/state.s +++ b/src/state.s @@ -93,7 +93,7 @@ st_ui_building_selector: st_ui_building_selector_delay: st_def CURSOR_MOVE_TIMER, st_null_fn, st_ui_building_selector st_ui_buildung_selector_exit: - st_def 0, ui_building_selector_exit, st_cursor + st_def 8, ui_building_selector_exit, st_cursor st_update_game: st_def 0x00, update_game, st_update_game -- 2.30.2