From: Lukas Krickl Date: Thu, 22 Jan 2026 04:07:21 +0000 (+0100) Subject: player: target is now a vector instead of an absolute position X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=5acf28cd43547a3a623521b5bb985f7c072a43fc;p=gbrg%2F.git player: target is now a vector instead of an absolute position --- diff --git a/src/player.s b/src/player.s index 69f7a84..21fa61e 100644 --- a/src/player.s +++ b/src/player.s @@ -6,12 +6,10 @@ ; $1: inc/dec for y position (e.g. 0, 1, -1) ; $2: inc/dec for x position (e.g. 0, 1, -1) #macro _player_set_target - ld a, [player+act_pos_y] - add a, $1 & 0xFF + ld a, $1 & 0xFF ld [player_target_y], a - ld a, [player+act_pos_x] - add a, $2 & 0xFF + ld a, $2 & 0xFF ld [player_target_x], a #endmacro @@ -119,12 +117,18 @@ player_draw: ; draw target position ; y pos + ld a, [player+act_pos_y] + ld b, a ld a, [player_target_y] + add a, b _act_pos_offset_y ld [hl+], a ; x pos + ld a, [player+act_pos_x] + ld b, a ld a, [player_target_x] + add a, b _act_pos_offset_x ld [hl+], a @@ -157,6 +161,8 @@ player_handle_move: ld b, DIRLEFT input_held jr z, @not_left REL + _player_set_target 0, -1 + ld a, [player+act_pos_x] dec a ld c, a @@ -171,13 +177,13 @@ player_handle_move: cp a, 0 call z, player_moved call player_collided - - _player_set_target 0, -1 @not_left: ld b, DIRRIGHT input_held jr z, @not_right REL + _player_set_target 0, 1 + ld a, [player+act_pos_x] inc a ld c, a @@ -191,13 +197,13 @@ player_handle_move: cp a, 0 call z, player_moved call player_collided - - _player_set_target 0, 1 @not_right: ld b, DIRUP input_held jr z, @not_up REL + _player_set_target -1, 0 + ld a, [player+act_pos_y] dec a ld b, a @@ -208,16 +214,18 @@ player_handle_move: ld de, player call act_move_to + cp a, 0 call z, player_moved call player_collided - _player_set_target -1, 0 @not_up: ld b, DIRDOWN input_held jr z, @not_down REL + _player_set_target 1, 0 + ld a, [player+act_pos_y] inc a ld b, a @@ -227,12 +235,10 @@ player_handle_move: ld de, player call act_move_to - + cp a, 0 call z, player_moved call player_collided - - _player_set_target 1, 0 @not_down: ret diff --git a/src/update.s b/src/update.s index c66cdbc..a137865 100644 --- a/src/update.s +++ b/src/update.s @@ -52,7 +52,7 @@ tick: update_render: call disableinterrupts - + ; enable objects ld a, [RLCD] or a, LCDCF_OBJON diff --git a/src/wram.s b/src/wram.s index 7f99904..4ef3fa4 100644 --- a/src/wram.s +++ b/src/wram.s @@ -93,7 +93,7 @@ player_eq: .adv eq_size ; player view distance radius player_viewradius: .adv 1 - ; player target position + ; player target vector ; used for attacks and casts player_target_y: .adv 1 player_target_x: .adv 1