ret
+ ; creates a copy of the actors position
+ ; in tmp_act_y and _x
+ ; inputs:
+ ; de: actor
+ ; preverse:
+ ; de
+_act_backup_pos:
+ ld hl, act_pos_y
+ add hl, de
+ ld a, [hl+]
+ ld [tmp_act_y], a
+ ld a, [hl]
+ ld [tmp_act_x], a
+ ret
+
+ ; restores actor position
+ ; from tmp_act_y/x
+ ; inputs:
+ ; de: actor
+ ; preserves:
+ ; de
+_act_restore_pos:
+ ld hl, act_pos_y
+ add hl, de
+
+ ld a, [tmp_act_y]
+ ld [hl+], a
+ ld a, [tmp_act_x]
+ ld [hl], a
+ ret
+
+ ; tests if the new actor location contains
+ ; an actor
+ ; rolls back position to tmp_act_y/x if it does
+ ; input:
+ ; de: actor
+ ; preserves:
+ ; de
+_act_check_act_in_location:
+ push de
+ ld hl, act_pos_y
+ add hl, de
+ ld a, [hl+]
+ ld b, a
+ ld c, [hl]
+ call map_get_tile
+ ; hl = tile
+ ld bc, t_act
+ add hl, bc
+
+ ld a, [hl+]
+ or a, [hl]
+ pop de
+ call nz, _act_restore_pos
+ ret
+
; moves the actor forward
; performs collision checks
; inputs:
; de: actor
act_move_forward:
+ call _act_backup_pos
+
push de
ld hl, act_dir_forward
call act_can_move
call act_apply_vec
- ; TODO: check if player collides with actor
+ ; check if player collides with actor
; at new location
-
pop de
+ call _act_check_act_in_location
call act_set_tact
ret
; inputs:
; de: actor
act_move_back:
+ call _act_backup_pos
+
push de
ld hl, act_dir_back
call act_can_move
call act_apply_vec
pop de
+ call _act_check_act_in_location
call act_set_tact
ret
tmp_map_near_right_door: .adv 1
tmp_map_far_left_door: .adv 1
tmp_map_far_right_door: .adv 1
+tmp_act_y: .adv 1
+tmp_act_x: .adv 1
; actor that is adjacent
; to the players current facing