From e8d1724b45e2b437a251d86ceaa8b46c38174807 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Thu, 8 Apr 2021 22:51:59 +0300 Subject: [PATCH] FIx offset mistakes --- application.cpp | 26 ++++++++++++-------------- application.h | 2 -- note.cpp | 7 ++++--- timeline.cpp | 13 +++++++++---- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/application.cpp b/application.cpp index dd9e45d..bf249b7 100644 --- a/application.cpp +++ b/application.cpp @@ -12,7 +12,7 @@ Application::Application() : _font.loadFromFile("/usr/share/qtcreator/fonts/SourceCodePro-Regular.ttf"); _grade.setFont(_font); _grade.setPosition(160, 160); - _grade.setFillColor(sf::Color(255, 0, 0, 0)); + _grade.setFillColor(sf::Color(255, 0, 0)); _grade.setCharacterSize(35); _grade.setString("NOT INIT"); } @@ -55,33 +55,30 @@ void Application::startGameLoop() } } -static sf::Text makeGradeString(const NoteGrade::Rating& rating) +static void makeGradeString(const NoteGrade::Rating& rating, sf::Text& text) { - sf::Text ret; switch (rating) { case (NoteGrade::Rating::BAD): - ret.setString("BAD"); - ret.setFillColor(sf::Color(255, 255, 255, 255)); + text.setString("BAD"); + text.setFillColor(sf::Color(255, 255, 255, 255)); break; case (NoteGrade::Rating::GREAT): - ret.setString("GREAT"); - ret.setFillColor(sf::Color(255, 255, 0, 255)); + text.setString("GREAT"); + text.setFillColor(sf::Color(255, 255, 0, 255)); break; case (NoteGrade::Rating::WRONG): - ret.setString("WRONG"); - ret.setFillColor(sf::Color(120, 120, 120, 255)); + text.setString("WRONG"); + text.setFillColor(sf::Color(120, 120, 120, 255)); break; case (NoteGrade::Rating::GOOD): - ret.setString("GOOD"); - ret.setFillColor(sf::Color(255, 100, 120, 255)); + text.setString("GOOD"); + text.setFillColor(sf::Color(255, 100, 120, 255)); break; } - - return ret; } void Application::input() @@ -158,7 +155,8 @@ void Application::onTap(const Note::Arrow &arrow) if (note) { const auto tap_result = note->onTap(arrow, music_offset); - _grade = makeGradeString(tap_result.rating); + makeGradeString(tap_result.rating, _grade); + _grade.setFillColor(sf::Color(255, 255, 255, 255)); } } diff --git a/application.h b/application.h index a8d2b4d..9e8b70d 100644 --- a/application.h +++ b/application.h @@ -25,8 +25,6 @@ private: sf::Font _font; sf::Text _grade; - sf::Text _tap_time; - Timeline _timeline; DebugHelper _debug; diff --git a/note.cpp b/note.cpp index cc59023..16e8df6 100644 --- a/note.cpp +++ b/note.cpp @@ -1,10 +1,11 @@ #include "note.h" +#include #include Note::Note(microsec offset, microsec life_span_offset, Note::Arrow type) : - _offset(offset), // TODO: Move to struct NoteData - _start_handling_offset(_offset + life_span_offset), // so Note::Note(NoteData&& data) : . . . - _end_handling_offset(_offset - life_span_offset), + _offset(offset), + _start_handling_offset(_offset - life_span_offset), + _end_handling_offset(_offset + life_span_offset), _type(type) {} diff --git a/timeline.cpp b/timeline.cpp index fd64ba1..c68eb49 100644 --- a/timeline.cpp +++ b/timeline.cpp @@ -1,6 +1,8 @@ #include "timeline.h" #include "note.h" +#include + Timeline::Timeline() { // BPM of METEOR is 170. @@ -11,14 +13,15 @@ Timeline::Timeline() int amount_of_beats = 209; microsec time_between_beats = 1412162; microsec note_input_offset = 412162; - microsec interval = starting_beat_offset + (time_between_beats * amount_of_beats); + microsec interval = starting_beat_offset; + microsec AAAAAAAAENDBLYAT = starting_beat_offset + (time_between_beats * amount_of_beats); - Note::resetPrecisionQualifier(note_input_offset / 2); + Note::resetPrecisionQualifier(note_input_offset / 3); - while (interval > 0) + while (interval < AAAAAAAAENDBLYAT) { _timeline.emplace_back(new Note(interval, note_input_offset)); - interval -= time_between_beats; + interval += time_between_beats; } _active_note = nullptr; @@ -56,12 +59,14 @@ void Timeline::checkForNextActiveNote(const microsec µseconds) { if (!_active_note && (*_top_note)->isActive(microseconds)) { + std::cout << "New active note: " << microseconds << '\n'; _active_note = *_top_note; } } const Note* Timeline::fetchActiveNote(const microsec µseconds) noexcept { + std::cout << "Clicked at: " << microseconds << '\n'; update(microseconds); return _active_note; }