+ score panel landscape support

This commit is contained in:
FajsiEx 2021-11-25 19:02:21 +01:00
parent 09dc795ee6
commit 01ea812b7f
1 changed files with 20 additions and 14 deletions

View File

@ -4,6 +4,8 @@ local bgImage = gfx.CreateSkinImage("gameplay/score_panel/bg.png", 0)
local desw = 1080;
local desh = 1920;
local isLandscape = false;
function load_number_image(path)
local images = {}
for i = 0, 9 do
@ -40,15 +42,26 @@ local tickTransitions = function (deltaTime)
end
local render = function (deltaTime, score, maxChain)
tickTransitions(deltaTime)
gfx.Save();
local x = desw - 740*0.61; -- WHY IS THERE DIFFERENT SCALING FOR THIS TOO????
local y = 330;
local resx, resy = game.GetResolution();
isLandscape = resx > resy;
tickTransitions(deltaTime)
local x = desw;
local y = isLandscape and 0 or 330;
if (isLandscape) then
gfx.Translate(x, 0);
x=0
gfx.Scale(0.7, 0.7);
end
gfx.BeginPath();
gfx.ImageRect(
x,
x-740*0.61, -- WHY IS THERE DIFFERENT SCALING FOR THIS TOO????
y,
740*0.61,
320*0.61,
@ -57,8 +70,8 @@ local render = function (deltaTime, score, maxChain)
0
);
draw_number(x+142, y + 83, 1.0, score/10000, 4, scoreNumbers, true, 0.38, 1.12)
draw_number(x+338, y + 90, 1.0, score, 4, scoreNumbers, true, 0.28, 1.12)
draw_number(x-309.4, y + 83, 1.0, score/10000, 4, scoreNumbers, true, 0.38, 1.12)
draw_number(x-113.4, y + 90, 1.0, score, 4, scoreNumbers, true, 0.28, 1.12)
-- Draw max chain
gfx.BeginPath();
@ -66,15 +79,8 @@ local render = function (deltaTime, score, maxChain)
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE)
gfx.FontSize(30);
-- gfx.FillColor(0,0,0,255);
-- gfx.Text(string.format("%04d", maxChain), x+170-2, y+155-2);
-- gfx.Text(string.format("%04d", maxChain), x+170-2, y+155+2);
-- gfx.Text(string.format("%04d", maxChain), x+170+2, y+155-2);
-- gfx.Text(string.format("%04d", maxChain), x+170+2, y+155+2);
gfx.FillColor(255,255,255,255);
gfx.Text(string.format("%04d", maxChain), x+170, y+155);
gfx.Text(string.format("%04d", maxChain), x-281.4, y+155);
gfx.Restore();
end