added bg audio + score iterator
still figuring out ui scaling, draw_numbers is "broken"? maybe I'm using it wrong.
This commit is contained in:
parent
6fcd3e8352
commit
f8ae2ac243
|
@ -8,6 +8,8 @@ local desw = 1080
|
|||
local desh = 1920
|
||||
local scale = 1
|
||||
|
||||
local bgSfxPlayed = false;
|
||||
|
||||
local BAR_ALPHA = 191;
|
||||
local HEADER_HEIGHT = 100
|
||||
|
||||
|
@ -26,6 +28,9 @@ local crewImage = gfx.CreateSkinImage("crew in game/near noah vw.png", 0);
|
|||
local irHeartbeatRequested = false;
|
||||
local IRserverName = '';
|
||||
|
||||
-- AUDIO
|
||||
game.LoadSkinSample("challenge_result.wav")
|
||||
|
||||
function resetLayoutInformation()
|
||||
resx, resy = game.GetResolution()
|
||||
desw = 1080
|
||||
|
@ -33,6 +38,43 @@ function resetLayoutInformation()
|
|||
scale = resx / desw
|
||||
end
|
||||
|
||||
local function handleSfx()
|
||||
if not bgSfxPlayed then
|
||||
game.PlaySample("challenge_result.wav", true)
|
||||
bgSfxPlayed = true
|
||||
end
|
||||
if game.GetButton(game.BUTTON_STA) then game.StopSample("challenge_result.wav") end
|
||||
if game.GetButton(game.BUTTON_BCK) then game.StopSample("challenge_result.wav") end
|
||||
end
|
||||
|
||||
local function load_number_image(path)
|
||||
local images = {}
|
||||
for i = 0, 9 do
|
||||
images[i + 1] = gfx.CreateSkinImage(string.format("%s/%d.png", path, i),
|
||||
0)
|
||||
end
|
||||
return images
|
||||
end
|
||||
|
||||
local function draw_number(x, y, alpha, num, digits, images, is_dim, scale, kern)
|
||||
scale = scale or 1;
|
||||
kern = kern or 1;
|
||||
local tw, th = gfx.ImageSize(images[1])
|
||||
tw = tw * scale;
|
||||
th = th * scale;
|
||||
x = x + (tw * (digits - 1)) / 2
|
||||
y = y - th / 2
|
||||
for i = 1, digits do
|
||||
local mul = 10 ^ (i - 1)
|
||||
local digit = math.floor(num / mul) % 10
|
||||
local a = alpha
|
||||
if is_dim and num < mul then a = 0.4 end
|
||||
gfx.BeginPath()
|
||||
gfx.ImageRect(x, y, tw, th, images[digit + 1], a, 0)
|
||||
x = x - (tw * kern)
|
||||
end
|
||||
end
|
||||
|
||||
function drawBackground()
|
||||
gfx.BeginPath()
|
||||
gfx.ImageRect(0, 0, desw, desh, backgroundImage, 1, 0);
|
||||
|
@ -80,6 +122,25 @@ function drawPlayerInfo()
|
|||
gfx.ImageRect(311, 490, 107*1.25, 29*1.25, danBadgeImage, 1, 0);
|
||||
end
|
||||
|
||||
local scoreNumber = load_number_image("score_num");
|
||||
|
||||
function drawScorePanelContent()
|
||||
game.Log("Drawing scores...", game.LOGGER_INFO) --debug
|
||||
for i,chart in ipairs(result.charts) do
|
||||
if chart.score == nil then
|
||||
game.Log("Score does not exist? Quitting loop...", game.LOGGER_WARNING)
|
||||
break
|
||||
end
|
||||
game.Log("#"..i.." chart.score: " .. chart.score, game.LOGGER_INFO) --debug
|
||||
-- Draw score
|
||||
draw_number(250, 150, 1.0,
|
||||
math.floor(chart.score / 10000), 4, scoreNumber, true, 0.40,
|
||||
1.12)
|
||||
--still not sure how ui scaling/layers works in this game, still figuring it out :p
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local IR_HeartbeatResponse = function(res)
|
||||
if res.statusCode == IRData.States.Success then
|
||||
IRserverName = res.body.serverName .. ' ' .. res.body.irVersion;
|
||||
|
@ -100,12 +161,15 @@ function render(deltaTime)
|
|||
resetLayoutInformation();
|
||||
gfx.Scale(scale,scale);
|
||||
|
||||
handleSfx()
|
||||
IR_Handle()
|
||||
|
||||
drawBackground()
|
||||
|
||||
drawPlayerInfo()
|
||||
|
||||
drawScorePanelContent()
|
||||
|
||||
|
||||
drawHeader()
|
||||
Footer.draw(deltaTime);
|
||||
|
|
Loading…
Reference in New Issue