diff options
Diffstat (limited to 'world.lua')
| -rw-r--r-- | world.lua | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 |
