action: Added tile offset to attack action
authorLukas Krickl <lukas@krickl.dev>
Mon, 18 Aug 2025 03:28:22 +0000 (05:28 +0200)
committerLukas Krickl <lukas@krickl.dev>
Mon, 18 Aug 2025 03:28:22 +0000 (05:28 +0200)
src/action.s

index 3b77df74bcc1d47bbdb3c3939e08b4336c496164..5634416fdc0a6ec5409bae6c4b7998f8e7359d01 100644 (file)
@@ -131,11 +131,32 @@ unit_action_attack:
        push de
        ; get location
        call unit_get_pos
+       
+       ld hl, act_rt_action_dat1
+       add hl, de ; hl = dat1
 
-       ld de, act_rt_action_dat1
-       add hl, de
-       ; TODO determine where to draw animation
+       ; determine where to draw animation
        ld a, [hl] ; a = direction pressed
+       cp a, DIRUP
+       jr nz, @not_up REL
+               dec b ; y--
+@not_up:
+
+       cp a, DIRDOWN
+       jr nz, @not_down REL
+               inc b ; y++
+@not_down:
+       
+       cp a, DIRLEFT
+       jr nz, @not_left REL
+               dec c ; x--
+@not_left:
+       
+       cp a, DIRRIGHT
+       jr nz, @not_right REL
+               inc c ; x++
+@not_right:
+
 
        ; draw a slash animation at that location
        push bc