wip: point rectangle collision
authorLukas Krickl <lukas@krickl.dev>
Fri, 1 Nov 2024 06:14:11 +0000 (07:14 +0100)
committerLukas Krickl <lukas@krickl.dev>
Fri, 1 Nov 2024 06:14:11 +0000 (07:14 +0100)
src/collision.s

index 33162b7728a2e4a146e28b59f4aad3c565f4a918..6c4ff8c3c9b010b0a0444d0c0e6c9baf79b0907f 100644 (file)
@@ -188,19 +188,40 @@ collision_tile:
   ;    a = 0 -> no collision
   ;    a = 1 -> collision
 collision_pt_rec:
+@top_left:
   ; check top left
   ; -> y pos 
   ld a, [hl+]
   add a, b ; a = rec y + y offset 
-  cp a, d ; tl < py?
+  cp a, d ; tl > py?
   jr nc, @no_collision REL
 
   ; -> x pos
   ld a, [hl+]
   add a, c ; a = rec x + x offset 
-  cp a, d ; t1 < px?
+  cp a, e ; t1 > px?
   jr nc, @no_collision REL 
 
+@top_right:
+  ; check top right 
+  ; y pos
+  ld a, [hl+]
+  add a, b ; a = rec y + y offset 
+  cp a, d  ; tr > py?
+  jr nc, @no_collision REL
+
+  ; x pos
+  ld a, [hl+]
+  add a, c ; a = rec x + x offset 
+  cp a, e ; tr < px
+  jr c, @no_collision REL
+  
+  ; TODO check bottom left 
+  @bottom_left:
+
+  ; TODO check bottom right
+@bottom_right:
+
 @collision:
   ld a, 1
 @no_collision: