gameplay, transition, and track end screen improvements

these screens are not broken in landscape mode anymore

also replaced some duplicated code to require 'common.numbers'
This commit is contained in:
Hersi 2021-12-02 03:41:12 +01:00
parent 3db4d2e5f2
commit 8e9c9d38fc
15 changed files with 255 additions and 211 deletions

View File

@ -15,9 +15,27 @@ local TrackEnd = require('gameplay.track_end')
local json = require "json"
local resx, resy = game.GetResolution()
local desw, desh;
local scale;
-- Window variables
local resX, resY
-- Aspect Ratios
local landscapeWidescreenRatio = 16 / 9
local landscapeStandardRatio = 4 / 3
local portraitWidescreenRatio = 9 / 16
-- Portrait sizes
local fullX, fullY
local desw = 1080
local desh = 1920
local resolutionChange = function(x, y)
resX = x
resY = y
fullX = portraitWidescreenRatio * y
fullY = y
game.Log('resX:' .. resX .. ' // resY:' .. resY .. ' // fullX:' .. fullX .. ' // fullY:' .. fullY, game.LOGGER_ERROR);
end
local users = nil
@ -25,22 +43,12 @@ local maxChain = 0;
local chain = 0;
local score = 0;
function resetLayoutInformation()
resx, resy = game.GetResolution()
if (resx > resy) then
desw = 1920
desh = 1080
scale = resx / desw
else
desw = 1080
desh = 1920
scale = resx / desw
end
end
function render(deltaTime)
resetLayoutInformation();
gfx.Scale(scale, scale);
-- detect resolution change
local resx, resy = game.GetResolution();
if resx ~= resX or resy ~= resY then
resolutionChange(resx, resy)
end
Banner.render(deltaTime, users, gameplay.user_id);

View File

@ -45,6 +45,7 @@ local render = function (deltaTime, users, currentUserId)
drawScoreboard(users, currentUserId); -- TODO: for now
-- hide if landscape
if (resx > resy) then
return
end

View File

