From ca92b73bc8eca1c7775f52bd94f81b61de74d988 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Tue, 26 Nov 2024 15:07:01 +0100 Subject: [PATCH] Added simple player animation --- src/actor.s | 19 ------------------- src/player.s | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/actor.s b/src/actor.s index fbda9c9..7b1f220 100644 --- a/src/actor.s +++ b/src/actor.s @@ -31,24 +31,6 @@ ld [actor_soam_ptr], a #endmacro - ; loads an animation frame - ; from a table - ; uses hl and a - ; inputs: - ; $1: table - ; $2: max frames (mask) - ; returns: - ; a: the frame -#macro load_anim_frame - ld hl, $1 - ld a, [frame_count] - and a, $2 ; max frames - ld d, 0 - ld e, a - add hl, de ; hl = correct tile index - ld a, [hl] -#endmacro - actor_anim_table_bat: .db BAT_TILE_IDLE1 .db BAT_TILE_IDLE1 @@ -66,7 +48,6 @@ actor_anim_table_bat: .db BAT_TILE_IDLE2 .db BAT_TILE_IDLE2 .db BAT_TILE_IDLE2 -.db BAT_TILE_IDLE2 ; function ptrs for each actor type diff --git a/src/player.s b/src/player.s index 9fb75ee..39a928f 100644 --- a/src/player.s +++ b/src/player.s @@ -4,6 +4,14 @@ .def int PLAYER_TILE_IDLE1 = 0x00 .def int PLAYER_TILE_IDLE2 = 0x12 +.def int PLAYER_TILE_MOVE_FRAME1_1 = 0x02 +.def int PLAYER_TILE_MOVE_FRAME2_1 = 0x10 + +player_anim_table1: +.rep c, 2, 1, .db PLAYER_TILE_IDLE1 +.rep c, 7, 1, .db PLAYER_TILE_MOVE_FRAME1_1 +.rep c, 7, 1, .db PLAYER_TILE_MOVE_FRAME2_1 + #define PLAYER_IFRAME_TIMER 64 #define DAMAGE_ANIM_LEN 20 @@ -56,7 +64,7 @@ player_init: push de ; 2) hl = player_y already - ; 3) load correct collision points +; 3) load correct collision points ld de, $1 call collision_tile_table_check pop de @@ -289,6 +297,12 @@ player_update: ret @draw_visible: + ; load left tile into tmp + push de + load_anim_frame player_anim_table1, 0b1111 + ld [tmp], a + pop de + ; drawing ; set up obj flag mask based on frame counter @@ -310,7 +324,7 @@ player_update: ld [hl+], a ; idel tile 1 - ld a, PLAYER_TILE_IDLE1 + ld a, [tmp] ld [hl+], a ; flags -- 2.30.2