From e35d89f21ea49cd94142f2de27cca69baa6aab62 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 2 Jan 2022 10:02:48 +0100 Subject: [PATCH] fix: remove an use of scissor for hp bars --- sonic-radiance.love/assets/gui/bar_small.lua | 6 ++++++ sonic-radiance.love/assets/gui/bar_small.png | Bin 0 -> 719 bytes sonic-radiance.love/game/modules/gui/init.lua | 20 ++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 sonic-radiance.love/assets/gui/bar_small.lua create mode 100644 sonic-radiance.love/assets/gui/bar_small.png diff --git a/sonic-radiance.love/assets/gui/bar_small.lua b/sonic-radiance.love/assets/gui/bar_small.lua new file mode 100644 index 0000000..fe8752b --- /dev/null +++ b/sonic-radiance.love/assets/gui/bar_small.lua @@ -0,0 +1,6 @@ +return { + metadata = { + height = 7, + width = 14, + } +} \ No newline at end of file diff --git a/sonic-radiance.love/assets/gui/bar_small.png b/sonic-radiance.love/assets/gui/bar_small.png new file mode 100644 index 0000000000000000000000000000000000000000..0e7413f81b1f7fd1c7b529bad0fca5ed6da0341e GIT binary patch literal 719 zcmV;=0xEX>4Tx04R}tkv&MmKpe$iTcsiu5j%(|M5s;{ii$XD6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfb8}L3krMxx6k5c1aNLh~_a1le0DryARI?)nsG4P@ z5^*7uT@`|_2w@m~7(q;8ramW%NqCO0d-(Wz7v)*r=l&c$O3q|}PavLUx?vG-5KnJf zI_G`jFe^$5@j3ChK^G)`x%kia6AAVPqQDoQBBLX=jG6cZ`hk9+tB9luB}nOr3> zax9<%6_Voz|AXJ%n)%5IHz^bcI$v!2V-yJP0*#t&e;?a+;{*si16NwhU#SB#pQP7X zTI2}m-3BhMTbjHFTnGy0}1(0>bbuerT7_i_3Fq^Yaq4RCM> zj1?$*-Q(R|?Y;ebrrF;Q$Qg3U@cwO800006VoOIv0RI600RN!9r;`8x010qNS#tmY zE+YT{E+YYWr9XB6000McNlirueSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{005^+L_t(Y$L-NU4uBvGMA7#ChproAVua40Mt61x@(Jc; zRaG>TnYrALh?vCJh8y1&PW*TRjh8=8;@o|dad)7*SaP(ElNfWfj!tZIw2ma+au zLpn}k#33D>*y50mBwlhTik1U8PGZS{9Gw_*AV(5EI0(g-13OOQmIFIFG2+0EB))M_ ziY15TIEl9$mZK9(4$Be6bxus?kKc~RH~;Ym@c||K`_mv?6Kenf002ovPDHLkV1ieo BD!l*z literal 0 HcmV?d00001 diff --git a/sonic-radiance.love/game/modules/gui/init.lua b/sonic-radiance.love/game/modules/gui/init.lua index c8f0426..70f8869 100644 --- a/sonic-radiance.love/game/modules/gui/init.lua +++ b/sonic-radiance.love/game/modules/gui/init.lua @@ -1,6 +1,8 @@ local gui = {} +local TileSet = require "birb.modules.assets.types.tileset" local barborder = love.graphics.newImage("assets/gui/barborder.png") +local barSmall = TileSet("assets/gui/bar_small") function gui.newBorder(width, height, middlePosition) local tileset = love.graphics.newImage("assets/gui/borders.png") @@ -79,14 +81,18 @@ function gui.newChoiceBack(approximateWidth) end function gui.drawBar(x, y, width, height) + width = math.floor(width) + if (width > 0) then - local height = height or 7 - core.screen:setScissor(x, y, width, height) - love.graphics.draw(barborder, x, y) - local barwidth = math.max(width-14, 0) - love.graphics.rectangle("fill", x+7, y, barwidth, height) - love.graphics.draw(barborder, x+barwidth+7, y, 0, -1, -1, 7, 7) - core.screen:resetScissor( ) + height = 7 + if (width <= 8) then + barSmall:drawTile(9 - width, 0, 0) + else + love.graphics.draw(barborder, x, y) + local barwidth = math.max(width-14, 0) + love.graphics.rectangle("fill", x+7, y, barwidth, height) + love.graphics.draw(barborder, x+barwidth+7, y, 0, -1, -1, 7, 7) + end end end