From fa90ee5c494ef7db5c779fe7eec33d6312237f9b Mon Sep 17 00:00:00 2001 From: cursed22bc Date: Mon, 9 Mar 2026 12:58:53 +0200 Subject: missing texture shader --- world.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'world.lua') 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 -- cgit v1.2.3