From: Lukas Krickl Date: Sun, 2 Feb 2025 09:58:41 +0000 (+0100) Subject: animation: made walk speed more easily adjustable X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=0cd468bb4e812630b739c19c476ffa2c5788f102;p=gbrg%2F.git animation: made walk speed more easily adjustable --- diff --git a/src/animation.s b/src/animation.s index 76b49f2..9abf931 100644 --- a/src/animation.s +++ b/src/animation.s @@ -6,24 +6,24 @@ ; sm_param[0]: frames to walk for anim_walk_north: inc bc ; bc = actor y - ld d, 0xFF ; walk back + ld d, 0xFF & 0 - ANIM_WALK_SPEED ; walk back jp anim_walk_generic anim_walk_south: inc bc ; bc = actor y - ld d, 1 ; walk forward + ld d, ANIM_WALK_SPEED ; walk forward jp anim_walk_generic anim_walk_east: inc bc inc bc ; bc = actor x - ld d, 1 ; walk forward + ld d, ANIM_WALK_SPEED ; walk forward jp anim_walk_generic anim_walk_west: inc bc inc bc ; bc = actor x - ld d, 0xFF ; walk back + ld d, 0xFF & 0 - ANIM_WALK_SPEED ; walk back jp anim_walk_generic ; generic version of anim walk diff --git a/src/defs.s b/src/defs.s index bf16bbf..c94acac 100644 --- a/src/defs.s +++ b/src/defs.s @@ -55,7 +55,9 @@ #define ANIM_STEP_UP 0xFF #define ANIM_STEP_RIGHT 1 -#define ANIM_PLAYER_WALK_FRAMES 16 +#define ANIM_WALK_SPEED 1 +#define ANIM_TILE_SIZE 16 +#define ANIM_PLAYER_WALK_FRAMES (ANIM_TILE_SIZE / ANIM_WALK_SPEED) ; actor type enum .se 0 diff --git a/src/state.s b/src/state.s index bb62b89..e176932 100644 --- a/src/state.s +++ b/src/state.s @@ -49,7 +49,7 @@ sm_player_poll_inputs: ld [hl], a ; set param[0] ; perform collision check - ld d, ANIM_PLAYER_WALK_FRAMES + ld d, ANIM_TILE_SIZE ld e, 0 call player_collision_check @@ -67,7 +67,7 @@ sm_player_poll_inputs: ; perform collision check - ld d, 0xFF & 0 - ANIM_PLAYER_WALK_FRAMES + ld d, 0xFF & 0 - ANIM_TILE_SIZE ld e, 0 call player_collision_check @@ -85,7 +85,7 @@ sm_player_poll_inputs: ; perform collision check ld d, 0 - ld e, 0xFF & 0 - ANIM_PLAYER_WALK_FRAMES + ld e, 0xFF & 0 - ANIM_TILE_SIZE call player_collision_check ret @@ -102,7 +102,7 @@ sm_player_poll_inputs: ; perform collision check ld d, 0 - ld e, ANIM_PLAYER_WALK_FRAMES + ld e, ANIM_TILE_SIZE call player_collision_check ret