roads: Added road building
authorLukas Krickl <lukas@krickl.dev>
Fri, 18 Apr 2025 11:47:00 +0000 (13:47 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 18 Apr 2025 11:47:00 +0000 (13:47 +0200)
Roads now will need to check adjacent tiles to draw the correct tile.

src/buildings.s
src/player.s
src/state.s

index 92fca865d7871a25ab7ec2541f3db90a8cfab893..021dd92063b7947942abb9a3f2cd4ab27f22f13f 100644 (file)
@@ -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
index f4e19353cf1691dedaaa434a2bb84277af7ff3f7..37e9e6386b87ebbcf609aecf5620425e641b0248 100644 (file)
@@ -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
index 914e0814235ab7e326ef8b89587b3675aed1dea4..d3d93afea57cee3ab2aa430fb1024bb7b0527334 100644 (file)
@@ -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