From 70b6d2a335a40ae60e990cc5f37b828ed9dbf526 Mon Sep 17 00:00:00 2001 From: cursed22bc Date: Tue, 10 Mar 2026 21:26:24 +0200 Subject: pickups --- world.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'world.lua') 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 -- cgit v1.2.3