player: improved collision box
authorLukas Krickl <lukas@krickl.dev>
Tue, 9 Dec 2025 14:32:06 +0000 (15:32 +0100)
committerLukas Krickl <lukas@krickl.dev>
Tue, 9 Dec 2025 14:32:06 +0000 (15:32 +0100)
gravity: gravity now peaks jump if it is being applied

src/actor.s
src/player.s

index 3354a64c615c15b1deb08b6a2a80f99b4103e3d3..802fde1198a6f961e4047575ce1c17e2a976be1d 100644 (file)
@@ -3,6 +3,9 @@
        ;       sets act_direction to DOWN
        ; inputs:
        ;               de: actor
+       ;       returns:
+       ;               a: != 0 no gravity
+       ;               a: 0 gravity
 act_apply_gravity:
        ld a, [col_direction]
        and a, DIRUP
@@ -17,6 +20,8 @@ act_apply_gravity:
        ld a, [hl]
        inc a
        ld [hl], a
+
+       xor a, a
        ret
 
        ; stores current position in col_prev_pos
index 3dea74f111dc01083156fb8059ec77c6f503bb8e..42c0d155902a4c40cd663e1f6dbc8bce444adb4d 100644 (file)
@@ -5,8 +5,9 @@
 
        ; sets up the player actor
 player_init:
-       xor a, a
+       ld a, 0x5A
        ld [player+act_pos_y], a
+       ld a, 0x47
        ld [player+act_pos_x], a
        
        ret
@@ -25,31 +26,35 @@ player_col_write_points:
        
        ; top left point
        ld a, b 
+       add a, 2
        ld [col_point_tl], a
        ld a, c
+       add a, 2
        ld [col_point_tl+1], a
 
        ; top right point
        ld a, b
+       add a, 2
        ld [col_point_tr], a
 
        ld a, c
-       add a, 16
+       add a, 12
        ld [col_point_tr+1], a
 
        ; bottom left point
        ld a, b
-       add a, 16
+       add a, 14
        ld [col_point_bl], a
        ld a, c
+       add a, 2
        ld [col_point_bl+1], a
 
        ; bottom right points
        ld a, b
-       add a, 16
+       add a, 14
        ld [col_point_br], a
        ld a, c
-       add a, 16
+       add a, 14
        ld [col_point_br+1], a
 
        ; center point
@@ -76,6 +81,11 @@ player_update:
        pop de
        push de
        call act_apply_gravity
+       cp a, 0
+       jr nz, @no_gravity REL
+               ld a, 1
+               ld [player_jump_peak], a
+@no_gravity:
 
        pop de
        call act_test_tile_collision