diff options
author | Astatin <[email protected]> | 2025-02-27 17:06:33 +0900 |
---|---|---|
committer | Astatin <[email protected]> | 2025-02-27 17:06:33 +0900 |
commit | 398c9d42b691bc633d22dff85bc2ac29ed635efa (patch) | |
tree | 21de30112ea1a49f2f064b4d8322cfba4015cfcb /entity | |
parent | b21954eb05d9285ed7542a1f42ed755a147782a8 (diff) |
Fix entities and objects spawning on top of each other
Diffstat (limited to 'entity')
-rw-r--r-- | entity/init.gbasm | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/entity/init.gbasm b/entity/init.gbasm index 60edff6..d035820 100644 --- a/entity/init.gbasm +++ b/entity/init.gbasm @@ -48,7 +48,20 @@ Initialize_Entities: INC A CALL =RNG_Bound ADD D - LD (HL+), A + + LD (HL), A + + PUSH BC + LD C, (HL) + DEC HL + LD B, (HL) + INC HL + + CALL =Carve_Entity_Collision_Map + + POP BC + + INC HL LD A, $enum_direction_down LD (HL+), A @@ -152,6 +165,7 @@ Initialize_Enemy: ; HL => pointer to entity struct LD B, high($mem_room_list) + ; X LD A, (BC) LD D, A INC BC @@ -172,7 +186,33 @@ Initialize_Enemy: ; HL => pointer to entity struct INC A CALL =RNG_Bound ADD D - LD (HL+), A + LD (HL), A + + ; Check if spawning on collisionable tile + PUSH BC + LD C, (HL) + DEC HL + LD B, (HL) + INC HL + + CALL =Is_Collisionable + CP $00 + JR Z, =.no_collision + + XOR A + LD (HL-), A + LD (HL-), A + LD (HL-), A + + POP BC + RET + + .no_collision: + CALL =Carve_Entity_Collision_Map + + POP BC + + INC HL ; Direction LD A, $03 |