@ -1,3 +1,4 @@
local Numbers = require('common.numbers')
local chainLabel = gfx.CreateSkinImage("gameplay/chain/label.png", 0)
@ -10,38 +11,9 @@ local transitionShakeScale = 0;
local transitionShakePosOffset = 0;
local shakeTimer = 0;
function load_number_image(path)
local images = {}
for i = 0, 9 do
images[i + 1] = gfx.CreateSkinImage(string.format("%s/%d.png", path, i), 0)
end
return images
end
local chainNumbersReg = load_number_image('gameplay/chain/reg')
local chainNumbersUC = load_number_image('gameplay/chain/uc')
local chainNumbersPUC = load_number_image('gameplay/chain/puc')
function draw_number(x, y, alpha, num, digits, images, is_dim, scale, kern)
scale = scale or 1;
kern = kern or 1;
local tw, th = gfx.ImageSize(images[1])
tw = tw * scale;
th = th * scale;
x = x + (tw * (digits - 1)) / 2
y = y - th / 2
for i = 1, digits do
local mul = 10 ^ (i - 1)
local digit = math.floor(num / mul) % 10
local a = alpha
if is_dim and num < mul then
a = 0.4
end
gfx.BeginPath()
gfx.ImageRect(x, y, tw, th, images[digit + 1], a, 0)
x = x - (tw * kern)
end
end
local chainNumbersReg = Numbers.load_number_image('gameplay/chain/reg')
local chainNumbersUC = Numbers.load_number_image('gameplay/chain/uc')
local chainNumbersPUC = Numbers.load_number_image('gameplay/chain/puc')
local tickTransitions = function (deltaTime)
@ -93,7 +65,11 @@ local render = function (deltaTime, comboState, combo, critLineCenterX, critLine
bottomOffsetMultiplier = 0.25
end
local posx = desw / 2 + transitionShakePosOffset;
local scale = resy / desh
if scale == 0 then
scale = 1
end
local posx = (resx / 2 + transitionShakePosOffset) / scale; -- counteract scaling
local posy = desh - (desh*bottomOffsetMultiplier) + transitionShakePosOffset;
local chainNumbers = chainNumbersReg --regular
@ -107,6 +83,8 @@ local render = function (deltaTime, comboState, combo, critLineCenterX, critLine
end
end
gfx.Scale(scale, scale)
-- \_ chain _/
local tw, th
tw, th = gfx.ImageSize(chainLabel)
@ -117,7 +95,9 @@ local render = function (deltaTime, comboState, combo, critLineCenterX, critLine
posy = posy - th + 32
local comboScale = 0.45;
draw_number(posx - (tw*4*comboScale)/2+(tw*comboScale*1.5)+10, posy - th / 2, 1.0, combo, 4, chainNumbers, true, comboScale, 1.12)
Numbers.draw_number(posx - (tw*4*comboScale)/2+(tw*comboScale*1.5)+10, posy - th / 2, 1.0, combo, 4, chainNumbers, true, comboScale, 1.12)
gfx.ResetTransform()
gfx.Restore();
end

View File

@ -49,7 +49,10 @@ local render = function (deltaTime, gaugeType, gaugeValue, isArsEnabled)
desh = 1920;
end
gfx.Translate(desw,0);
gfx.Translate(resx, 0);
local scale = resy / desh
gfx.Scale(scale, scale)
local gaugeIndex = math.min(gaugeType+1, 4) -- Any gauge type above blastive will be blastive as a fallback
local currentGauge = gauges[gaugeIndex]
@ -85,7 +88,8 @@ local render = function (deltaTime, gaugeType, gaugeValue, isArsEnabled)
local BgW, BgH = gfx.ImageSize(gaugeBgImage);
local FillW, FillH = gfx.ImageSize(gaugeFillImage);
local gaugePosX = - BgW - (isLandscape and 400 or 110);
local landscapeXCorrection = resx / desw
local gaugePosX = - BgW - (isLandscape and 400 * landscapeXCorrection or 110);
local gaugePosY = desh/2 - BgH/2 - (isLandscape and 0 or 95);
gfx.BeginPath()
@ -173,6 +177,8 @@ local render = function (deltaTime, gaugeType, gaugeValue, isArsEnabled)
gfx.FontSize(16)
gfx.Text('%', gaugePosX-15, gaugeMarkerY+16.5)
gfx.ResetTransform()
gfx.Restore();
end

View File

@ -185,15 +185,20 @@ local render = function (deltaTime)
ALERT_Y_POS = desh*0.58
end
RIGHT_ALERT_X_POS = desw - 450*0.5
local scale = resy / desh
RIGHT_ALERT_X_POS = (resx - 450*0.5) / scale
tickTransitions(deltaTime);
gfx.Save();
gfx.Scale(scale, scale)
renderLeftAlert();
renderRightAlert();
test = test + deltaTime;
gfx.ResetTransform()
gfx.Restore();
-- gfx.BeginPath();
-- gfx.FontSize(18)

View File

@ -1,3 +1,4 @@
local Numbers = require('common.numbers')
local bgImage = gfx.CreateSkinImage("gameplay/score_panel/bg.png", 0)
@ -6,36 +7,7 @@ local desh = 1920;
local isLandscape = false;
function load_number_image(path)
local images = {}
for i = 0, 9 do
images[i + 1] = gfx.CreateSkinImage(string.format("%s/%d.png", path, i), 0)
end
return images
end
local scoreNumbers = load_number_image('score_num')
function draw_number(x, y, alpha, num, digits, images, is_dim, scale, kern)
scale = scale or 1;
kern = kern or 1;
local tw, th = gfx.ImageSize(images[1])
tw = tw * scale;
th = th * scale;
x = x + (tw * (digits - 1)) / 2
y = y - th / 2
for i = 1, digits do
local mul = 10 ^ (i - 1)
local digit = math.floor(num / mul) % 10
local a = alpha
if is_dim and num < mul then
a = 0.4
end
gfx.BeginPath()
gfx.ImageRect(x, y, tw, th, images[digit + 1], a, 0)
x = x - (tw * kern)
end
end
local scoreNumbers = Numbers.load_number_image("score_num")
local tickTransitions = function (deltaTime)
@ -57,7 +29,7 @@ local render = function (deltaTime, score, maxChain)
tickTransitions(deltaTime)
local x = desw;
local x = resx;
local y = isLandscape and 5 or 330;
if (isLandscape) then
@ -65,6 +37,9 @@ local render = function (deltaTime, score, maxChain)
x=0
end
local scale = resy / desh
gfx.Scale(scale, scale)
gfx.BeginPath();
gfx.ImageRect(
x-740*0.61, -- WHY IS THERE DIFFERENT SCALING FOR THIS TOO????
@ -76,8 +51,8 @@ local render = function (deltaTime, score, maxChain)
0
);
draw_number(x-309.4, y + 83, 1.0, score/10000, 4, scoreNumbers, true, 0.38, 1.12)
draw_number(x-113.4, y + 90, 1.0, score, 4, scoreNumbers, true, 0.28, 1.12)
Numbers.draw_number(x-309.4, y + 83, 1.0, score/10000, 4, scoreNumbers, true, 0.38, 1.12)
Numbers.draw_number(x-113.4, y + 90, 1.0, score, 4, scoreNumbers, true, 0.28, 1.12)
-- Draw max chain
gfx.BeginPath();
@ -88,6 +63,8 @@ local render = function (deltaTime, score, maxChain)
gfx.FillColor(255,255,255,255);
gfx.Text(string.format("%04d", maxChain), x-281.4, y+155);
gfx.ResetTransform()
gfx.Restore();
end

View File

@ -50,9 +50,19 @@ local render = function (deltaTime, bpm, laneSpeed, jacketPath, diff, level, pro
tickTransitions(deltaTime)
if (isLandscape) then
desw = 1920;
desh = 1080;
else
desw = 1080;
desh = 1920;
end
local y = isLandscape and 0 or 210;
local scale = resy / desh
gfx.Scale(scale, scale)
gfx.BeginPath();
gfx.ImageRect(
0,
@ -124,6 +134,8 @@ local render = function (deltaTime, bpm, laneSpeed, jacketPath, diff, level, pro
gfx.FontSize(22)
gfx.Text(songTitle .. ' / ' .. songArtist, 385, y+60);
gfx.ResetTransform()
gfx.Restore();
end

View File

@ -1,8 +1,8 @@
local Easing = require('common.easings')
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 bgHexTopImage = gfx.CreateSkinImage("gameplay/track_end/top_hex.png", gfx.IMAGE_REPEATX)
local bgHexBottomImage = gfx.CreateSkinImage("gameplay/track_end/bottom_hex.png", gfx.IMAGE_REPEATX)
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)
@ -29,6 +29,26 @@ local particleYellowRingImage = gfx.CreateSkinImage("gameplay/track_end/particle
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)
-- Window variables
local resX, resY = game.GetResolution()
-- Aspect Ratios
local landscapeWidescreenRatio = 16 / 9
local landscapeStandardRatio = 4 / 3
local portraitWidescreenRatio = 9 / 16
-- Portrait sizes
local fullX = portraitWidescreenRatio * resY
local fullY = resY
local desW = 1080
local desH = 1920
local function resolutionChange(x, y)
resX = x
resY = y
fullX = portraitWidescreenRatio * y
fullY = y
end
local outroTransitionScale = 0;
local outroTransitionGlobalAlpha = 0;
@ -374,42 +394,46 @@ local handleSounds = function ()
end
end
local function renderBackground()
local bgHexW, bgHexH
local scale
gfx.BeginPath();
gfx.ImageRect(0, 0, resX, resY, bgImage, 1, 0)
gfx.BeginPath();
bgHexW, bgHexH = gfx.ImageSize(bgHexTopImage)
scale = (resY / 2) / bgHexH
gfx.Rect(0, 0, resX, resY / 2)
gfx.FillPaint(gfx.ImagePattern((resX - bgHexW * scale) / 2, 0, bgHexW * scale, bgHexH * scale, 0, bgHexTopImage, 1))
gfx.Fill()
gfx.BeginPath();
bgHexW, bgHexH = gfx.ImageSize(bgHexBottomImage)
scale = (resY / 2) / bgHexH
gfx.Rect(0, resY / 2, resX, resY / 2)
gfx.FillPaint(gfx.ImagePattern((resX - bgHexW * scale) / 2, resY / 2, bgHexW * scale, bgHexH * scale, 0, bgHexBottomImage, 1))
gfx.Fill()
end
local render = function (deltaTime)
local resx, resy = game.GetResolution()
if resx ~= resX or resy ~= resY then
resolutionChange(resx, resy)
end
tickTransitions(deltaTime);
handleSounds();
gfx.GlobalAlpha(outroTransitionGlobalAlpha);
gfx.BeginPath();
gfx.ImageRect(
0,
0,
2160*0.5,
3840*0.5,
bgImage,
1,
0
);
renderBackground()
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
);
local xOffset = (resX - fullX) / 2
gfx.Translate(xOffset, 0);
gfx.Scale(fullX / desW, fullY / desH);
gfx.Scissor(0, 0, desW, desH);
-- Enter flares
gfx.BeginPath();

View File

@ -72,6 +72,9 @@ local render = function (deltaTime, score, bestReplay)
tickTransitions(deltaTime)
local scale = resy / desh
gfx.Scale(scale, scale)
gfx.BeginPath();
gfx.ImageRect(
0,
@ -128,6 +131,8 @@ local render = function (deltaTime, score, bestReplay)
);
VolforceWindow.render(deltaTime, 220, y+197)
gfx.ResetTransform()
end

View File

@ -9,13 +9,29 @@ local creww = game.GetSkinSetting("single_idol")
local VolforceWindow = require('components.volforceWindow')
local resx, resy = game.GetResolution()
-- Window variables
local resX, resY
-- Aspect Ratios
local landscapeWidescreenRatio = 16 / 9
local landscapeStandardRatio = 4 / 3
local portraitWidescreenRatio = 9 / 16
-- Portrait sizes
local fullX, fullY
local desw = 1080
local desh = 1920
local function resolutionChange(x, y)
resX = x
resY = y
fullX = portraitWidescreenRatio * y
fullY = y
end
local bgSfxPlayed = false;
local backgroundImage = gfx.CreateSkinImage("bg.png", 0);
local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY)
local topBarImage = gfx.CreateSkinImage("result/top_bar.png", 0);
local jacketPanelImage = gfx.CreateSkinImage("result/panels/jacket.png", 0);
@ -159,13 +175,6 @@ local irText = ''
game.LoadSkinSample("result")
function resetLayoutInformation()
resx, resy = game.GetResolution()
desw = 1080
desh = 1920
scale = resx / desw
end
local handleSfx = function()
if not bgSfxPlayed then
game.PlaySample("result", true)
@ -653,19 +662,12 @@ result_set = function()
earlyLateBarsStats.criticals = result.perfects -- Criticals are for all objects
end
render = function(deltaTime, showStats)
gfx.BeginPath();
gfx.Save();
resetLayoutInformation()
gfx.ResetTransform();
gfx.ResetScissor();
gfx.BeginPath();
drawResultScreen = function (x, y, w, h, deltaTime)
gfx.BeginPath()
gfx.Scale(scale, scale)
gfx.Translate(x, y);
gfx.Scale(w / 1080, h / 1920);
gfx.Scissor(0, 0, 1080, 1920);
Background.draw(deltaTime)
drawIdol(deltaTime)
@ -676,7 +678,7 @@ render = function(deltaTime, showStats)
drawBottomPanel()
drawBottomPanelContent(deltaTime)
drawRightPanel()
drawRightBarAni(deltaTime)
drawbgrade()
@ -693,6 +695,24 @@ render = function(deltaTime, showStats)
handleSfx();
IR_Handle();
gfx.ResetTransform()
end
render = function(deltaTime, showStats)
-- detect resolution change
local resx, resy = game.GetResolution()
if resx ~= resX or resy ~= resY then
resolutionChange(resx, resy)
end
gfx.BeginPath()
local bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
gfx.Rect(0, 0, resX, resY)
gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2))
gfx.Fill()
drawResultScreen((resX - fullX) / 2, 0, fullX, fullY, deltaTime)
-- debug
gfx.FontSize(18)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
@ -701,7 +721,4 @@ render = function(deltaTime, showStats)
-- Easing.outQuad(transitionEnterScale), 8, 8);
tickTransitions(deltaTime)
gfx.Restore();
gfx.BeginPath();
end

