From: Lukas Krickl Date: Tue, 8 Oct 2024 15:05:36 +0000 (+0200) Subject: Added simple flashing animation for iframes X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=f993c676e7e2c6fc843929c33cec446cfdaf762a;p=gbrg%2F.git Added simple flashing animation for iframes --- diff --git a/src/player.s b/src/player.s index bc8d1e6..3b39871 100644 --- a/src/player.s +++ b/src/player.s @@ -5,7 +5,7 @@ .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 @@ -55,10 +55,6 @@ player_update: ; 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 @@ -137,12 +133,56 @@ player_update: 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