.def int PLAYER_TILE_IDLE2 = 0x1E
.def int PLAYER_TILE_IDLE3 = 0x2E
-#define PLAYER_IFRAME_TIMER 8
+#define PLAYER_IFRAME_TIMER 64
#define DAMAGE_ANIM_LEN 20
; init the player
; e: player_x
; b: obj flags mask
- ; set up obj flag mask based on frame counter
- ld a, [frame_count]
- and a, 4
- ld b, 0
; input handling
input_held BTNDOWN
pop hl
@notb:
-
- ; drawing
-
; sotre x in e
ld a, [hl]
ld e, a
+
+ ; hl is ok to use again
+ ; bc is free
+ ; de is still used
+
+ ; check if i-frame
+ ; if iframe is divisible by 2
+ ; flash all sprites off
+ ; otherwise continue with regular code
+ ; hl = player_x
+ dec hl ; hl = player_y = player start
+ ld bc, player_timer_i
+ add hl, bc ; hl = timer now
+ ld a, [hl]
+ cp a, 0
+ jr z, @draw_visible REL
+
+ dec a
+ ld [hl], a ; timer--
+ inc a
+
+ and a, 4 ; blink every 4 frames
+ jr z, @draw_visible REL
+
+@hide_player:
+
+ ; hide 3 player sprites
+ ld a, 0
+ ld hl, PLAYER_SPRITE1
+ ld [hl+], a
+ ld [hl+], a
+ ld hl, PLAYER_SPRITE1+4
+ ld [hl+], a
+ ld [hl+], a
+ ld hl, PLAYER_SPRITE1+8
+ ld [hl+], a
+ ld [hl+], a
+
+ ret
+@draw_visible:
+ ; drawing
+
+ ; set up obj flag mask based on frame counter
+ ; b is now not free anymore!
+ ld a, [frame_count]
+ and a, 4
+ ld b, 0
; obj 1
ld hl, PLAYER_SPRITE1