summaryrefslogtreecommitdiff
path: root/collisions.lua
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-05-16 08:10:20 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-05-16 08:10:20 -0700
commit7d415c4958f584c031922ed77a3559d15bf2dc1b (patch)
tree1957ccc8a42de22778b639352b38d9091a4adf4d /collisions.lua
parent8cd9ec2e98d27b414bc7cff3a5a98b0aad9099ce (diff)
downloaddyl8-7d415c4958f584c031922ed77a3559d15bf2dc1b.tar.gz
dyl8-7d415c4958f584c031922ed77a3559d15bf2dc1b.zip
Snapshot
Diffstat (limited to 'collisions.lua')
-rw-r--r--collisions.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/collisions.lua b/collisions.lua
index 04575c4..f57554e 100644
--- a/collisions.lua
+++ b/collisions.lua
@@ -1,14 +1,17 @@
-sw, sh = 8, 8
function is_colliding(a, b)
ax1, bx1 = a.position.x, b.position.x
- ax2, bx2 = ax1 + sw, bx1 + sw
+ ax2, bx2 = ax1 + SPRITE_DIMS.x, bx1 + SPRITE_DIMS.y
ay1, by1 = a.position.y, b.position.y
- ay2, by2 = ay1 + sh, by1 + sh
+ ay2, by2 = ay1 + SPRITE_DIMS.y, by1 + SPRITE_DIMS.x
return (ax1 < bx2 and ax2 > bx1
and ay1 < by2 and ay2 > by1)
end
function handle_collision(a, b)
+ if a.entity_type == Entities.Sword and b.entity_type == Entities.Player and b.equipped[a.id] == nil then
+ b:equip(a)
+ return
+ end
if a.damage and b.health then
if b:is_in_iframe() then
return