.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
; 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
; 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