ExperimentalGear/scripts/gameplay/track_end.lua

471 lines
13 KiB
Lua
Raw Normal View History

2021-10-28 13:46:24 +02:00
local Easing = require('common.easings')
2021-10-28 12:17:20 +02:00
local bgImage = gfx.CreateSkinImage("gameplay/track_end/bg.png", 0)
local bgHexTopImage = gfx.CreateSkinImage("gameplay/track_end/top_hex.png", 0)
local bgHexBottomImage = gfx.CreateSkinImage("gameplay/track_end/bottom_hex.png", 0)
local enterFlareBlueImage = gfx.CreateSkinImage("gameplay/track_end/flares/blue_transition_flare.png", 0)
local enterFlarePinkImage = gfx.CreateSkinImage("gameplay/track_end/flares/pink_transition_flare.png", 0)
2021-10-28 13:13:34 +02:00
local trackCompImage = gfx.CreateSkinImage("gameplay/track_end/track_comp.png", 0)
local trackCompBlurImage = gfx.CreateSkinImage("gameplay/track_end/track_comp_blur.png", 0)
2021-10-28 13:13:34 +02:00
-- new
local particleGreenDot1Image = gfx.CreateSkinImage("gameplay/track_end/particles/green_dot_1.png", 0)
local particleGreenDot2Image = gfx.CreateSkinImage("gameplay/track_end/particles/green_dot_2.png", 0)
2021-10-28 14:54:31 +02:00
local particleBlueRingImage = gfx.CreateSkinImage("gameplay/track_end/particles/blue_ring.png", 0)
local particleLargeRainbowRingImage = gfx.CreateSkinImage("gameplay/track_end/particles/large_rainbow_ring.png", 0)
local particleRedBallImage = gfx.CreateSkinImage("gameplay/track_end/particles/red_ball.png", 0)
2021-11-17 19:05:08 +01:00
local particleRedRingImage = gfx.CreateSkinImage("gameplay/track_end/particles/red_ring.png", 0)
2021-10-28 14:54:31 +02:00
2021-11-17 19:09:54 +01:00
local particleSmallYellowRing1Image = gfx.CreateSkinImage("gameplay/track_end/particles/small_yellow_ring_1.png", 0)
2021-11-17 19:14:15 +01:00
local particleSmallYellowRing2Image = gfx.CreateSkinImage("gameplay/track_end/particles/small_yellow_ring_2.png", 0)
2021-11-17 19:24:56 +01:00
local particleSmallRainbowRingImage = gfx.CreateSkinImage("gameplay/track_end/particles/small_rainbow_ring.png", 0)
2021-11-17 19:48:01 +01:00
local particleYellowRingImage = gfx.CreateSkinImage("gameplay/track_end/particles/yellow_ring.png", 0)
2021-11-17 20:05:18 +01:00
local flareEndBlueImage = gfx.CreateSkinImage("gameplay/track_end/flares/blue_end_flare.png", 0)
local flareEndPinkImage = gfx.CreateSkinImage("gameplay/track_end/flares/pink_end_flare.png", 0)
2021-10-28 13:46:24 +02:00
2021-10-28 12:17:20 +02:00
local outroTransitionScale = 0;
local outroTransitionGlobalAlpha = 0;
local outroTransitionEnterFlareX = -1920;
2021-10-28 14:54:31 +02:00
2021-10-28 13:13:34 +02:00
local outroTransitionTextCutX = 0;
local outroTransitionTextAlpha = 1;
local outroTransitionTextBlurAlpha = 0;
2021-10-28 14:54:31 +02:00
2021-11-17 20:05:18 +01:00
local particlesStartTime = 0.25;
local particlesDuration = 0.2;
local particles = {
2021-11-17 21:26:44 +01:00
{
name = 'green_dot_one',
texture = particleGreenDot1Image,
opacity = 1,
startX = 1280,
finishX = 380,
xPos = 1280,
yPos = 660,
width = 235*0.5,
height = 235*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
},
2021-11-17 21:26:44 +01:00
{
name = 'green_dot_two',
texture = particleGreenDot2Image,
opacity = 1,
startX = 1280,
finishX = 70,
xPos = 1280,
yPos = 610,
width = 128*0.5,
height = 128*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
},
2021-11-17 21:26:44 +01:00
{
name = 'blue_ring',
texture = particleBlueRingImage,
opacity = 1,
startX = 1280,
finishX = 65,
xPos = 1280,
yPos = 620,
width = 229*0.5,
height = 229*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
},
2021-11-17 21:26:44 +01:00
{ -- TODO: scale transitions
name = 'large_rainbow_ring',
texture = particleLargeRainbowRingImage,
opacity = 0,
startOpacity = 0,
finishOpacity = 1,
startX = (1080/2-(2160*0.675)/2),
finishX = (1080/2-(2160*0.675)/2),
xPos = (1080/2-(2160*0.675)/2),
yPos = (680-(2273*0.675)/2) + 100,
width = 2160*0.675,
height = 2273*0.675,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
},
2021-11-17 21:26:44 +01:00
{
name = 'red_ball',
texture = particleRedBallImage,
startOpacity = 0,
finishOpacity = 1,
opacity = 0,
xPos = -150,
yPos = 500,
width = 787*0.5,
height = 818*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
},
2021-11-17 21:26:44 +01:00
{
name = 'red_ring',
2021-11-17 19:05:08 +01:00
texture = particleRedRingImage,
opacity = 1,
2021-11-17 19:05:08 +01:00
startX = -600,
finishX = 590,
xPos = -600,
2021-11-17 19:05:08 +01:00
yPos = 460,
width = 1051*0.5,
height = 1081*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
2021-11-17 19:05:08 +01:00
},
2021-11-17 21:26:44 +01:00
{
name = 'small_yellow_ring_1',
2021-11-17 19:09:54 +01:00
texture = particleSmallYellowRing1Image,
opacity = 1,
2021-11-17 19:09:54 +01:00
startX = 1280,
finishX = -170,
xPos = 1280,
2021-11-17 19:09:54 +01:00
yPos = 620,
width = 579*0.5,
height = 557*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
2021-11-17 19:09:54 +01:00
},
2021-11-17 21:26:44 +01:00
{
name = 'small_yellow_ring_2',
2021-11-17 19:14:15 +01:00
texture = particleSmallYellowRing2Image,
opacity = 1,
2021-11-17 19:14:15 +01:00
startX = 1280,
finishX = 140,
xPos = 1280,
2021-11-17 19:14:15 +01:00
yPos = 590,
width = 436*0.5,
height = 392*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
2021-11-17 19:14:15 +01:00
},
2021-11-17 21:26:44 +01:00
{
name = 'small_rainbow_ring',
2021-11-17 19:24:56 +01:00
texture = particleSmallRainbowRingImage,
opacity = 1,
2021-11-17 19:24:56 +01:00
startX = 1280,
finishX = -380,
xPos = 1280,
2021-11-17 19:24:56 +01:00
yPos = 450,
width = 1117*0.5,
height = 1117*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
2021-11-17 19:24:56 +01:00
},
2021-11-17 21:26:44 +01:00
{
name = 'yellow_ring',
2021-11-17 19:48:01 +01:00
texture = particleYellowRingImage,
opacity = 1,
2021-11-17 19:48:01 +01:00
startX = -600,
finishX = 650,
xPos = -600,
2021-11-17 19:48:01 +01:00
yPos = 370,
width = 1401*0.5,
height = 1398*0.5,
2021-11-17 20:05:18 +01:00
startTime = particlesStartTime,
duration = particlesDuration
},
2021-11-17 21:26:44 +01:00
{
name = 'blue_flare',
2021-11-17 20:05:18 +01:00
texture = flareEndBlueImage,
opacity = 1,
startX = -1500,
finishX = 0,
xPos = -1500,
yPos = 480,
width = 2160*0.5,
height = 1100*0.5,
startTime = particlesStartTime,
duration = particlesDuration
},
2021-11-17 21:26:44 +01:00
{
name = 'pink_flare',
2021-11-17 20:05:18 +01:00
texture = flareEndPinkImage,
opacity = 1,
startX = 1500,
finishX = 0,
xPos = 1080+1500,
yPos = 480,
width = 2160*0.5,
height = 1100*0.5,
startTime = particlesStartTime,
duration = particlesDuration
2021-11-17 19:48:01 +01:00
},
}
2021-10-28 14:54:31 +02:00
2021-10-28 12:17:20 +02:00
2021-10-30 21:50:55 +02:00
if (game.GetSkinSetting('audio_systemVoice')) then
game.LoadSkinSample('gameplay/track_comp_rasis.wav');
else
game.LoadSkinSample('gameplay/track_comp.wav');
end
2021-10-29 16:09:09 +02:00
local compSfxPlayed = false;
2021-10-28 12:17:20 +02:00
local tickTransitions = function (deltaTime)
if outroTransitionScale < 1 then
outroTransitionScale = outroTransitionScale + deltaTime / 3 -- transition should last for that time in seconds
2021-10-28 12:17:20 +02:00
else
outroTransitionScale = 1
end
outroTransitionGlobalAlpha = math.min(1, (outroTransitionScale*6))
outroTransitionEnterFlareX = math.min(2*1920, (
(outroTransitionScale-0.2)/0.1* -- Last from 0.2 transition scale for 0.1 transition scale, ending at 0.3 TS
(1920*2) -- move this amount during the transition
)-1920); -- start off-screen
2021-10-28 13:13:34 +02:00
outroTransitionTextCutX = math.min(1920, (
(outroTransitionScale-0.25)/0.2* -- Last from 0.25 transition scale for 0.2 transition scale, ending at 0.45 TS
(1920) -- reveal this amount during the transition (the whole width)
)-0); -- start from 0
2021-10-28 13:46:24 +02:00
2021-10-28 14:54:31 +02:00
local particleTransitionScale = Easing.outQuad(math.min(1,
(outroTransitionScale-0.25)/0.2) -- Last from 0.25 transition scale for 0.2 transition scale, ending at 0.45 TS
)
for particleName, particle in pairs(particles) do
local transScale = Easing.outQuad(math.min(1, (outroTransitionScale-particle.startTime)/particle.duration));
if (particle.finishX) then -- If x position want to have anim
if (outroTransitionScale < particle.startTime) then
particle.xPos = particle.startX;
elseif (outroTransitionScale >= particle.startTime + particle.duration) then
particle.xPos = particle.finishX;
else
local xDiff = particle.finishX - particle.startX;
particle.xPos = particle.startX + xDiff*transScale;
end
end
if (particle.finishOpacity) then
if (outroTransitionScale < particle.startTime) then
particle.opacity = particle.startOpacity;
elseif (outroTransitionScale >= particle.startTime + particle.duration) then
particle.opacity = particle.finishOpacity;
else
local opacityDiff = particle.finishOpacity - particle.startOpacity;
particle.opacity = particle.startOpacity + opacityDiff*transScale;
end
end
end
-- if (outroTransitionScale > 0.45 and outroTransitionScale < 0.5) then
-- if (outroTransitionScale <= 0.475) then
-- outroTransitionTextAlpha = 1-(0.5*((outroTransitionScale-0.45)/0.075))
-- else
-- outroTransitionTextAlpha = 0.5+0.5*((outroTransitionScale-0.475)/0.075)
-- end
-- else
-- outroTransitionTextAlpha = 1;
-- end
2021-10-28 13:46:24 +02:00
end
local drawParticles = function ()
2021-11-17 21:26:44 +01:00
for index, particle in ipairs(particles) do
gfx.BeginPath();
gfx.ImageRect(
particle.xPos,
particle.yPos,
particle.width,
particle.height,
particle.texture,
particle.opacity,
0
);
2021-11-17 21:26:44 +01:00
-- game.Log(particle.name, game.LOGGER_ERROR)
end
2021-11-17 20:13:41 +01:00
gfx.BeginPath();
-- gfx.BeginPath();
-- gfx.ImageRect(
-- outroTransitionParticleRedX-80,
-- 510-80,
-- 787*0.7,
-- 818*0.7,
-- particleYellowRing,
-- 1,
-- 0
-- );
-- gfx.BeginPath();
-- gfx.ImageRect(
-- outroTransitionParticleRedX,
-- 510,
-- 787*0.5,
-- 818*0.5,
-- particleRedBall,
-- 1,
-- 0
-- );
-- gfx.BeginPath();
-- gfx.ImageRect(
-- outroTransitionParticleRedX,
-- 510,
-- 787*0.5,
-- 818*0.5,
-- particleRedRing,
-- 1,
-- 0
-- );
-- -- Right side
-- gfx.BeginPath();
-- gfx.ImageRect(
-- outroTransitionParticleSmallRainbowX,
-- 465,
-- 1117*0.5,
-- 1117*0.5,
-- particleSmallRainbowRing,
-- 1,
-- 0
-- );
-- gfx.BeginPath();
-- gfx.ImageRect(
-- outroTransitionParticleSmallYellowRingAX,
-- 575,
-- 579*0.5,
-- 557*0.5,
-- particleSmYellowRingA,
-- 1,
-- 0
-- );
-- gfx.BeginPath();
-- gfx.ImageRect(
-- outroTransitionParticleSmallYellowRingBX,
-- 585,
-- 436*0.5,
-- 392*0.5,
-- particleSmYellowRingB,
-- 1,
-- 0
-- );
-- gfx.BeginPath();
-- gfx.ImageRect(
-- outroTransitionParticleSmallYellowRingCX,
-- 625,
-- 275*0.5,
-- 275*0.5,
-- particleSmYellowRingC,
-- 1,
-- 0
-- );
2021-10-28 12:17:20 +02:00
end
2021-10-29 16:09:09 +02:00
local handleSounds = function ()
if not compSfxPlayed then
2021-10-30 21:50:55 +02:00
compSfxPlayed = true;
if (game.GetSkinSetting('audio_systemVoice')) then
game.PlaySample('gameplay/track_comp_rasis.wav');
else
game.PlaySample('gameplay/track_comp.wav');
end
2021-10-29 16:09:09 +02:00
end
end
2021-10-28 12:17:20 +02:00
local render = function (deltaTime)
tickTransitions(deltaTime);
2021-10-29 16:09:09 +02:00
handleSounds();
2021-10-28 12:17:20 +02:00
gfx.GlobalAlpha(outroTransitionGlobalAlpha);
gfx.BeginPath();
gfx.ImageRect(
0,
0,
2160*0.5,
3840*0.5,
bgImage,
1,
0
);
gfx.BeginPath();
gfx.ImageRect(
0,
0,
2160*0.5,
1921*0.5,
bgHexTopImage,
1,
0
);
gfx.BeginPath();
gfx.ImageRect(
0,
1920-(1921*0.5),
2160*0.5,
1921*0.5,
bgHexBottomImage,
1,
0
);
-- Enter flares
gfx.BeginPath();
gfx.ImageRect(
outroTransitionEnterFlareX,
530,
3280*0.5,
790*0.5,
enterFlareBlueImage,
1,
0
);
gfx.BeginPath();
gfx.ImageRect(
-outroTransitionEnterFlareX, -- go from the other side of the screen
530,
3280*0.5,
790*0.5,
enterFlarePinkImage,
1,
0
);
2021-10-28 13:46:24 +02:00
drawParticles();
2021-10-28 13:13:34 +02:00
gfx.BeginPath();
gfx.Scissor(0, 530, outroTransitionTextCutX, 1920)
gfx.GlobalAlpha(outroTransitionTextAlpha);
2021-10-28 13:13:34 +02:00
gfx.ImageRect(
0,
680,
2160*0.5,
177*0.5,
trackCompImage,
1,
0
);
gfx.GlobalAlpha(outroTransitionGlobalAlpha);
2021-10-28 13:13:34 +02:00
gfx.ResetScissor();
2021-10-28 12:17:20 +02:00
-- Get the banner downscaled in whatever resolution it is, while maintaining the aspect ratio
-- local tw,th = gfx.ImageSize(bannerBaseImage);
-- BANNER_H = th * (1080/tw);
-- gfx.BeginPath();
-- gfx.ImageRect(
-- 0,
-- 0,
-- BANNER_W,
-- BANNER_H,
-- bannerBaseImage,
-- 1,
-- 0
-- );
end
return {
render=render
}