From 7d7d28a737cddf7a5ab68715b114d12dbbb367c4 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 1 Nov 2025 07:49:24 +0100 Subject: [PATCH] player: Added cursor movement fixed cursor rendering --- src/player.s | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/player.s b/src/player.s index 9a98f0e..a1b2713 100644 --- a/src/player.s +++ b/src/player.s @@ -13,6 +13,44 @@ player_init: ; updates the special player actor player_update: call scroll_center_player + + call move_cursor + ret + + ; moves the player cursor + ; does not move out of bounds +move_cursor: + ld b, BTNDOWN + input_held + jr z, @not_down REL + ld a, [player+act_pos_y] + inc a + ld [player+act_pos_y], a +@not_down: + + ld b, BTNUP + input_held + jr z, @not_up REL + ld a, [player+act_pos_y] + dec a + ld [player+act_pos_y], a +@not_up: + + ld b, BTNLEFT + input_held + jr z, @not_left REL + ld a, [player+act_pos_x] + dec a + ld [player+act_pos_x], a +@not_left: + + ld b, BTNRIGHT + input_held + jr z, @not_right REL + ld a, [player+act_pos_x] + inc a + ld [player+act_pos_x], a +@not_right: ret ; draws player at current location @@ -28,7 +66,7 @@ player_draw: ld a, [player+act_pos_y] add a, OBJ_OFF_Y - sub a, b + sub a, b ; - scroll y ; store y for second obj ld [tmp_y], a @@ -38,10 +76,10 @@ player_draw: ; calculate x pos ld a, [scroll_x] ld b, a - sub a, b ld a, [player+act_pos_x] add a, OBJ_OFF_X + sub a, b ; - scroll x ; store x for second obj ld [tmp_x], a -- 2.30.2