Skip to content

Commit

Permalink
更新flashlight,修改部分样式
Browse files Browse the repository at this point in the history
  • Loading branch information
telecomadm1145 committed Nov 19, 2023
1 parent 8a655bc commit 4d01d97
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
2 changes: 0 additions & 2 deletions cmania/GameBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
63 changes: 37 additions & 26 deletions cmania/TaikoRuleset.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,29 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
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.
Expand All @@ -369,9 +378,8 @@ class TaikoRuleset : public Ruleset<TaikoObject> {

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)) {
Expand All @@ -386,25 +394,24 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
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) {
Expand All @@ -414,7 +421,10 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
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 继承
Expand Down Expand Up @@ -459,21 +469,22 @@ class TaikoRuleset : public Ruleset<TaikoObject> {
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;
Expand Down

0 comments on commit 4d01d97

Please sign in to comment.