diff --git a/nautica.json b/nautica.json index dd7a246..bf1d94e 100644 --- a/nautica.json +++ b/nautica.json @@ -1 +1 @@ -{"3ff083a0-138a-11eb-b7fa-73440733704d":"Downloaded","6df03d20-dcb0-11eb-b3d0-b7e5f9bb55e7":"Downloaded","700c75a0-e9fb-11eb-9cdd-15b32e9a44d8":"Downloaded","6578e6d0-ebe2-11eb-a3e8-476e0023a0e2":"Downloaded"} \ No newline at end of file +{"6578e6d0-ebe2-11eb-a3e8-476e0023a0e2":"Downloaded","6df03d20-dcb0-11eb-b3d0-b7e5f9bb55e7":"Downloaded","700c75a0-e9fb-11eb-9cdd-15b32e9a44d8":"Downloaded","3ff083a0-138a-11eb-b7fa-73440733704d":"Downloaded"} \ No newline at end of file diff --git a/scripts/common/easings.lua b/scripts/common/easings.lua new file mode 100644 index 0000000..19fd2e7 --- /dev/null +++ b/scripts/common/easings.lua @@ -0,0 +1,58 @@ +-- +-- Adapted from +-- Tweener's easing functions (Penner's Easing Equations) +-- and http://code.google.com/p/tweener/ (jstweener javascript version) +-- +--[[ +Disclaimer for Robert Penner's Easing Equations license: +TERMS OF USE - EASING EQUATIONS +Open source under the BSD License. +Copyright © 2001 Robert Penner +All rights reserved. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +]] -- For all easing functions: +-- t = elapsed time +-- b = begin +-- c = change == ending - beginning +-- d = duration (total time) +local pow = function (a,b) + return a ^ b; +end + +local function inQuad(t, b, c, d) + t = t / 1 + return 1 * pow(t, 2) + 0 +end + +local function outQuad(t, b, c, d) + t = t / 1 + return -1 * t * (t - 2) + 0 +end + +local function inOutQuad(t, b, c, d) + t = t / d * 2 + if t < 1 then + return c / 2 * pow(t, 2) + b + else + return -c / 2 * ((t - 1) * (t - 3) - 1) + b + end +end + +local function outInQuad(t, b, c, d) + if t < d / 2 then + return outQuad(t * 2, b, c / 2, d) + else + return inQuad((t * 2) - d, b + c / 2, c / 2, d) + end +end + +return { + inQuad = inQuad, + outQuad = outQuad, + inOutQuad = inOutQuad, + outInQuad = outInQuad +} diff --git a/scripts/result.lua b/scripts/result.lua index 028d584..38d4ade 100644 --- a/scripts/result.lua +++ b/scripts/result.lua @@ -1,10 +1,29 @@ -local resx,resy = game.GetResolution() +local Easing = require('common.easings'); + +local resx, resy = game.GetResolution() local desw = 1080 local desh = 1920 local bgSfxPlayed = false; local backgroundImage = gfx.CreateSkinImage("bg.png", 1); + +local topBarImage = gfx.CreateSkinImage("result/top_bar.png", 1); +local jacketPanelImage = gfx.CreateSkinImage("result/panels/jacket.png", 1); +local rightPanelImage = gfx.CreateSkinImage("result/panels/right.png", 1); +local bottomPanelImage = gfx.CreateSkinImage("result/panels/bottom.png", 1); + +local jacketImage = gfx.CreateSkinImage("result/default_jacket.png", 1); + +local transitionEnterScale = 0; + +local jacketPanelX = 0; +local jacketPanelY = 820; + +local JACKET_PANEL_TRANSTION_ENTER_OFFSET = -128; +local RIGHT_PANEL_TRANSTION_ENTER_OFFSET = 128; +local BOTTOM_PANEL_TRANSTION_ENTER_OFFSET = 128; + game.LoadSkinSample("result") function resetLayoutInformation() @@ -14,20 +33,124 @@ function resetLayoutInformation() scale = resx / desw end -render = function(deltaTime, showStats) - resetLayoutInformation() - - gfx.ImageRect(0, 0, desw, desh, backgroundImage, 0.5, 0); - gfx.Scale(scale,scale) - +local handleSfx = function() if not bgSfxPlayed then game.PlaySample("result", true) bgSfxPlayed = true end - if game.GetButton(game.BUTTON_STA) then - game.StopSample("result") + if game.GetButton(game.BUTTON_STA) then game.StopSample("result") end + if game.GetButton(game.BUTTON_BCK) then game.StopSample("result") end +end + +local drawTopBar = function() + gfx.BeginPath(); + local tw, th = gfx.ImageSize(topBarImage); + gfx.ImageRect(0, -th * (1 - Easing.outQuad(transitionEnterScale)), desw, th, + topBarImage, 1, 0); + gfx.ClosePath(); +end + + +local drawRightPanel = function() + gfx.BeginPath(); + local tw, th = gfx.ImageSize(rightPanelImage); + + gfx.ImageRect( + 0+(RIGHT_PANEL_TRANSTION_ENTER_OFFSET * (1 - Easing.outQuad(transitionEnterScale))), + 850, + tw, + th, + rightPanelImage, + Easing.outQuad(transitionEnterScale), + 0 + ); + + gfx.ClosePath(); +end + +local drawBottomPanel = function () + gfx.BeginPath(); + local tw, th = gfx.ImageSize(bottomPanelImage); + + gfx.ImageRect( + 0, + 1110+(BOTTOM_PANEL_TRANSTION_ENTER_OFFSET * (1 - Easing.outQuad(transitionEnterScale))), + tw, + th, + bottomPanelImage, + Easing.outQuad(transitionEnterScale), + 0 + ); + + gfx.ClosePath(); +end + +local drawJacketPanel = function() + gfx.BeginPath(); + local tw, th = gfx.ImageSize(jacketPanelImage); + + gfx.ImageRect( + jacketPanelX, + jacketPanelY, + tw, + th, + jacketPanelImage, + Easing.outQuad(transitionEnterScale), + 0 + ); + + gfx.ClosePath(); +end + +local drawJacketPanelContent = function () + gfx.BeginPath() + gfx.ImageRect( + jacketPanelX+12, + jacketPanelY+26, + 273, + 273, + jacketImage, + Easing.outQuad(transitionEnterScale), + 0 + ); + gfx.ClosePath() +end + +local tickTransitions = function(deltaTime) + + if transitionEnterScale < 1 then + transitionEnterScale = transitionEnterScale + deltaTime / 5 + else + transitionEnterScale = 1 end - if game.GetButton(game.BUTTON_BCK) then - game.StopSample("result") + + jacketPanelX = 40 + (JACKET_PANEL_TRANSTION_ENTER_OFFSET * (1 - Easing.outQuad(transitionEnterScale))) +end + +result_set = function () + if result.jacketPath ~= nil and result.jacketPath ~= "" then + jacketImage = gfx.CreateImage(result.jacketPath, 1) end -end \ No newline at end of file +end + +render = function(deltaTime, showStats) + resetLayoutInformation() + gfx.Scale(scale, scale) + + gfx.ImageRect(0, 0, desw, desh, backgroundImage, 1, 0); + + drawTopBar() + drawBottomPanel() + drawRightPanel() + drawJacketPanel() + drawJacketPanelContent() + + handleSfx() + + -- debug + gfx.Text('DELTA: ' .. deltaTime .. ' // TRANSITION_ENTER_SCALE: ' .. + transitionEnterScale .. ' // EASING_OUT_QUAD: ' .. + Easing.outQuad(transitionEnterScale), 255, 255); + + tickTransitions(deltaTime) +end diff --git a/textures/result/default_jacket.png b/textures/result/default_jacket.png new file mode 100644 index 0000000..d7db32d Binary files /dev/null and b/textures/result/default_jacket.png differ diff --git a/textures/result/panels/bottom.png b/textures/result/panels/bottom.png index 16a0306..a9367ad 100644 Binary files a/textures/result/panels/bottom.png and b/textures/result/panels/bottom.png differ diff --git a/textures/result/panels/jacket.png b/textures/result/panels/jacket.png index 51df019..7258438 100644 Binary files a/textures/result/panels/jacket.png and b/textures/result/panels/jacket.png differ diff --git a/textures/result/panels/right.png b/textures/result/panels/right.png index 1750a2b..72cb90f 100644 Binary files a/textures/result/panels/right.png and b/textures/result/panels/right.png differ diff --git a/textures/result/top_bar.png b/textures/result/top_bar.png new file mode 100644 index 0000000..e96d05e Binary files /dev/null and b/textures/result/top_bar.png differ