Added atk and def bars
authorLukas Krickl <lukas@krickl.dev>
Sat, 5 Oct 2024 14:07:36 +0000 (16:07 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sat, 5 Oct 2024 14:07:36 +0000 (16:07 +0200)
src/player.s
src/ui.s
src/wram.s

index 322ff0bb6c2243ddc81b31fe50166171e19def3c..7c319d3ddcebcec01da9341560f4027b66f9d9db 100644 (file)
@@ -29,11 +29,13 @@ player_init:
 
   ; default def 
   ld a, PLAYER_DEFAULT_DEF 
-  ld [hl+], a
+  ld [hl+], a ; def
+  ld [hl+], a ; def max
 
   ; default atk 
   ld a, PLAYER_DEFAULT_ATK
-  ld [hl+], a
+  ld [hl+], a ; atk 
+  ld [hl+], a ; atk max
 
   ret
 
index 18917c932fb21f56bab7c4a444e30dfeca6cce34..146cee54e3a950134854babd74834640d9b20260 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -9,7 +9,7 @@
   ; only call during blanking
 ui_init:
   ; darw mp and hp on first frame 
-  ld a, UI_REDRAW_HP | UI_REDRAW_MP 
+  ld a, UI_REDRAW_HP | UI_REDRAW_MP | UI_REDRAW_ATK | UI_REDRAW_DEF
   ld [ui_flags], a
   
   ; hp icon 
@@ -69,6 +69,16 @@ ui_draw_mp_bar:
   ; directly jump without a return
   jp ui_draw_bar 
 
+ui_draw_atk_bar:
+  ld hl, SCRN0_UI+SCRN_W+1
+  ld de, player + player_atk
+  jp ui_draw_bar
+
+ui_draw_def_bar:
+  ld hl, SCRN0_UI+SCRN_W+11
+  ld de, player + player_def
+  jp ui_draw_bar
+
   ; update the UI 
   ; this should only be called 
   ; during blanking 
@@ -87,6 +97,16 @@ ui_draw:
   and a, UI_REDRAW_HP 
   call nz, ui_draw_mp_bar 
 
+  ; check if we should draw atk bar 
+  ld a, [ui_flags]
+  and a, UI_REDRAW_ATK
+  call nz, ui_draw_atk_bar
+
+  ; check if we should draw def bar 
+  ld a, [ui_flags]
+  and a, UI_REDRAW_DEF
+  call nz, ui_draw_def_bar
+
   ; set flags to 0 
   xor a, a
   ld [ui_flags], a
index ce2ba56eae76f686f55c7852d9b67968fc17fa46..de1c43c2516f182a69961f5414effd941add01d6 100644 (file)
@@ -47,7 +47,9 @@ actor_table: .adv ACTORS_MAX * actor_size
 .de player_mp, 1
 .de player_mp_max, 1
 .de player_def, 1
+.de player_def_max, 1
 .de player_atk, 1
+.de player_atk_max, 1
 
 .de player_size, 0