View File

@ -489,7 +489,7 @@ render = function(deltaTime)
-- draw background image
gfx.BeginPath()
bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
local bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
gfx.Rect(0, 0, resX, resY)
gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2))
gfx.Fill()

View File

@ -1,9 +1,10 @@
require('common')
local Easing = require('common.easings')
local Background = require('components.background');
local Background = require('components.background')
local common = require('common.common')
local Numbers = require('common.numbers')
local VolforceCalc = require('components.volforceCalc');
local VolforceCalc = require('components.volforceCalc')
local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY)
@ -99,12 +100,8 @@ local difficultyLabelUnderImages = {
game.LoadSkinSample('song_wheel/cursor_change.wav');
game.LoadSkinSample('song_wheel/diff_change.wav');
local difficultyNumbers;
local scoreNumbers;
local resx, resy = game.GetResolution()
local desw, desh;
local scale;
local scoreNumbers = Numbers.load_number_image("score_num")
local difficultyNumbers = Numbers.load_number_image("diff_num")
local songPlateHeight = 172;
@ -167,35 +164,6 @@ local resolutionChange = function(x, y)
game.Log('resX:' .. resX .. ' // resY:' .. resY .. ' // fullX:' .. fullX .. ' // fullY:' .. fullY, game.LOGGER_ERROR);
end
function load_number_image(path)
local images = {}
for i = 0, 9 do
images[i + 1] = gfx.CreateSkinImage(string.format("%s/%d.png", path, i), 0)
end
return images
end
function draw_number(x, y, alpha, num, digits, images, is_dim, scale, kern)
scale = scale or 1;
kern = kern or 1;
local tw, th = gfx.ImageSize(images[1])
tw = tw * scale;
th = th * scale;
x = x + (tw * (digits - 1)) / 2
y = y - th / 2
for i = 1, digits do
local mul = 10 ^ (i - 1)
local digit = math.floor(num / mul) % 10
local a = alpha
if is_dim and num < mul then
a = 0.4
end
gfx.BeginPath()
gfx.ImageRect(x, y, tw, th, images[digit + 1], a, 0)
x = x - (tw * kern)
end
end
function getCorrectedIndex(from, offset)
total = #songwheel.songs;
@ -336,7 +304,7 @@ function drawSong(song, y)
-- Draw the difficulty level number
gfx.BeginPath()
draw_number(songX+30, y+125, 1.0, selectedSongDifficulty.level, 2, difficultyNumbers, false, 0.65, 1)
Numbers.draw_number(songX+30, y+125, 1.0, selectedSongDifficulty.level, 2, difficultyNumbers, false, 0.65, 1)
-- Draw song title
gfx.FontSize(24)
@ -406,7 +374,6 @@ function drawSongList()
gfx.GlobalAlpha(1);
end
local scoreNumbers = load_number_image("score_num");
function drawData() -- Draws the song data on the left panel
if isFilterWheelActive or transitionLeaveReappearTimer ~= 0 then return false end;
@ -435,8 +402,8 @@ function drawData() -- Draws the song data on the left panel
scoreNumber = bestScore.score
end
draw_number(100, 793, 1.0, math.floor(scoreNumber / 10000), 4, scoreNumbers, true, 0.3, 1.12)
draw_number(253, 798, 1.0, scoreNumber, 4, scoreNumbers, true, 0.22, 1.12)
Numbers.draw_number(100, 793, 1.0, math.floor(scoreNumber / 10000), 4, scoreNumbers, true, 0.3, 1.12)
Numbers.draw_number(253, 798, 1.0, scoreNumber, 4, scoreNumbers, true, 0.22, 1.12)
-- Draw grade
local gradeImage = gradeImages.none;
@ -499,7 +466,7 @@ function drawData() -- Draws the song data on the left panel
gfx.ImageRect(DIFF_X_START+(index-1)*DIFF_GAP-(163*0.8)/2, 1028, 163*0.8, 163*0.8, diffCursorImage, 1, 0)
end
draw_number(85+(index-1)*DIFF_GAP, 1085, 1.0, diff.level, 2, difficultyNumbers, false, 0.8, 1)
Numbers.draw_number(85+(index-1)*DIFF_GAP, 1085, 1.0, diff.level, 2, difficultyNumbers, false, 0.8, 1)
local diffLabelImage = difficultyLabelUnderImages[
GetDisplayDifficulty(diff.jacketPath, diff.difficulty)
@ -799,10 +766,6 @@ render = function (deltaTime)
common.stopMusic();
if not difficultyNumbers then
difficultyNumbers = load_number_image('diff_num')
end
-- detect resolution change
local resx, resy = game.GetResolution();
if resx ~= resX or resy ~= resY then

View File

@ -3,7 +3,7 @@ local common = require('common.common');
game.LoadSkinSample('song_transition_screen/transition_enter.wav');
local refBgImage = gfx.CreateSkinImage("songtransition/bg_old.png", 0)
local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY)
local bgImage = gfx.CreateSkinImage("songtransition/bg.png", 0)
local glowOverlayImage = gfx.CreateSkinImage("songtransition/glowy.png", 0)
@ -28,9 +28,18 @@ local difficultyLabelImages = {
local transitionTimer = 0;
local outTimer = 0
local resx, resy = game.GetResolution()
local desw, desh -- The resolution of the deisign
local scale;
-- Window variables
local resX, resY = game.GetResolution()
-- Aspect Ratios
local landscapeWidescreenRatio = 16 / 9
local landscapeStandardRatio = 4 / 3
local portraitWidescreenRatio = 9 / 16
-- Portrait sizes
local fullX, fullY
local desw = 1080
local desh = 1920
local noJacket = gfx.CreateSkinImage("song_select/loading.png", 0)
@ -38,11 +47,6 @@ local wasEnterSfxPlayed = false;
function resetLayoutInformation()
resx, resy = game.GetResolution()
-- portrait = resy > resx
-- desw = portrait and 1080 or 1920
-- desh = desw * (resy / resx)
desw = 1080
desh = 1920
scale = resx / desw
end
@ -85,12 +89,21 @@ function render(deltaTime)
difficultyNumbers = load_number_image('diff_num')
end
resetLayoutInformation()
gfx.ResetTransform();
gfx.Scale(scale, scale);
local x_offset = (resX - fullX) / 2
local y_offset = 0
gfx.BeginPath()
local bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
gfx.Rect(0, 0, resX, resY)
gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2))
gfx.Fill()
gfx.Translate(x_offset, y_offset);
gfx.Scale(fullX / 1080, fullY / 1920);
gfx.Scissor(0, 0, 1080, 1920);
render_screen(transitionTimer);
transitionTimer = transitionTimer + deltaTime * 0.2
transitionTimer = math.min(transitionTimer,1)
@ -193,7 +206,9 @@ end
function reset()
transitionTimer = 0
resx, resy = game.GetResolution()
resX, resY = game.GetResolution()
fullX = portraitWidescreenRatio * resY
fullY = resY
outTimer = 0
wasEnterSfxPlayed = false;
end

