Commit cdf17e99 authored by Kevin Balz's avatar Kevin Balz

Merge branch 'feature/29-indicate-end-of-song-near' into 'develop'

Resolve "Indicate end of song near"

Closes #29

See merge request !17
parents 13e5455c d2de1098
Pipeline #3316 passed with stage
in 2 minutes and 51 seconds
......@@ -35,14 +35,14 @@ namespace phase_shifter::gameplay {
{
_acc += dt.value();
int size = static_cast<int>(_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<Lose_msg>();
}
}
......
......@@ -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<int>(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<int>(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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment