+ basics of background component

This commit is contained in:
FajsiEx 2021-08-21 13:49:51 +02:00
parent d25d8a1fae
commit ae90c2e86e
10 changed files with 86 additions and 2 deletions

View File

@ -0,0 +1,83 @@
local resx, resy = game.GetResolution()
local desw, desh = 1080,1920;
local scale = 1;
local BAR_ALPHA = 191;
local FOOTER_HEIGHT = 128
local footerY = desh - FOOTER_HEIGHT;
-- Images
local bgBaseImage = gfx.CreateSkinImage("components/background/bg.png", 0);
local dotsOverlayImage = gfx.CreateSkinImage("components/background/dots.png", 0);
local valk1Image = gfx.CreateSkinImage("components/background/test.png", 0);
-- Animation related
local transitionRotateScale = 0;
function resetLayoutInformation()
resx, resy = game.GetResolution()
desw = 1080
desh = 1920
scale = resx / desw
end
local drawValkyrie = function (piProgression)
gfx.Save()
gfx.BeginPath()
local distanceScaleMultiplier = (math.sin(piProgression)+math.pi)*0.25 + 0.25
gfx.Translate(math.sin(piProgression+2)*0.6*desw+0.5*desw,-math.sin(piProgression+2)*0.1*desh+desh*0.1)
gfx.Scale(math.sin(piProgression)*distanceScaleMultiplier, 1*distanceScaleMultiplier)
gfx.SkewY(-math.sin(piProgression+0.5*math.pi)*0.3)
gfx.ImageRect(0, 0, 540, 960, valk1Image, 1, 0);
gfx.Restore()
end
local drawValkyries = function ()
gfx.BeginPath()
local piProgression = 1-transitionRotateScale*2*math.pi
drawValkyrie(piProgression)
drawValkyrie(piProgression+math.pi*0.5)
drawValkyrie(piProgression+math.pi*1.0)
drawValkyrie(piProgression+math.pi*1.5)
end
local drawBackground = function ()
gfx.BeginPath();
gfx.ImageRect(0, 0, desw, desh, bgBaseImage, 1, 0);
drawValkyries();
gfx.BeginPath();
gfx.ImageRect(0, 0, desw, desh, dotsOverlayImage, 1, 0);
end
local progressTransitions = function (deltaTime)
transitionRotateScale = transitionRotateScale + deltaTime / 10;
if (transitionRotateScale > 1) then
transitionRotateScale = 0;
end
end
local draw = function (deltaTime)
gfx.Save()
resetLayoutInformation()
gfx.Scale(scale, scale)
drawBackground();
progressTransitions(deltaTime);
gfx.Restore()
end
return {
draw = draw
};

View File

@ -1,4 +1,5 @@
local Footer = require('components.footer'); local Footer = require('components.footer');
local Background = require('components.background');
local cursorIndex = 3; local cursorIndex = 3;
local buttonHeight = 128 + 16; local buttonHeight = 128 + 16;
@ -332,7 +333,7 @@ render = function(deltaTime)
-- Draw background -- Draw background
gfx.BeginPath(); gfx.BeginPath();
gfx.ImageRect(0, 0, desw, desh, bgImage, 1, 0); Background.draw(deltaTime)
local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime); local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime);
if idolAnimTickRes == 1 then if idolAnimTickRes == 1 then
@ -344,7 +345,7 @@ render = function(deltaTime)
end end
gfx.BeginPath(); gfx.BeginPath();
gfx.ImageRect(0, 0, desw, desh, idolAnimation, 1, 0); --gfx.ImageRect(0, 0, desw, desh, idolAnimation, 1, 0);
gfx.GlobalAlpha(1); gfx.GlobalAlpha(1);
end end

View File

Before

Width:  |  Height:  |  Size: 4.6 MiB

After

Width:  |  Height:  |  Size: 4.6 MiB

View File

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

Before

Width:  |  Height:  |  Size: 4.7 MiB

After

Width:  |  Height:  |  Size: 4.7 MiB

View File

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View File

Before

Width:  |  Height:  |  Size: 227 KiB

After

Width:  |  Height:  |  Size: 227 KiB

View File

Before

Width:  |  Height:  |  Size: 346 KiB

After

Width:  |  Height:  |  Size: 346 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 MiB

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB