; sotre x in e
ld a, [hl]
ld e, a
-
- ; if any collision happens now
- ; we stop the animation
- push hl ; need to save hl
+
ld a, [anim_target_y]
add a, 8
ld d, a ; d = target y + 8 to center on tile
ld a, [anim_target_x]
add a, 8
ld e, a ; e = target x + 8 to center on tile
- call collision_tile
- ld h, a ; store original a in h for now
-
- and a, RF_DOOR
- jr z, @no_door_hit REL
-
- ; set room load flag is door was hit
- ld a, [engine_flags]
- or a, EG_FLOAD_ROOM
- ld [engine_flags], a
-
-
-@no_door_hit:
-
- ld a, h ; restore original a for next check
- and a, RF_ACTOR
- jr z, @no_enemy_hit REL
-
- ; TODO add enemy hit logic
-
-@no_enemy_hit:
-
- ld a, h ; restore original a for next check
- and a, RF_WALL | RF_ACTOR
- pop hl
-
- jr z, @no_collision REL
- ; clear anim memory
- call anim_clear
- jr @skip_input REL
-@no_collision:
- ; call z, player_tile_update_rf_flags
+ call player_collision_check
@skip_input:
; hl should be player_y here
ret
+ ; performs player collision checks
+ ; inputs:
+ ; hl: player ptr
+ ; de: y/x position used for check
+player_collision_check:
+ ; if any collision happens now
+ ; we stop the animation
+ push hl ; need to save hl
+ call collision_tile
+ ld h, a ; store original a in h for now
+
+ and a, RF_DOOR
+ jr z, @no_door_hit REL
+
+ ; set room load flag is door was hit
+ ld a, [engine_flags]
+ or a, EG_FLOAD_ROOM
+ ld [engine_flags], a
+
+
+@no_door_hit:
+
+ ld a, h ; restore original a for next check
+ and a, RF_ACTOR
+ jr z, @no_enemy_hit REL
+
+ ; TODO add enemy hit logic
+
+@no_enemy_hit:
+
+ ld a, h ; restore original a for next check
+ and a, RF_WALL | RF_ACTOR
+ pop hl
+
+ jr z, @no_collision REL
+ ; clear anim memory
+ call anim_clear
+ jr @skip REL
+@no_collision:
+ ; call z, player_tile_update_rf_flags
+@skip:
+ ret
+
; uses a resource such as
; hp, mp, atk or def down to 0
; inputs: