bool ScreenEvaluation::Run(double Delta) { WindowFrame.SetLightMultiplier(sin(GetScreenTime()) * 0.2 + 1); Background.Render(); if (Font) { Font->Render(ResultsString, Vec2( ScreenWidth/2 - 110, ScreenHeight/2 - 100 )); Font->Render(ResultsNumerical, Vec2( ScreenWidth/2, ScreenHeight/2 - 100 )); Font->Render(String("results screen"), Vec2( ScreenWidth/2 - 70, 0 )); Font->Render(String("press space to continue..."), Vec2( ScreenWidth/2 - 130, ScreenHeight*7/8 )); Font->Render(TitleFormat, Vec2( 0, ScreenHeight - 20 )); } return Running; }
bool ScreenGameplay::Run(double Delta) { if (Next) return RunNested(Delta); if (!DoPlay) return false; if (ForceActivation) { Activate(); ForceActivation = false; } if (Active) { Time.Game += Delta; Time.Miss -= Delta; Time.Failure -= Delta; Time.Success -= Delta; if (Time.Game >= Time.Waiting) { UpdateSongTime(Delta); // PlayerContext::Update(Time.Stream) CheckShouldEndScreen(); } else { Time.InterpolatedStream = -(Time.Waiting - Time.Game); Time.Stream = Time.InterpolatedStream; } } RunAutoEvents(); for (auto &p : Players) p->Update(Time.InterpolatedStream); Animations->UpdateTargets(Delta); BGA->Update(Delta); Render(); if (Delta > 0.1) Log::Logf("ScreenGameplay7K: Delay@[ST%.03f/RST:%.03f] = %f\n", GetScreenTime(), Time.Game, Delta); return Running; }
void ScreenGameplay::RenderObjects(float TimeDelta, bool drawPlayable) { Vec2 mpos = WindowFrame.GetRelativeMPos(); Cursor.SetPosition(mpos); Cursor.AddRotation(CursorRotospeed * TimeDelta); int Beat = MeasureRatio * MySong->MeasureLength; float Fraction = (float(MeasureRatio * MySong->MeasureLength) - Beat); Lifebar.SetScaleX(1.0 - 0.05 * Fraction); // Rendering ahead. if (IsPaused) { Background.Blue = Background.Red = Background.Green = 0.5; } else Background.Blue = Background.Red = Background.Green = 1; Background.Render(); MarkerA.Render(); MarkerB.Render(); if (!EditMode) Lifebar.Render(); if (drawPlayable) { DrawVector(NotesHeld, TimeDelta); DrawVector(AnimateOnly, TimeDelta); if (Measure > 0) { if (NotesInMeasure.size() && // there are measures and Measure - 1 < NotesInMeasure.size() && // the measure is within the range and NotesInMeasure.at(Measure - 1).size() > 0) // there are notes in this measure { DrawVector(NotesInMeasure[Measure - 1], TimeDelta); } } // Render current measure on front of the next! if (Measure + 1 < CurrentDiff->Measures.size()) { if (NotesInMeasure.size() > Measure + 1 && NotesInMeasure.at(Measure + 1).size() > 0) { DrawVector(NotesInMeasure[Measure + 1], TimeDelta); } } if (Measure < CurrentDiff->Measures.size()) { if (NotesInMeasure.size() > Measure && NotesInMeasure.at(Measure).size() > 0) { DrawVector(NotesInMeasure[Measure], TimeDelta); } } } Barline.Render(); if (!EditMode) aJudgment.Render(); // Combo rendering. std::stringstream str; str << Combo; float textX = GetScreenOffset(0.5).x - (str.str().length() * ComboSizeX / 2); MyFont.Render(str.str(), Vec2(textX, 0)); std::stringstream str2; str2 << int32_t(1000000.0 * Evaluation.dpScoreSquare / (Evaluation.totalNotes * (Evaluation.totalNotes + 1))); textX = GetScreenOffset(0.5).x - (str2.str().length() * ComboSizeX / 2); MyFont.Render(str2.str(), Vec2(textX, 720)); /* Lengthy information printing code goes here.*/ std::stringstream info; if (IsAutoplaying) info << "Autoplay"; #ifndef NDEBUG info << "\nSongTime: " << SongTime << "\nPlaybackTime: "; if (Music) info << Music->GetPlayedTime(); else info << "???"; /*info << "\nStreamTime: "; if(Music) info << Music->GetStreamedTime(); else info << "???"; */ info << "\naudioFactor: " << MixerGetFactor(); info << "\nSongDelta: " << SongDelta; info << "\nDevice Latency: " << (int)(MixerGetLatency() * 1000); /* if (Music) info << Music->GetStreamedTime() - Music->GetPlaybackTime(); else info << "???"; */ info << "\nScreenTime: " << GetScreenTime(); info << "\nMeasureRatio: " << MeasureRatio; info << "\nMeasureRatioPerSecond: " << RatioPerSecond; #endif if (TappingMode) info << "\nTapping mode"; if (!FailEnabled) info << "\nFailing Disabled"; #ifdef NDEBUG if (EditMode) #endif info << "\nMeasure: " << Measure; SongInfo.Render(info.str(), Vec2(0, 0)); ReadySign.Render(); Cursor.Render(); }
/* TODO: Use measure ratios instead of song time for the barline. */ bool ScreenGameplay::Run(double TimeDelta) { if (Music && LeadInTime <= 0) { SongDelta = Music->GetStreamedTime() - SongTime; SongTime += SongDelta; } float ScreenTime = Screen::GetScreenTime(); if (ScreenTime > ScreenPauseTime || !ShouldChangeScreenAtEnd) // we're over the pause? { if (SongTime <= 0) { if (LeadInTime > 0) { LeadInTime -= TimeDelta; SongTime = -LeadInTime; } else startMusic(); } if (Next) // We have a pending screen? return RunNested(TimeDelta); // use that instead. RunMeasure(SongDelta); if (LeadInTime) Barline.Run(TimeDelta, MeasureRatio); else Barline.Run(SongDelta, MeasureRatio); if (SongTime > CurrentDiff->Offset) { while (BarlineRatios.size() && BarlineRatios.at(0).Time <= SongTime) { RatioPerSecond = BarlineRatios.front().Value; BarlineRatios.erase(BarlineRatios.begin()); } MeasureRatio += RatioPerSecond * SongDelta; if (SongDelta == 0 && !IsPaused) { if ((!Music || !Music->IsPlaying())) MeasureRatio += RatioPerSecond * TimeDelta; } if (MeasureRatio > 1.0f) { MeasureRatio -= 1.0f; Measure += 1; } Lifebar.Run(SongDelta); aJudgment.Run(TimeDelta); } } if (ShouldChangeScreenAtEnd) { float TotalTime = (CurrentDiff->Offset + MySong->LeadInTime + ScreenPauseTime); float X = GetScreenTime() / TotalTime; float xPos; if (X < 0.5) xPos = ((-2)*X*X + 2 * X) * ScreenWidth; else xPos = ScreenWidth - ((-2)*X*X + 2 * X) * ScreenWidth; ReadySign.SetPosition(xPos, ScreenHeight / 2); ReadySign.Alpha = 2 * ((-2)*X*X + 2 * X); // Lights float LightProgress = GetScreenTime() / 1.5; if (LightProgress <= 1) WindowFrame.SetLightMultiplier(LightProgress * 1.2); } else ReadySign.Alpha = 0; RenderObjects(TimeDelta); if (ShouldChangeScreenAtEnd && Measure >= CurrentDiff->Measures.size()) { auto Eval = std::make_shared<ScreenEvaluation>(); Eval->Init(Evaluation, MySong->SongAuthor, MySong->SongName); Next = Eval; Music->Stop(); } // You died? Not editing? Failing is enabled? if (Lifebar.Health <= 0 && !EditMode && FailEnabled) Running = false; // It's over. return Running; }