Commit 13e5455c authored by Kevin Balz's avatar Kevin Balz
Browse files

fix beat decrease

parent 4c5fe467
Pipeline #3314 passed with stage
in 8 minutes and 1 second
......@@ -26,6 +26,7 @@ namespace phase_shifter::gameplay {
i++;
}
_state.beats_left = static_cast<int>(_time_stamps.size());
_state.avg_beat_time =
static_cast<float>(_time_stamps[_time_stamps.size() - 1]) / _time_stamps.size();
}
......@@ -35,11 +36,13 @@ 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];
int beats_left = _state.beats_left;
if(beat) {
_beat_index++;
LOG(plog::debug) << "beat";
if(_beat_index + 1 >= size) {
beats_left = size - 1 - _beat_index - _beat_offset;
if(beats_left <= 0) {
_bus.send<Lose_msg>();
}
}
......@@ -48,7 +51,7 @@ namespace phase_shifter::gameplay {
_beat_index >= 0 ? _acc - _time_stamps[_beat_index] : _acc,
_beat_index + 1 < size ? _time_stamps[_beat_index + 1] - _acc : 999,
_state.avg_beat_time,
size - 1 - _beat_index};
beats_left};
}
auto Beat_system::graphic_time_scale() const -> float
......@@ -67,6 +70,7 @@ namespace phase_shifter::gameplay {
void Beat_system::decrease_beats_left(int count)
{
_beat_offset -= count;
if(_state.beats_left > 0) {
_state.beats_left -= count;
......
......@@ -39,6 +39,7 @@ namespace phase_shifter::gameplay {
float _acc = 0.f;
std::vector<float> _time_stamps;
int _beat_index = -1;
int _beat_offset = 0;
};
} // namespace phase_shifter::gameplay
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