View File

@ -409,7 +409,7 @@ render = function(deltaTime)
end
gfx.BeginPath()
bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
local bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
gfx.Rect(0, 0, resX, resY)
gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2))
gfx.Fill()

View File

@ -4,7 +4,19 @@ local common = require('common.common');
local transitionEnterAnimation;
local transitionLeaveAnimation;
local resx, resy = game.GetResolution()
local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY)
-- Window variables
local resX, resY = game.GetResolution()
-- Aspect Ratios
local landscapeWidescreenRatio = 16 / 9
local landscapeStandardRatio = 4 / 3
local portraitWidescreenRatio = 9 / 16
-- Portrait sizes
local fullX = portraitWidescreenRatio * resY
local fullY = resY
local timer = 0;
local outTimer = 0;
@ -20,7 +32,20 @@ function loadAnimations()
transitionLeaveAnimation = gfx.LoadSkinAnimation('transition/transition_frames/leave', 1/60, 1, false);
end
function drawBackground()
gfx.BeginPath()
local bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
gfx.Rect(0, 0, resX, resY)
gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2))
gfx.Fill()
end
function render(deltaTime)
local x_offset = (resX - fullX) / 2
local y_offset = 0
gfx.BeginPath()
common.stopMusic();
if not transitionEnterAnimation then
@ -37,7 +62,7 @@ function render(deltaTime)
wasEnterSfxPlayed = true;
end
gfx.BeginPath();
gfx.ImageRect(0, 0, resx, resy, transitionEnterAnimation, 1, 0);
gfx.ImageRect(x_offset, y_offset, fullX, fullY, transitionEnterAnimation, 1, 0);
gfx.GlobalAlpha(1);
-- debug
@ -51,10 +76,14 @@ end
function render_out(deltaTime)
local leaveAnimeTickRes = gfx.TickAnimation(transitionLeaveAnimation, deltaTime);
local x_offset = (resX - fullX) / 2
local y_offset = 0
gfx.BeginPath()
if leaveAnimeTickRes == 0 then
gfx.BeginPath();
gfx.ImageRect(0, 0, resx, resy, transitionEnterAnimation, 1, 0);
gfx.ImageRect(x_offset, y_offset, fullX, fullY, transitionEnterAnimation, 1, 0);
else
if not wasLeaveSfxPlayed then
game.PlaySample('transition_screen/transition_leave.wav');
@ -62,7 +91,7 @@ function render_out(deltaTime)
end
gfx.BeginPath();
gfx.ImageRect(0, 0, resx, resy, transitionLeaveAnimation, 1, 0);
gfx.ImageRect(x_offset, y_offset, fullX, fullY, transitionLeaveAnimation, 1, 0);
outTimer = outTimer + (1/60) / 0.5
end
@ -79,7 +108,9 @@ end
function reset()
resx, resy = game.GetResolution();
resX, resY = game.GetResolution();
fullX = portraitWidescreenRatio * resY
fullY = resY
timer = 0;
outTimer = 0;