summaryrefslogtreecommitdiff
path: root/world.lua
diff options
context:
space:
mode:
authorcursed22bc <admin@pixeldawn.org>2026-03-10 21:26:24 +0200
committercursed22bc <admin@pixeldawn.org>2026-03-10 21:26:24 +0200
commit70b6d2a335a40ae60e990cc5f37b828ed9dbf526 (patch)
tree025b946feae41782f2cddb57e444e05cc6f9ac39 /world.lua
parenta64d77bc12cadb3989a7faf094adc1d5c581d565 (diff)
pickups
Diffstat (limited to 'world.lua')
-rw-r--r--world.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/world.lua b/world.lua
index c7cde9f..ad3d1ae 100644
--- a/world.lua
+++ b/world.lua
@@ -25,6 +25,7 @@ function World:new()
self.liquidSurfaceFixtures = {}
self.spikes = {}
self.textTriggers = {}
+ self.pickups = {}
self.refractionCanvas = nil
self.liquidShader = nil
self.activeSplashes = {}
@@ -160,6 +161,13 @@ function World:load(mapPath, tilesets)
table.insert(self.entities, textTrigger)
end
+ for _, pickup in ipairs(self.tilemap:getEntitiesPickups()) do
+ pickup:assignImage()
+ pickup:setWorldPhysics(self.physicsWorld)
+ table.insert(self.pickups, pickup)
+ table.insert(self.entities, pickup)
+ end
+
local ok, shader = pcall(love.graphics.newShader, "shaders/liquid.glsl")
self.liquidShader = ok and shader or nil
if not self.liquidShader then
@@ -211,11 +219,21 @@ function World:handleTextTrigger(trigger, player)
end
end
+function World:handlePickup(pickup, player)
+ if pickup and player and pickup.isPickup and self:_isPlayerLike(player) then
+ pickup:pickup(self, player)
+ end
+end
+
function World:_onBeginContact(udA, udB, nx, ny, contact)
if type(udA) == "table" and udA.isTextTrigger then
self:handleTextTrigger(udA, udB)
elseif type(udB) == "table" and udB.isTextTrigger then
self:handleTextTrigger(udB, udA)
+ elseif type(udA) == "table" and udA.isPickup then
+ self:handlePickup(udA, udB)
+ elseif type(udB) == "table" and udB.isPickup then
+ self:handlePickup(udB, udA)
end
if udA == "ground" and self:_isTrackedEntity(udB) then