Added bg hexagons and flickering to songtransition

This commit is contained in:
Hersi 2021-12-13 23:06:58 +01:00
parent 640ecc6c2d
commit c42c5da314
1 changed files with 45 additions and 17 deletions

View File

@ -13,6 +13,12 @@ local frameOverlayImage = gfx.CreateSkinImage("songtransition/frames.png", 0)
local albumBgImage = gfx.CreateSkinImage("songtransition/album_crop.png", 0)
local infoOverlayPanel = gfx.CreateSkinImage("songtransition/info_panels_crop.png", 0)
local linkedHexagonsImage = gfx.CreateSkinImage("songtransition/linked_hexagons_crop.png", 0)
local hexagonImages = {
gfx.CreateSkinImage("songtransition/hex1.png", 0),
gfx.CreateSkinImage("songtransition/hex2.png", 0)
}
local difficultyNumbers;
local difficultyLabelImages = {
@ -26,8 +32,11 @@ local difficultyLabelImages = {
gfx.CreateSkinImage("songtransition/difficulty_labels/vvd.png", 0),
}
local transitionTimer = 0;
local outTimer = 0
local timer = 0
local transitionProgress = 0;
local outProgress = 0
local flickerTime = 0.050 --seconds (50ms)
-- Window variables
local resX, resY = game.GetResolution()
@ -74,13 +83,13 @@ function render(deltaTime)
gfx.Scale(fullX / 1080, fullY / 1920);
gfx.Scissor(0, 0, 1080, 1920);
render_screen(transitionTimer);
render_screen();
transitionTimer = transitionTimer + deltaTime * 0.2
transitionTimer = math.min(transitionTimer,1)
transitionProgress = transitionProgress + deltaTime * 0.2
transitionProgress = math.min(transitionProgress,1)
if transitionTimer < 0.25 then
local whiteAlpha = math.max(0, (1-transitionTimer/0.25))
if transitionProgress < 0.25 then
local whiteAlpha = math.max(0, (1-transitionProgress/0.25))
gfx.BeginPath();
gfx.FillColor(255,255,255,math.floor(255*whiteAlpha));
@ -89,8 +98,8 @@ function render(deltaTime)
gfx.ClosePath();
end
if transitionTimer > 0.85 then
local blackAlpha = math.min(1, ((transitionTimer-0.85)/0.15))
if transitionProgress > 0.85 then
local blackAlpha = math.min(1, ((transitionProgress-0.85)/0.15))
gfx.BeginPath();
gfx.FillColor(0,0,0,math.floor(255*blackAlpha));
@ -99,29 +108,48 @@ function render(deltaTime)
gfx.ClosePath();
end
return transitionTimer >= 1
timer = timer + deltaTime
return transitionProgress >= 1
end
function render_out(deltaTime)
outTimer = outTimer + deltaTime * 0.2
outTimer = math.min(outTimer, 1)
outProgress = outProgress + deltaTime * 0.2
outProgress = math.min(outProgress, 1)
return outTimer >= 1;
timer = timer + deltaTime
return outProgress >= 1;
end
function sign(x)
return x>0 and 1 or x<0 and -1 or 0
end
function render_screen(progress)
function render_screen()
gfx.BeginPath()
gfx.ImageRect(0, 0, 1080, 1920, bgImage,1,0);
if transitionProgress < 0.35 then
local hex1alpha = math.max(0, (1-transitionProgress/0.35))
local hex2alpha = math.max(0, (1-transitionProgress/0.3))
gfx.BeginPath()
gfx.ImageRect(0,0, desw, desh, hexagonImages[1], hex1alpha, 0)
gfx.BeginPath()
gfx.ImageRect(0,0, desw, desh, hexagonImages[2], hex2alpha, 0)
end
gfx.BeginPath()
gfx.ImageRect(0,0,1080,1920,frameOverlayImage,1,0);
gfx.BeginPath()
gfx.ImageRect(0, 0, 1080, 1920, glowOverlayImage,1,0);
gfx.BeginPath()
gfx.ImageRect(37.5, 1074, 1180*0.85, 343*0.85, infoOverlayPanel,1,0);
gfx.ImageRect(37.5, 1074, 1180*0.85, 343*0.85, infoOverlayPanel, 1, 0);
if (timer % flickerTime) < (flickerTime / 2) then --flicker with 20Hz (50ms), 50% duty cycle
gfx.BeginPath()
gfx.ImageRect(37.5, 1074, 1180*0.85, 189*0.85, linkedHexagonsImage, 0.1, 0);
end
gfx.BeginPath()
gfx.ImageRect(10, 195.5, 1060, 1015, albumBgImage,1,0);
@ -177,10 +205,10 @@ function render_screen(progress)
end
function reset()
transitionTimer = 0
transitionProgress = 0
resX, resY = game.GetResolution()
fullX = portraitWidescreenRatio * resY
fullY = resY
outTimer = 0
outProgress = 0
wasEnterSfxPlayed = false;
end