ExperimentalGear/scripts/gameplay/score_panel.lua

71 lines
1.5 KiB
Lua
Raw Normal View History

local Numbers = require('common.numbers')
2021-10-09 23:37:33 +02:00
local bgImage = gfx.CreateSkinImage("gameplay/score_panel/bg.png", 0)
local desw = 1080;
local desh = 1920;
2021-11-25 19:02:21 +01:00
local isLandscape = false;
local scoreNumbers = Numbers.load_number_image("score_num")
2021-10-09 23:37:33 +02:00
local tickTransitions = function (deltaTime)
end
local render = function (deltaTime, score, maxChain)
gfx.Save();
2021-11-25 19:02:21 +01:00
local resx, resy = game.GetResolution();
isLandscape = resx > resy;
2021-11-25 19:38:59 +01:00
if (isLandscape) then
desw = 1920;
desh = 1080;
else
desw = 1080;
desh = 1920;
end
2021-11-25 19:02:21 +01:00
tickTransitions(deltaTime)
2021-10-09 23:37:33 +02:00
2021-12-02 21:53:30 +01:00
local scale = resy / desh
local x = resx;
2021-11-25 19:38:59 +01:00
local y = isLandscape and 5 or 330;
2021-11-25 19:02:21 +01:00
2021-12-02 21:53:30 +01:00
gfx.Translate(x, 0);
x = 0
2021-10-09 23:37:33 +02:00
gfx.Scale(scale, scale)
2021-10-09 23:37:33 +02:00
gfx.BeginPath();
gfx.ImageRect(
2021-11-25 19:02:21 +01:00
x-740*0.61, -- WHY IS THERE DIFFERENT SCALING FOR THIS TOO????
2021-10-09 23:37:33 +02:00
y,
740*0.61,
320*0.61,
bgImage,
1,
0
);
Numbers.draw_number(x-309.4, y + 83, 1.0, score/10000, 4, scoreNumbers, true, 0.38, 1.12)
Numbers.draw_number(x-113.4, y + 90, 1.0, score, 4, scoreNumbers, true, 0.28, 1.12)
2021-10-09 23:37:33 +02:00
-- Draw max chain
gfx.BeginPath();
2021-10-09 23:37:33 +02:00
gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE)
gfx.FontSize(30);
gfx.FillColor(255,255,255,255);
2021-11-25 19:02:21 +01:00
gfx.Text(string.format("%04d", maxChain), x-281.4, y+155);
gfx.ResetTransform()
gfx.Restore();
2021-10-09 23:37:33 +02:00
end
return {
render=render
}