From d2de109812149e0e03d1c9f03f122143e69e6ad7 Mon Sep 17 00:00:00 2001 From: Kevin Balz Date: Fri, 20 Sep 2019 10:27:53 +0200 Subject: [PATCH] Proper end of song --- src/gameplay/beat_system.cpp | 4 ++-- src/ui/hud_system.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gameplay/beat_system.cpp b/src/gameplay/beat_system.cpp index 1c98750..5d8da05 100644 --- a/src/gameplay/beat_system.cpp +++ b/src/gameplay/beat_system.cpp @@ -35,14 +35,14 @@ namespace phase_shifter::gameplay { { _acc += dt.value(); int size = static_cast(_time_stamps.size()); - auto beat = _beat_index + 1 < size && _acc >= _time_stamps[_beat_index + 1]; + auto beat = _beat_index + 1< size && _acc >= _time_stamps[_beat_index + 1]; int beats_left = _state.beats_left; if(beat) { _beat_index++; LOG(plog::debug) << "beat"; beats_left = size - 1 - _beat_index - _beat_offset; - if(beats_left <= 0) { + if(beats_left <= 0 || _beat_index + 1 >= size) { _bus.send(); } } diff --git a/src/ui/hud_system.cpp b/src/ui/hud_system.cpp index b38ec01..169626d 100644 --- a/src/ui/hud_system.cpp +++ b/src/ui/hud_system.cpp @@ -70,15 +70,17 @@ namespace phase_shifter::ui { //auto beats = std::clamp(beat_state.beats_left, 0, 5); ImGui::BeginChild("Line", {viewport.z, bar_height}, true); ImDrawList* drawList = ImGui::GetWindowDrawList(); + while (beat_index < static_cast(beats.size())) { auto x_offset = (beats[beat_index] - _passed) * bar_speed; auto height = beat_bar_height * (1.f - glm::smoothstep(0.f, beat_bar_length, x_offset)); + auto bar_color = beat_index < static_cast(beats.size() * 0.8f) ? 0xFFFFFFFF : 0xFF0000FF; ImVec2 p(cursor.x + viewport.z / 2 - x_offset, cursor.y - height / 2.f); - drawList->AddLine(p, {p.x, p.y + height}, 0xFFFFFFFF, 1); + drawList->AddLine(p, {p.x, p.y + height}, bar_color, 1); p.x = cursor.x + viewport.z / 2 + x_offset; - drawList->AddLine(p, {p.x, p.y + height}, 0xFFFFFFFF, 1); + drawList->AddLine(p, {p.x, p.y + height}, bar_color, 1); if(x_offset > beat_bar_length + 50) { break; -- GitLab