summaryrefslogtreecommitdiff
path: root/world.lua
diff options
context:
space:
mode:
authorcursed22bc <admin@pixeldawn.org>2026-03-09 12:58:53 +0200
committercursed22bc <admin@pixeldawn.org>2026-03-09 12:58:53 +0200
commitfa90ee5c494ef7db5c779fe7eec33d6312237f9b (patch)
tree5b52c6aeb97ac411ad230344a32a49b2ddf31382 /world.lua
parent97d0d1ecc0cfd5516cfad2d477faa4d35992e7ba (diff)
missing texture shader
Diffstat (limited to 'world.lua')
-rw-r--r--world.lua20
1 files changed, 16 insertions, 4 deletions
diff --git a/world.lua b/world.lua
index 86ab7ba..2542fa1 100644
--- a/world.lua
+++ b/world.lua
@@ -100,6 +100,11 @@ function World:load(mapPath, tilesets)
end
end
+ local ok, shader = pcall(love.graphics.newShader, "shaders/missing_texture.glsl")
+ self.missingShader = ok and shader or nil
+ if not ok then
+ print("Warning: missing_texture.glsl not loaded, using fallback (no missing texture)")
+ end
self.player = nil
self.enemies = {}
self.entities = {}
@@ -358,7 +363,7 @@ function World:draw()
drawTileLayer(self.tilemap:getBackgroundLayer(), mapTileW, mapTileH, tileGidInfo, viewMinX, viewMinY, viewMaxX, viewMaxY)
drawTileLayer(self.tilemap:getGroundLayer(), mapTileW, mapTileH, tileGidInfo, viewMinX, viewMinY, viewMaxX, viewMaxY)
for _, e in ipairs(self.entities) do
- if e.draw then e:draw() else World.drawEntityDefault(e) end
+ if e.draw then e:draw() else World.drawEntityDefault(self, e) end
end
drawTileLayer(self.tilemap:getForegroundLayer(), mapTileW, mapTileH, tileGidInfo, viewMinX, viewMinY, viewMaxX, viewMaxY)
love.graphics.setCanvas(mainCanvas)
@@ -431,7 +436,8 @@ function World:draw()
if not useRefraction then
for _, e in ipairs(self.entities) do
- if e.draw then e:draw() else World.drawEntityDefault(e) end
+ print(e)
+ if e.draw then e:draw() else World.drawEntityDefault(self, e) end
end
drawTileLayer(self.tilemap:getForegroundLayer(), mapTileW, mapTileH, tileGidInfo, viewMinX, viewMinY, viewMaxX, viewMaxY)
end
@@ -459,12 +465,18 @@ function World.drawPhysicsBodyOutlines(entityList)
love.graphics.setColor(1, 1, 1, 1)
end
-function World.drawEntityDefault(entity)
+function World.drawEntityDefault(self, entity)
love.graphics.setColor(0.2, 0.6, 1, 1)
if entity.isPlayer then
love.graphics.setColor(1, 0.3, 0.2, 1)
end
- love.graphics.rectangle("fill", math.floor(entity.x), math.floor(entity.y), entity.width, entity.height)
+ if self.missingShader then
+ love.graphics.setShader(self.missingShader)
+ love.graphics.draw(entity.texture, math.floor(entity.x), math.floor(entity.y))
+ love.graphics.setShader()
+ else
+ love.graphics.rectangle("fill", math.floor(entity.x), math.floor(entity.y), entity.width, entity.height)
+ end
love.graphics.setColor(1, 1, 1, 1)
end