diff --git a/scripts/components/background.lua b/scripts/components/background.lua new file mode 100644 index 0000000..c9d1d9e --- /dev/null +++ b/scripts/components/background.lua @@ -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 +}; \ No newline at end of file diff --git a/scripts/titlescreen.lua b/scripts/titlescreen.lua index e4ef0cb..72d5259 100644 --- a/scripts/titlescreen.lua +++ b/scripts/titlescreen.lua @@ -1,4 +1,5 @@ local Footer = require('components.footer'); +local Background = require('components.background'); local cursorIndex = 3; local buttonHeight = 128 + 16; @@ -332,7 +333,7 @@ render = function(deltaTime) -- Draw background gfx.BeginPath(); - gfx.ImageRect(0, 0, desw, desh, bgImage, 1, 0); + Background.draw(deltaTime) local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime); if idolAnimTickRes == 1 then @@ -344,7 +345,7 @@ render = function(deltaTime) end gfx.BeginPath(); - gfx.ImageRect(0, 0, desw, desh, idolAnimation, 1, 0); + --gfx.ImageRect(0, 0, desw, desh, idolAnimation, 1, 0); gfx.GlobalAlpha(1); end diff --git a/textures/bg/bg.png b/textures/components/background/bg.png similarity index 100% rename from textures/bg/bg.png rename to textures/components/background/bg.png diff --git a/textures/bg/blue_flare.png b/textures/components/background/blue_flare.png similarity index 100% rename from textures/bg/blue_flare.png rename to textures/components/background/blue_flare.png diff --git a/textures/bg/dots.png b/textures/components/background/dots.png similarity index 100% rename from textures/bg/dots.png rename to textures/components/background/dots.png diff --git a/textures/bg/hex1.png b/textures/components/background/hex1.png similarity index 100% rename from textures/bg/hex1.png rename to textures/components/background/hex1.png diff --git a/textures/bg/hex2.png b/textures/components/background/hex2.png similarity index 100% rename from textures/bg/hex2.png rename to textures/components/background/hex2.png diff --git a/textures/bg/hex3.png b/textures/components/background/hex3.png similarity index 100% rename from textures/bg/hex3.png rename to textures/components/background/hex3.png diff --git a/textures/bg/pink_flare.png b/textures/components/background/pink_flare.png similarity index 100% rename from textures/bg/pink_flare.png rename to textures/components/background/pink_flare.png diff --git a/textures/components/background/test.png b/textures/components/background/test.png new file mode 100644 index 0000000..829fe8b Binary files /dev/null and b/textures/components/background/test.png differ