|
|
@ -11,20 +11,20 @@ ClassicTimeline::ClassicTimeline()
|
|
|
|
// Length is 1:14
|
|
|
|
// Length is 1:14
|
|
|
|
// I calculated that the time between beats is about 1412162 microseconds
|
|
|
|
// I calculated that the time between beats is about 1412162 microseconds
|
|
|
|
|
|
|
|
|
|
|
|
std::string song_filename = "/home/naiji/METEOR.flac";
|
|
|
|
std::string song_filename = "METEOR.flac";
|
|
|
|
|
|
|
|
|
|
|
|
_music.openFromFile(song_filename);
|
|
|
|
_music.openFromFile(song_filename);
|
|
|
|
_music.setVolume(10);
|
|
|
|
_music.setVolume(10);
|
|
|
|
|
|
|
|
|
|
|
|
_timeline.reserve(1000);
|
|
|
|
_timeline.reserve(1000);
|
|
|
|
|
|
|
|
|
|
|
|
microsec starting_beat_offset = 372162;
|
|
|
|
microsec starting_beat_offset = 352162;
|
|
|
|
int amount_of_beats = 209;
|
|
|
|
int amount_of_beats = 209;
|
|
|
|
microsec interval = 1412162;
|
|
|
|
microsec interval = 1412162;
|
|
|
|
microsec note_input_offset = 412162;
|
|
|
|
microsec note_input_offset = 412162;
|
|
|
|
microsec bpm_iterator = starting_beat_offset;
|
|
|
|
microsec bpm_iterator = starting_beat_offset;
|
|
|
|
microsec bpm_end = starting_beat_offset + (interval * amount_of_beats);
|
|
|
|
microsec bpm_end = starting_beat_offset + (interval * amount_of_beats);
|
|
|
|
_visibility_offset = note_input_offset * 6;
|
|
|
|
_visibility_offset = note_input_offset * 8;
|
|
|
|
|
|
|
|
|
|
|
|
_timeline.emplace_back(new ClassicNote({note_input_offset}, bpm_iterator, Action::PRESS_DOWN, {90, 90}));
|
|
|
|
_timeline.emplace_back(new ClassicNote({note_input_offset}, bpm_iterator, Action::PRESS_DOWN, {90, 90}));
|
|
|
|
bpm_iterator += interval;
|
|
|
|
bpm_iterator += interval;
|
|
|
@ -35,10 +35,13 @@ ClassicTimeline::ClassicTimeline()
|
|
|
|
_timeline.emplace_back(new ClassicNote({note_input_offset}, bpm_iterator, Action::PRESS_LEFT, {290, 90}));
|
|
|
|
_timeline.emplace_back(new ClassicNote({note_input_offset}, bpm_iterator, Action::PRESS_LEFT, {290, 90}));
|
|
|
|
bpm_iterator += interval;
|
|
|
|
bpm_iterator += interval;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float x = 90.;
|
|
|
|
|
|
|
|
|
|
|
|
while (bpm_iterator < bpm_end)
|
|
|
|
while (bpm_iterator < bpm_end)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_timeline.emplace_back(new ClassicNote({note_input_offset}, bpm_iterator, Action::PRESS_UP, {390, 390}));
|
|
|
|
_timeline.emplace_back(new ClassicNote({note_input_offset}, bpm_iterator, Action::PRESS_UP, {x, 390.}));
|
|
|
|
bpm_iterator += interval;
|
|
|
|
bpm_iterator += interval;
|
|
|
|
|
|
|
|
x += 70;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
expire(_last_visible_note);
|
|
|
|
expire(_last_visible_note);
|
|
|
@ -46,7 +49,7 @@ ClassicTimeline::ClassicTimeline()
|
|
|
|
_top_note = _timeline.begin();
|
|
|
|
_top_note = _timeline.begin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicTimeline::init()
|
|
|
|
void ClassicTimeline::run()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_music.play();
|
|
|
|
_music.play();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -113,7 +116,7 @@ microsec ClassicTimeline::currentMusicOffset() const
|
|
|
|
return _music.getPlayingOffset().asMicroseconds();
|
|
|
|
return _music.getPlayingOffset().asMicroseconds();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicTimeline::discardExpiredNotes(const std::unique_ptr<ClassicViewManager> &view_manager, const microsec &music_offset)
|
|
|
|
void ClassicTimeline::discardExpiredNotes(const std::unique_ptr<ClassicViewManager> &view_manager)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_top_note == _timeline.begin())
|
|
|
|
if (_top_note == _timeline.begin())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -137,15 +140,25 @@ bool ClassicTimeline::isVisiblyClose(const Iterator &iterator, const microsec &m
|
|
|
|
|
|
|
|
|
|
|
|
void ClassicTimeline::fetchVisibleNotes(const std::unique_ptr<ClassicViewManager>& view_manager)
|
|
|
|
void ClassicTimeline::fetchVisibleNotes(const std::unique_ptr<ClassicViewManager>& view_manager)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
microsec music_offset = currentMusicOffset();
|
|
|
|
const microsec music_offset = currentMusicOffset();
|
|
|
|
discardExpiredNotes(view_manager, music_offset);
|
|
|
|
discardExpiredNotes(view_manager);
|
|
|
|
|
|
|
|
|
|
|
|
Iterator note_iterator = _top_note;
|
|
|
|
Iterator note_iterator = _top_note;
|
|
|
|
while (isVisiblyClose(note_iterator, music_offset))
|
|
|
|
while (isVisiblyClose(note_iterator, music_offset))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ClassicNote* note = *note_iterator;
|
|
|
|
ClassicNote* note = *note_iterator;
|
|
|
|
if (!note->sprite())
|
|
|
|
if (!note->sprite())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
note->saveAppearanceTime(music_offset);
|
|
|
|
view_manager->initNoteSprite(note);
|
|
|
|
view_manager->initNoteSprite(note);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (note->state() == ClassicNote::State::DEAD)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
view_manager->resetNoteSprite(note);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
note->update(music_offset);
|
|
|
|
|
|
|
|
|
|
|
|
++note_iterator;
|
|
|
|
++note_iterator;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -157,13 +170,15 @@ void ClassicTimeline::drawVisibleNotes(sf::RenderWindow &window) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool no_visible_notes = isExpired(_last_visible_note)
|
|
|
|
bool no_visible_notes = isExpired(_last_visible_note)
|
|
|
|
|| _top_note > _last_visible_note;
|
|
|
|
|| _top_note > _last_visible_note;
|
|
|
|
|
|
|
|
|
|
|
|
if (no_visible_notes)
|
|
|
|
if (no_visible_notes)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
Iterator note_to_draw = _top_note;
|
|
|
|
Iterator note_to_draw = _top_note;
|
|
|
|
while (note_to_draw != (_last_visible_note))
|
|
|
|
while (note_to_draw != (_last_visible_note))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
window.draw(*(*note_to_draw));
|
|
|
|
if ((*note_to_draw)->sprite())
|
|
|
|
|
|
|
|
window.draw(*(*note_to_draw));
|
|
|
|
++note_to_draw;
|
|
|
|
++note_to_draw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|