wip: iframe timer
authorLukas Krickl <lukas@krickl.dev>
Tue, 8 Oct 2024 04:43:51 +0000 (06:43 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 8 Oct 2024 04:43:51 +0000 (06:43 +0200)
src/player.s
src/wram.s

index f7d26c118686506b97db6e2459a76f5a1f2f7225..e5076ab322c9a87bc6c35789fe570009a5118260 100644 (file)
@@ -5,6 +5,7 @@
 .def int PLAYER_TILE_IDLE2 = 0x1E
 .def int PLAYER_TILE_IDLE3 = 0x2E
 
+#define PLAYER_IFRAME_TIMER 8
 #define DAMAGE_ANIM_LEN 20
 
   ; init the player 
@@ -109,8 +110,7 @@ player_update:
   ; make sure we do not mess with hl
   push hl
   ; hl = player_x right now 
-  inc hl
-  inc hl ; hl = player_hp
+  dec hl ; hl = player_y == player_base 
   call player_take_damage
   ; call for UI redraw 
   ld a, UI_REDRAW_HP 
@@ -224,11 +224,30 @@ player_use_resource:
 
   ; same as use_resource but specifically 
   ; also starts a damage animation
+  ; and iframes 
+  ; inputs:
+  ;   [hl]: pointer to player  
+  ;     a : the amount to subtract
 player_take_damage:
-  ld [tmp], a
+  ld [tmp], a ; tmp store a
+
+  ; set damage anim timer 
   ld a, DAMAGE_ANIM_LEN 
   ld [damage_anim], a
-  ld a, [tmp]
+
+  ; set iframe timer
+  ld a, PLAYER_IFRAME_TIMER 
+  push hl
+  ld e, player_timer_i
+  ld d, 0
+  add hl, de ; hl = timer_ia
+  ld [hl], a
+  pop hl
+
+  ld e, player_hp
+  ld d, 0
+  add hl, de
+  ld a, [tmp] ; a = tmp 
   jp player_use_resource
 
   ; gains a resource such as
index 76eae6da21f399501cff6e7ec106d88e273026b8..8a9c8e1a20927a7a4bc51d959c0fc14d3190afe8 100644 (file)
@@ -51,6 +51,12 @@ actor_table: .adv ACTORS_MAX * actor_size
 .de player_atk, 1
 .de player_atk_max, 1
 
+  ; player timer:
+  ;   differnt timers for the player
+  ;   iframe (i)
+  ;   layout:
+  ;     iiiiiiii
+.de player_timer_i, 1
 .de player_size, 0
 
 player: .adv player_size