diff --git a/scripts/gameplay.lua b/scripts/gameplay.lua index 68b8143..8bce058 100644 --- a/scripts/gameplay.lua +++ b/scripts/gameplay.lua @@ -5,11 +5,14 @@ local Banner = require('gameplay.banner') local CritLine = require('gameplay.crit_line') local Console = require('gameplay.console') local Gauge = require('gameplay.gauge') +local Chain = require('gameplay.chain') local resx, resy = game.GetResolution() local desw, desh; local scale; +local chain = 0; + function resetLayoutInformation() resx, resy = game.GetResolution() desw = 1080 @@ -28,6 +31,7 @@ function render(deltaTime) gameplay.gauge.value, (game.GetSkinSetting('_gaugeARS') == 1) ); + Chain.render(deltaTime, chain, gameplay.critLine.x, gameplay.critLine.y); end function render_crit_base(deltaTime) @@ -52,7 +56,7 @@ function update_score(newScore) end function update_combo(newCombo) - + chain = newCombo end function near_hit(wasLate) diff --git a/scripts/gameplay/chain.lua b/scripts/gameplay/chain.lua new file mode 100644 index 0000000..3ba9db6 --- /dev/null +++ b/scripts/gameplay/chain.lua @@ -0,0 +1,96 @@ + + +local desw = 1080; +local desh = 1920; + +local transitionShakeScale = 0; +local transitionShakePosOffset = 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 chainNumbers = load_number_image('gameplay/chain/reg') + +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 tickTransitions = function (deltaTime) + + if transitionShakeScale < 1 then + transitionShakeScale = transitionShakeScale + deltaTime / 0.075 -- transition should last for that time in seconds + else + transitionShakeScale = 0 + end + + if (transitionShakeScale < 0.33) then + transitionShakePosOffset = 0; + elseif (transitionShakeScale > 0.66) then + transitionShakePosOffset = -1; + else + transitionShakePosOffset = 1; + end +end + +local render = function (deltaTime, combo, critLineCenterX, critLineCenterY) + tickTransitions(deltaTime) + + if combo == 0 then return end + + -- comboTimer = comboTimer + deltaTime + + local posx = desw / 2 + transitionShakePosOffset; + local posy = desh - 650 + transitionShakePosOffset; + + -- if portrait then posy = desh * critLinePos[2] - 150 end + + -- if gameplay.comboState == 2 then + -- comboCurrent = comboPUC --puc + -- elseif gameplay.comboState == 1 then + -- comboCurrent = comboUC --uc + -- else + -- comboCurrent = comboREG --regular + -- end + + -- local alpha = math.floor(comboTimer * 20) % 2 + -- alpha = (alpha * 100 + 155) / 255 + local alpha = 1 + + -- \_ chain _/ + local tw, th + -- tw, th = gfx.ImageSize(comboBottom) + -- gfx.BeginPath() + -- gfx.ImageRect(posx - tw / 2 + 10, posy - th / 4 - 210, tw * 0.85, th * 0.85, comboBottom, alpha, 0) + + tw, th = gfx.ImageSize(chainNumbers[1]) + 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) +end + +return { + render=render +} \ No newline at end of file diff --git a/textures/chain/uc3/0.png b/textures/chain/uc3/0.png deleted file mode 100644 index 0fb237c..0000000 Binary files a/textures/chain/uc3/0.png and /dev/null differ diff --git a/textures/chain/uc3/1.png b/textures/chain/uc3/1.png deleted file mode 100644 index ad0aa0b..0000000 Binary files a/textures/chain/uc3/1.png and /dev/null differ diff --git a/textures/chain/uc3/2.png b/textures/chain/uc3/2.png deleted file mode 100644 index 6b5dd09..0000000 Binary files a/textures/chain/uc3/2.png and /dev/null differ diff --git a/textures/chain/uc3/3.png b/textures/chain/uc3/3.png deleted file mode 100644 index ffe2af4..0000000 Binary files a/textures/chain/uc3/3.png and /dev/null differ diff --git a/textures/chain/uc3/4.png b/textures/chain/uc3/4.png deleted file mode 100644 index 51009fd..0000000 Binary files a/textures/chain/uc3/4.png and /dev/null differ diff --git a/textures/chain/uc3/5.png b/textures/chain/uc3/5.png deleted file mode 100644 index 425503d..0000000 Binary files a/textures/chain/uc3/5.png and /dev/null differ diff --git a/textures/chain/uc3/6.png b/textures/chain/uc3/6.png deleted file mode 100644 index 09e76b3..0000000 Binary files a/textures/chain/uc3/6.png and /dev/null differ diff --git a/textures/chain/uc3/7.png b/textures/chain/uc3/7.png deleted file mode 100644 index 6b3dbae..0000000 Binary files a/textures/chain/uc3/7.png and /dev/null differ diff --git a/textures/chain/uc3/8.png b/textures/chain/uc3/8.png deleted file mode 100644 index 201c525..0000000 Binary files a/textures/chain/uc3/8.png and /dev/null differ diff --git a/textures/chain/uc3/9.png b/textures/chain/uc3/9.png deleted file mode 100644 index 0c0925a..0000000 Binary files a/textures/chain/uc3/9.png and /dev/null differ diff --git a/textures/chain/chain.png b/textures/gameplay/chain/label.png similarity index 100% rename from textures/chain/chain.png rename to textures/gameplay/chain/label.png diff --git a/textures/chain/puc/0.png b/textures/gameplay/chain/puc/0.png similarity index 100% rename from textures/chain/puc/0.png rename to textures/gameplay/chain/puc/0.png diff --git a/textures/chain/puc/1.png b/textures/gameplay/chain/puc/1.png similarity index 100% rename from textures/chain/puc/1.png rename to textures/gameplay/chain/puc/1.png diff --git a/textures/chain/puc/2.png b/textures/gameplay/chain/puc/2.png similarity index 100% rename from textures/chain/puc/2.png rename to textures/gameplay/chain/puc/2.png diff --git a/textures/chain/puc/3.png b/textures/gameplay/chain/puc/3.png similarity index 100% rename from textures/chain/puc/3.png rename to textures/gameplay/chain/puc/3.png diff --git a/textures/chain/puc/4.png b/textures/gameplay/chain/puc/4.png similarity index 100% rename from textures/chain/puc/4.png rename to textures/gameplay/chain/puc/4.png diff --git a/textures/chain/puc/5.png b/textures/gameplay/chain/puc/5.png similarity index 100% rename from textures/chain/puc/5.png rename to textures/gameplay/chain/puc/5.png diff --git a/textures/chain/puc/6.png b/textures/gameplay/chain/puc/6.png similarity index 100% rename from textures/chain/puc/6.png rename to textures/gameplay/chain/puc/6.png diff --git a/textures/chain/puc/7.png b/textures/gameplay/chain/puc/7.png similarity index 100% rename from textures/chain/puc/7.png rename to textures/gameplay/chain/puc/7.png diff --git a/textures/chain/puc/8.png b/textures/gameplay/chain/puc/8.png similarity index 100% rename from textures/chain/puc/8.png rename to textures/gameplay/chain/puc/8.png diff --git a/textures/chain/puc/9.png b/textures/gameplay/chain/puc/9.png similarity index 100% rename from textures/chain/puc/9.png rename to textures/gameplay/chain/puc/9.png diff --git a/textures/chain/reg/0.png b/textures/gameplay/chain/reg/0.png similarity index 100% rename from textures/chain/reg/0.png rename to textures/gameplay/chain/reg/0.png diff --git a/textures/chain/reg/1.png b/textures/gameplay/chain/reg/1.png similarity index 100% rename from textures/chain/reg/1.png rename to textures/gameplay/chain/reg/1.png diff --git a/textures/chain/reg/2.png b/textures/gameplay/chain/reg/2.png similarity index 100% rename from textures/chain/reg/2.png rename to textures/gameplay/chain/reg/2.png diff --git a/textures/chain/reg/3.png b/textures/gameplay/chain/reg/3.png similarity index 100% rename from textures/chain/reg/3.png rename to textures/gameplay/chain/reg/3.png diff --git a/textures/chain/reg/4.png b/textures/gameplay/chain/reg/4.png similarity index 100% rename from textures/chain/reg/4.png rename to textures/gameplay/chain/reg/4.png diff --git a/textures/chain/reg/5.png b/textures/gameplay/chain/reg/5.png similarity index 100% rename from textures/chain/reg/5.png rename to textures/gameplay/chain/reg/5.png diff --git a/textures/chain/reg/6.png b/textures/gameplay/chain/reg/6.png similarity index 100% rename from textures/chain/reg/6.png rename to textures/gameplay/chain/reg/6.png diff --git a/textures/chain/reg/7.png b/textures/gameplay/chain/reg/7.png similarity index 100% rename from textures/chain/reg/7.png rename to textures/gameplay/chain/reg/7.png diff --git a/textures/chain/reg/8.png b/textures/gameplay/chain/reg/8.png similarity index 100% rename from textures/chain/reg/8.png rename to textures/gameplay/chain/reg/8.png diff --git a/textures/chain/reg/9.png b/textures/gameplay/chain/reg/9.png similarity index 100% rename from textures/chain/reg/9.png rename to textures/gameplay/chain/reg/9.png diff --git a/textures/chain/uc/0.png b/textures/gameplay/chain/uc/0.png similarity index 100% rename from textures/chain/uc/0.png rename to textures/gameplay/chain/uc/0.png diff --git a/textures/chain/uc/1.png b/textures/gameplay/chain/uc/1.png similarity index 100% rename from textures/chain/uc/1.png rename to textures/gameplay/chain/uc/1.png diff --git a/textures/chain/uc/2.png b/textures/gameplay/chain/uc/2.png similarity index 100% rename from textures/chain/uc/2.png rename to textures/gameplay/chain/uc/2.png diff --git a/textures/chain/uc/3.png b/textures/gameplay/chain/uc/3.png similarity index 100% rename from textures/chain/uc/3.png rename to textures/gameplay/chain/uc/3.png diff --git a/textures/chain/uc/4.png b/textures/gameplay/chain/uc/4.png similarity index 100% rename from textures/chain/uc/4.png rename to textures/gameplay/chain/uc/4.png diff --git a/textures/chain/uc/5.png b/textures/gameplay/chain/uc/5.png similarity index 100% rename from textures/chain/uc/5.png rename to textures/gameplay/chain/uc/5.png diff --git a/textures/chain/uc/6.png b/textures/gameplay/chain/uc/6.png similarity index 100% rename from textures/chain/uc/6.png rename to textures/gameplay/chain/uc/6.png diff --git a/textures/chain/uc/7.png b/textures/gameplay/chain/uc/7.png similarity index 100% rename from textures/chain/uc/7.png rename to textures/gameplay/chain/uc/7.png diff --git a/textures/chain/uc/8.png b/textures/gameplay/chain/uc/8.png similarity index 100% rename from textures/chain/uc/8.png rename to textures/gameplay/chain/uc/8.png diff --git a/textures/chain/uc/9.png b/textures/gameplay/chain/uc/9.png similarity index 100% rename from textures/chain/uc/9.png rename to textures/gameplay/chain/uc/9.png