extract a couple of collision functions to a separate module for reuse

This commit is contained in:
2025-02-08 08:39:04 +00:00
parent f9fe009d59
commit 1c105193e2
3 changed files with 26 additions and 18 deletions

15
fcore/collision.sml Normal file
View File

@@ -0,0 +1,15 @@
structure Collision =
struct
fun isColliding (ix, iy, ifx, ify, cx, cy, cfx, cfy) =
ix < cfx andalso ifx > cx andalso iy < cfy andalso ify > cy
fun isCollidingPlus (ix, iy, iw, ih, cx, cy, cw, ch) =
let
val ifx = ix + iw
val ify = iy + ih
val cfx = cx + cw
val cfy = cy + ch
in
isColliding (ix, iy, ifx, ify, cx, cy, cfx, cfy)
end
end