From d6804dee7cd4a4bd6b0d2b27feef8a2f8bf9a0bd Mon Sep 17 00:00:00 2001 From: parameterized Date: Sat, 22 Sep 2018 11:43:26 -0400 Subject: [PATCH] broken type sort removed --- entities.lua | 6 ++---- hud.lua | 4 ++-- scene.lua | 12 ++---------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/entities.lua b/entities.lua index 54b2ff2..4e17f75 100644 --- a/entities.lua +++ b/entities.lua @@ -65,16 +65,14 @@ function entities.client.draw() draw = function() v:drawBody() end, - y = v.y, - type = 'entityBody' + y = v.y } if v.drawHP then scene.add{ draw = function() v:drawHP() end, - y = v.y, - type = 'entityHP' + y = v.y } end end diff --git a/hud.lua b/hud.lua index fa30866..23af7ab 100644 --- a/hud.lua +++ b/hud.lua @@ -206,7 +206,7 @@ function hud.draw() local font = fonts.c17 love.graphics.setFont(font) local level = tostring(math.floor(l)) - love.graphics.print(level, lume.round(240 - font:getWidth(level)/2), lume.round(y)) + text.print(level, lume.round(240 - font:getWidth(level)/2), lume.round(y)) font = fonts.stats love.graphics.setFont(font) @@ -225,7 +225,7 @@ function hud.draw() sx = x + (sx - hud.statsPanel.openPos.x) sy = y + (sy - hud.statsPanel.openPos.y) local txt = tostring(player.stats[col][row]) - love.graphics.print(txt, lume.round(sx - font:getWidth(txt)/2), lume.round(sy - font:getHeight()/2)) + text.print(txt, lume.round(sx - font:getWidth(txt)/2), lume.round(sy - font:getHeight()/2)) end end diff --git a/scene.lua b/scene.lua index 2e70bd2..2abef65 100644 --- a/scene.lua +++ b/scene.lua @@ -9,7 +9,7 @@ function scene.reset() scene.layers = {} end --- t = {draw=_, y=_, layer=_, type=_} +-- t = {draw=_, y=_, layer=_} function scene.add(t) if t.layer == nil then t.layer = 1 end if scene.layers[t.layer] == nil then scene.layers[t.layer] = {} end @@ -23,15 +23,7 @@ function scene.draw() end layers = isort(layers, 'k') for _, layer in ipairs(layers) do - local sorted = isort(layer.v, function(a, b) - if a.type == 'entityBody' and b.type == 'entityHP' then - return true - elseif a.type == 'entityHP' and b.type == 'entityBody' then - return false - else - return a.y < b.y - end - end) + local sorted = isort(layer.v, 'y') for _, v in pairs(sorted) do v.draw() end