summaryrefslogtreecommitdiff
path: root/world.lua
diff options
context:
space:
mode:
Diffstat (limited to 'world.lua')
-rw-r--r--world.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/world.lua b/world.lua
index 8f1722f..cbe6e8b 100644
--- a/world.lua
+++ b/world.lua
@@ -23,6 +23,7 @@ function World:new()
self.liquidPolygons = {}
self.liquidSurfaces = {}
self.liquidSurfaceFixtures = {}
+ self.spikes = {}
self.refractionCanvas = nil
self.liquidShader = nil
self.activeSplashes = {}
@@ -145,6 +146,12 @@ function World:load(mapPath, tilesets)
table.insert(self.liquidSurfaceFixtures, { body = body, fixture = fixture })
end
+ for _, spike in ipairs(self.tilemap:getEntitiesSpikes()) do
+ spike:setWorldPhysics(self.physicsWorld)
+ table.insert(self.spikes, spike)
+ table.insert(self.entities, spike)
+ end
+
local ok, shader = pcall(love.graphics.newShader, "shaders/liquid.glsl")
self.liquidShader = ok and shader or nil
if not self.liquidShader then
@@ -386,6 +393,9 @@ function World:draw()
drawTileLayer(self.tilemap:getDecorationBackgroundLayer(), mapTileW, mapTileH, tileGidInfo, viewMinX, viewMinY, viewMaxX, viewMaxY)
drawTileLayer(self.tilemap:getBackgroundLayer(), mapTileW, mapTileH, tileGidInfo, viewMinX, viewMinY, viewMaxX, viewMaxY)
drawTileLayer(self.tilemap:getGroundLayer(), mapTileW, mapTileH, tileGidInfo, viewMinX, viewMinY, viewMaxX, viewMaxY)
+ for _, spike in ipairs(self.tilemap:getEntitiesSpikes()) do
+ spike:draw()
+ end
for _, e in ipairs(self.entities) do
if e.draw then e:draw() else World.drawEntityDefault(self, e) end
end
@@ -545,6 +555,10 @@ function World:update(dt)
if surface.update then surface:update(dt) end
end
+ for _, spike in ipairs(self.tilemap:getEntitiesSpikes()) do
+ if spike.update then spike:update(dt) end
+ end
+
for i = #self.activeSplashes, 1, -1 do
self.activeSplashes[i].t = self.activeSplashes[i].t + dt * 2
if self.activeSplashes[i].t >= 1 then