+ separate anim timer for jacket bg to have it on loop

This commit is contained in:
FajsiEx 2021-08-26 19:50:33 +02:00
parent 201c920537
commit 16bec98b48
1 changed files with 25 additions and 10 deletions

View File

@ -127,6 +127,10 @@ local transitionAfterscrollTextSongArtist = 0;
local transitionAfterscrollDifficultiesAlpha = 0; local transitionAfterscrollDifficultiesAlpha = 0;
local transitionAfterscrollJacketBgAlpha = 0; local transitionAfterscrollJacketBgAlpha = 0;
local transitionJacketBgScrollScale = 0;
local transitionJacketBgScrollAlpha = 0;
local transitionJacketBgScrollPosX = 0;
local transitionLaserScale = 0; local transitionLaserScale = 0;
local transitionLaserY = 0; local transitionLaserY = 0;
@ -245,11 +249,11 @@ function drawBackground(deltaTime)
if song and diff then if song and diff then
local jacketImage = getJacketImage(song); local jacketImage = getJacketImage(song);
gfx.BeginPath() gfx.BeginPath()
gfx.ImageRect(0+transitionAfterscrollScale*-300, 0, 900, 900, jacketImage or defaultJacketImage, transitionAfterscrollJacketBgAlpha, 0) gfx.ImageRect(transitionJacketBgScrollPosX, 0, 900, 900, jacketImage or defaultJacketImage, transitionJacketBgScrollAlpha, 0)
gfx.BeginPath(); gfx.BeginPath();
gfx.FillColor(0,0,0,math.floor(transitionAfterscrollJacketBgAlpha*64)); gfx.FillColor(0,0,0,math.floor(transitionJacketBgScrollAlpha*64));
gfx.Rect(0,0,900,900); gfx.Rect(0,0,900,900);
gfx.Fill(); gfx.Fill();
gfx.ClosePath(); gfx.ClosePath();
@ -622,17 +626,27 @@ function tickTransitions(deltaTime)
transitionAfterscrollDifficultiesAlpha = 1; transitionAfterscrollDifficultiesAlpha = 1;
end end
-- Jacket background alpha -- Jacket bg animation
if transitionAfterscrollScale < 0.05 or transitionAfterscrollScale >= 1 then if transitionJacketBgScrollScale < 1 then
transitionAfterscrollJacketBgAlpha = 0; transitionJacketBgScrollScale = transitionJacketBgScrollScale + deltaTime / 20 -- transition should last for that time in seconds
elseif transitionAfterscrollScale >= 0.05 and transitionAfterscrollScale < 0.1 then
transitionAfterscrollJacketBgAlpha = math.min(1, (transitionAfterscrollScale-0.05) / 0.05);
elseif transitionAfterscrollScale >= 0.95 and transitionAfterscrollScale < 1 then
transitionAfterscrollJacketBgAlpha = math.min(1, 1-((transitionAfterscrollScale-0.95) / 0.05));
else else
transitionAfterscrollJacketBgAlpha = 1; transitionJacketBgScrollScale = 0
end end
if transitionJacketBgScrollScale < 0.05 or transitionJacketBgScrollScale >= 1 then
transitionJacketBgScrollAlpha = 0;
elseif transitionJacketBgScrollScale >= 0.05 and transitionJacketBgScrollScale < 0.1 then
transitionJacketBgScrollAlpha = math.min(1, (transitionJacketBgScrollScale-0.05) / 0.05);
elseif transitionJacketBgScrollScale >= 0.8 and transitionJacketBgScrollScale < 1 then
transitionJacketBgScrollAlpha = math.max(0,
math.min(1, 1-((transitionJacketBgScrollScale-0.8) / 0.05))
);
else
transitionJacketBgScrollAlpha = 1;
end
transitionJacketBgScrollPosX = 0+(transitionJacketBgScrollScale*(0.8/1))*-300;
-- Laser anim -- Laser anim
if transitionLaserScale < 1 then if transitionLaserScale < 1 then
transitionLaserScale = transitionLaserScale + deltaTime / 2 -- transition should last for that time in seconds transitionLaserScale = transitionLaserScale + deltaTime / 2 -- transition should last for that time in seconds
@ -751,6 +765,7 @@ end
set_index = function(newIndex) set_index = function(newIndex)
transitionScrollScale = 0; transitionScrollScale = 0;
transitionAfterscrollScale = 0; transitionAfterscrollScale = 0;
transitionJacketBgScrollScale = 0;
scrollingUp = false; scrollingUp = false;
if ((newIndex > selectedIndex and not (newIndex == #songwheel.songs and selectedIndex == 1)) or (newIndex == 1 and selectedIndex == #songwheel.songs)) then if ((newIndex > selectedIndex and not (newIndex == #songwheel.songs and selectedIndex == 1)) or (newIndex == 1 and selectedIndex == #songwheel.songs)) then