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 albumBgImage = gfx.CreateSkinImage("songtransition/album_crop.png", 0)
local infoOverlayPanel = gfx.CreateSkinImage("songtransition/info_panels_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 difficultyNumbers;
local difficultyLabelImages = { local difficultyLabelImages = {
@ -26,8 +32,11 @@ local difficultyLabelImages = {
gfx.CreateSkinImage("songtransition/difficulty_labels/vvd.png", 0), gfx.CreateSkinImage("songtransition/difficulty_labels/vvd.png", 0),
} }
local transitionTimer = 0; local timer = 0
local outTimer = 0 local transitionProgress = 0;
local outProgress = 0
local flickerTime = 0.050 --seconds (50ms)
-- Window variables -- Window variables
local resX, resY = game.GetResolution() local resX, resY = game.GetResolution()
@ -74,13 +83,13 @@ function render(deltaTime)
gfx.Scale(fullX / 1080, fullY / 1920); gfx.Scale(fullX / 1080, fullY / 1920);
gfx.Scissor(0, 0, 1080, 1920); gfx.Scissor(0, 0, 1080, 1920);
render_screen(transitionTimer); render_screen();
transitionTimer = transitionTimer + deltaTime * 0.2 transitionProgress = transitionProgress + deltaTime * 0.2
transitionTimer = math.min(transitionTimer,1) transitionProgress = math.min(transitionProgress,1)
if transitionTimer < 0.25 then if transitionProgress < 0.25 then
local whiteAlpha = math.max(0, (1-transitionTimer/0.25)) local whiteAlpha = math.max(0, (1-transitionProgress/0.25))
gfx.BeginPath(); gfx.BeginPath();
gfx.FillColor(255,255,255,math.floor(255*whiteAlpha)); gfx.FillColor(255,255,255,math.floor(255*whiteAlpha));
@ -89,8 +98,8 @@ function render(deltaTime)
gfx.ClosePath(); gfx.ClosePath();
end end
if transitionTimer > 0.85 then if transitionProgress > 0.85 then
local blackAlpha = math.min(1, ((transitionTimer-0.85)/0.15)) local blackAlpha = math.min(1, ((transitionProgress-0.85)/0.15))
gfx.BeginPath(); gfx.BeginPath();
gfx.FillColor(0,0,0,math.floor(255*blackAlpha)); gfx.FillColor(0,0,0,math.floor(255*blackAlpha));
@ -99,23 +108,37 @@ function render(deltaTime)
gfx.ClosePath(); gfx.ClosePath();
end end
return transitionTimer >= 1 timer = timer + deltaTime
return transitionProgress >= 1
end end
function render_out(deltaTime) function render_out(deltaTime)
outTimer = outTimer + deltaTime * 0.2 outProgress = outProgress + deltaTime * 0.2
outTimer = math.min(outTimer, 1) outProgress = math.min(outProgress, 1)
return outTimer >= 1; timer = timer + deltaTime
return outProgress >= 1;
end end
function sign(x) function sign(x)
return x>0 and 1 or x<0 and -1 or 0 return x>0 and 1 or x<0 and -1 or 0
end end
function render_screen(progress) function render_screen()
gfx.BeginPath() gfx.BeginPath()
gfx.ImageRect(0, 0, 1080, 1920, bgImage,1,0); 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.BeginPath()
gfx.ImageRect(0,0,1080,1920,frameOverlayImage,1,0); gfx.ImageRect(0,0,1080,1920,frameOverlayImage,1,0);
gfx.BeginPath() gfx.BeginPath()
@ -123,6 +146,11 @@ function render_screen(progress)
gfx.BeginPath() 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.BeginPath()
gfx.ImageRect(10, 195.5, 1060, 1015, albumBgImage,1,0); gfx.ImageRect(10, 195.5, 1060, 1015, albumBgImage,1,0);
@ -177,10 +205,10 @@ function render_screen(progress)
end end
function reset() function reset()
transitionTimer = 0 transitionProgress = 0
resX, resY = game.GetResolution() resX, resY = game.GetResolution()
fullX = portraitWidescreenRatio * resY fullX = portraitWidescreenRatio * resY
fullY = resY fullY = resY
outTimer = 0 outProgress = 0
wasEnterSfxPlayed = false; wasEnterSfxPlayed = false;
end end