ui: wip hp display
authorLukas Krickl <lukas@krickl.dev>
Fri, 17 Oct 2025 06:04:52 +0000 (08:04 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 17 Oct 2025 06:04:52 +0000 (08:04 +0200)
src/defs.s
src/player.s
src/ui.s

index 3ca6774cd0ae683d00b302beaee9c904d0a58bb0..e89b5f8a62bb365f2bec3883bf1f1001c242f1f8 100644 (file)
@@ -18,6 +18,7 @@
 #define ACTS_ENEMY_PROJECTILES 6
 #define ACTS_MAX (ACTS_PLAYER_PROJECTILES + ACTS_ENEMY + ACTS_ENEMY_PROJECTILES) 
 
+#define HP_MAX 20
 
 #define MAP_OBJ_MAX 32
 #define RECT_MAX 4
index debbaf7bbf3de75421d1f756bf5b56985250c28f..f56a47e6133b0f36eace635cba3ec08c2efa4e69 100644 (file)
@@ -13,7 +13,7 @@ player_init:
        ld a, 0x30 ; initial next scroll
        ld [player_next_scroll_y], a
 
-       ld a, 10
+       ld a, HP_MAX
        ld [player+act_hp], a
        ret
        
index 3721c449d7b576e532a48ffd5fcf4632da651a94..6003c442aa5df51c998569bbf92bd83a774032c1 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -9,6 +9,12 @@
 ; one tile after 'Z'
 #define UI_WINDOW_BACKGROUND 0xF4  
 
+#define UI_TILE_HP_4 0xC8
+#define UI_TILE_HP_3 0xC9
+#define UI_TILE_HP_2 0xCA
+#define UI_TILE_HP_1 0xCB
+
+
 strz str_player, "PLAYER"
 strz str_enemy, "ENEMY"
 
@@ -30,9 +36,18 @@ ui_draw_player_hp:
        ld hl, str_player
        call puts
 
-       ld de, UI_PLAYER_HP+7
+       ld hl, UI_PLAYER_HP+7
        ld a, [player+act_hp]
-       call putn
+       jp ui_draw_hp
+       
+       ; draws generic hp
+       ; inputs:
+       ;               hl: address to draw to
+       ;                b: current hp
+ui_draw_hp:
+       ld a, UI_TILE_HP_4
+       ld [hl+], a
+
        ret
 
        ; draws boss hp