From 4d01d97f7d035ec6e55580119638ebf9eea89f81 Mon Sep 17 00:00:00 2001 From: telecomadm1145 <1587496147@qq.com> Date: Sun, 19 Nov 2023 09:35:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0flashlight,=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmania/GameBuffer.cpp | 2 -- cmania/TaikoRuleset.h | 63 +++++++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/cmania/GameBuffer.cpp b/cmania/GameBuffer.cpp index cb325c7..7325fba 100644 --- a/cmania/GameBuffer.cpp +++ b/cmania/GameBuffer.cpp @@ -140,7 +140,6 @@ void GameBuffer::Output() { void GameBuffer::DrawCircle(int x, int y, double sz, double width, double whratio, PixelData pd) { const auto aa = 4; sz /= 2; - whratio -= 0.5; double radius = sz / 2; double sr = Sqr(radius) * aa; int r2 = (int)(sz + 1) * aa; @@ -163,7 +162,6 @@ void GameBuffer::DrawCircle(int x, int y, double sz, double width, double whrati void GameBuffer::FillCircle(int x, int y, double sz, double whratio, PixelData pd, int) { sz /= 2; - whratio -= 0.5; const int aa = 4; double radius = sz / 2; double sr = Sqr(radius) * aa; diff --git a/cmania/TaikoRuleset.h b/cmania/TaikoRuleset.h index 0e17751..34102d9 100644 --- a/cmania/TaikoRuleset.h +++ b/cmania/TaikoRuleset.h @@ -347,20 +347,29 @@ class TaikoRuleset : public Ruleset { double CalcFlashlight(OsuMods mods, double ratio) { if (ratio > 1 && ratio < 0) return 1; - if (HasFlag(mods, OsuMods::Hidden)) { - if (ratio < 0.4) { - return pow(ratio / 0.4, 2); + auto hd = HasFlag(mods, OsuMods::Hidden); + auto fo = HasFlag(mods, OsuMods::FadeOut); + if (hd && fo) + { + if (ratio < 0.7) { + return pow(ratio / 0.7, 3); + } + if (ratio > 0.3) { + return pow((1 - ratio) / 0.7, 3); } } - if (HasFlag(mods, OsuMods::FadeOut)) { - if (ratio > 0.6) { - return pow((1 - ratio) / 0.4, 2); + if (hd) { + return pow(ratio, 4); + } + if (fo) { + if (ratio > 0.55) { + return pow((1 - ratio) / 0.45, 2); } } return 1; } virtual void Render(GameBuffer& buf) override { - const auto rt = 2.0; + const auto rt = 1.7; auto e_ms = Clock.Elapsed(); // now we need to render all objects. @@ -369,9 +378,8 @@ class TaikoRuleset : public Ruleset { auto hitpos = PointI{ (int)(20 * scale) + 5, buf.Height * 3 / 8 }; buf.FillRect(0, buf.Height / 4, buf.Width, buf.Height * 2 / 4, { {}, { 255, 40, 40, 40 }, ' ' }); - buf.DrawLineH(hitpos.X, buf.Height / 4, buf.Height * 2 / 4, { { 255, 255, 255, 255 }, {}, '|' }); for (size_t i = 0; i < 4; i++) { - buf.FillRect(hitpos.X - ((double)i - 1) * scale * 5 - scale * 10, buf.Height / 4, hitpos.X - (i)*scale * 5 - scale * 10, buf.Height * 2 / 4, { {}, {120,80,80,80}, ' ' }); + buf.FillRect(hitpos.X - ((double)i - 1) * scale * 5 - scale * 10, buf.Height / 4, hitpos.X - (i)*scale * 5 - scale * 10, buf.Height * 2 / 4, { {}, { 120, 80, 80, 80 }, ' ' }); KeyHighlight[i].Update(e_ms, [&](double v) { Color clr{ 220, 20, 212, 255 }; if ((i == 1) || (i == 2)) { @@ -386,25 +394,24 @@ class TaikoRuleset : public Ruleset { continue; auto off = obj.StartTime - e_ms; Color fill = { 220, 20, 212, 255 }; - unsigned int chr = 'O'; + Color outter = { 255, 255, 255, 255 }; double sz = scale * 6; if (HasFlag(obj.ObjectType, TaikoObject::Kat)) { fill = { 220, 255, 30, 30 }; - chr = 'X'; } if (HasFlag(obj.ObjectType, TaikoObject::SliderTick)) { fill = { 220, 255, 237, 77 }; - chr = '*'; } if (HasFlag(obj.ObjectType, TaikoObject::Large)) { sz = scale * 8; } - auto objx = (int)(hitpos.X + off / obj.Velocity / 1000 * (double)buf.Width); + auto v = off / obj.Velocity / 1000; + auto objx = (int)(hitpos.X + v * (double)buf.Width); if (objx > buf.Width || objx < 0) continue; + outter.Alpha = fill.Alpha = (unsigned char)(CalcFlashlight(Mods, 1 - v) * 255) * std::clamp((1 - v) * 3, 0.0, 1.0); buf.FillCircle(objx, hitpos.Y, sz, rt, { {}, fill, ' ' }); - buf.DrawCircle(objx, hitpos.Y, sz, 0.25, rt, { {}, { 255, 255, 255, 255 }, ' ' }); - buf.SetPixel(objx, hitpos.Y, { { 255, 0, 0, 0 }, {}, chr }); + buf.DrawCircle(objx, hitpos.Y, sz, 0.25, rt, { {}, outter, ' ' }); } LastHitResultAnimator.Update(e_ms, [&](double val) { @@ -414,7 +421,10 @@ class TaikoRuleset : public Ruleset { auto color = GetHitResultColor(LastHitResult); color.Alpha = (unsigned char)val; buf.DrawString(label, hitpos.X - label.size() / 2, buf.Height / 4 - 2, color, {}); + color.Alpha = (unsigned char)(pow(val / 255, 3) * 20); + buf.FillCircle(hitpos.X, hitpos.Y, scale * 8, rt, { {}, color, ' ' }); }); + buf.DrawLineH(hitpos.X, buf.Height / 4, buf.Height * 2 / 4, { { 255, 255, 255, 255 }, {}, '|' }); } // ͨ¹ý Ruleset ¼Ì³Ð @@ -459,21 +469,22 @@ class TaikoRuleset : public Ruleset { for (auto obj : Beatmap) { auto kat = HasFlag(obj.ObjectType, TaikoObject::Kat); auto large = HasFlag(obj.ObjectType, TaikoObject::Large); - if (large) { - InputEvent ie{}; - ie.Clock = obj.StartTime; - ie.Pressed = true; - ie.Action = kat ? (alt ? 1 : 2) : (alt ? 0 : 3); - record.Events.push_back(ie); - ie.Clock += 50; - ie.Pressed = false; - record.Events.push_back(ie); - alt = !alt; - } InputEvent ie{}; ie.Clock = obj.StartTime; ie.Pressed = true; ie.Action = kat ? (alt ? 1 : 2) : (alt ? 0 : 3); + if (large) { + alt = !alt; + InputEvent ie2{}; + ie2.Clock = obj.StartTime; + ie2.Pressed = true; + ie2.Action = kat ? (alt ? 1 : 2) : (alt ? 0 : 3); + record.Events.push_back(ie2); + ie2.Clock += 50; + ie2.Pressed = false; + record.Events.push_back(ie2); + alt = !alt; + } record.Events.push_back(ie); ie.Clock += 50; ie.Pressed = false;