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