FIx offset mistakes

selection
NaiJi ✨ 3 years ago
parent a4d7d26e98
commit e8d1724b45

@ -12,7 +12,7 @@ Application::Application() :
_font.loadFromFile("/usr/share/qtcreator/fonts/SourceCodePro-Regular.ttf"); _font.loadFromFile("/usr/share/qtcreator/fonts/SourceCodePro-Regular.ttf");
_grade.setFont(_font); _grade.setFont(_font);
_grade.setPosition(160, 160); _grade.setPosition(160, 160);
_grade.setFillColor(sf::Color(255, 0, 0, 0)); _grade.setFillColor(sf::Color(255, 0, 0));
_grade.setCharacterSize(35); _grade.setCharacterSize(35);
_grade.setString("NOT INIT"); _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) switch (rating)
{ {
case (NoteGrade::Rating::BAD): case (NoteGrade::Rating::BAD):
ret.setString("BAD"); text.setString("BAD");
ret.setFillColor(sf::Color(255, 255, 255, 255)); text.setFillColor(sf::Color(255, 255, 255, 255));
break; break;
case (NoteGrade::Rating::GREAT): case (NoteGrade::Rating::GREAT):
ret.setString("GREAT"); text.setString("GREAT");
ret.setFillColor(sf::Color(255, 255, 0, 255)); text.setFillColor(sf::Color(255, 255, 0, 255));
break; break;
case (NoteGrade::Rating::WRONG): case (NoteGrade::Rating::WRONG):
ret.setString("WRONG"); text.setString("WRONG");
ret.setFillColor(sf::Color(120, 120, 120, 255)); text.setFillColor(sf::Color(120, 120, 120, 255));
break; break;
case (NoteGrade::Rating::GOOD): case (NoteGrade::Rating::GOOD):
ret.setString("GOOD"); text.setString("GOOD");
ret.setFillColor(sf::Color(255, 100, 120, 255)); text.setFillColor(sf::Color(255, 100, 120, 255));
break; break;
} }
return ret;
} }
void Application::input() void Application::input()
@ -158,7 +155,8 @@ void Application::onTap(const Note::Arrow &arrow)
if (note) if (note)
{ {
const auto tap_result = note->onTap(arrow, music_offset); 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));
} }
} }

@ -25,8 +25,6 @@ private:
sf::Font _font; sf::Font _font;
sf::Text _grade; sf::Text _grade;
sf::Text _tap_time;
Timeline _timeline; Timeline _timeline;
DebugHelper _debug; DebugHelper _debug;

@ -1,10 +1,11 @@
#include "note.h" #include "note.h"
#include <iostream>
#include <cmath> #include <cmath>
Note::Note(microsec offset, microsec life_span_offset, Note::Arrow type) : Note::Note(microsec offset, microsec life_span_offset, Note::Arrow type) :
_offset(offset), // TODO: Move to struct NoteData _offset(offset),
_start_handling_offset(_offset + life_span_offset), // so Note::Note(NoteData&& data) : . . . _start_handling_offset(_offset - life_span_offset),
_end_handling_offset(_offset - life_span_offset), _end_handling_offset(_offset + life_span_offset),
_type(type) _type(type)
{} {}

@ -1,6 +1,8 @@
#include "timeline.h" #include "timeline.h"
#include "note.h" #include "note.h"
#include <iostream>
Timeline::Timeline() Timeline::Timeline()
{ {
// BPM of METEOR is 170. // BPM of METEOR is 170.
@ -11,14 +13,15 @@ Timeline::Timeline()
int amount_of_beats = 209; int amount_of_beats = 209;
microsec time_between_beats = 1412162; microsec time_between_beats = 1412162;
microsec note_input_offset = 412162; 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)); _timeline.emplace_back(new Note(interval, note_input_offset));
interval -= time_between_beats; interval += time_between_beats;
} }
_active_note = nullptr; _active_note = nullptr;
@ -56,12 +59,14 @@ void Timeline::checkForNextActiveNote(const microsec &microseconds)
{ {
if (!_active_note && (*_top_note)->isActive(microseconds)) if (!_active_note && (*_top_note)->isActive(microseconds))
{ {
std::cout << "New active note: " << microseconds << '\n';
_active_note = *_top_note; _active_note = *_top_note;
} }
} }
const Note* Timeline::fetchActiveNote(const microsec &microseconds) noexcept const Note* Timeline::fetchActiveNote(const microsec &microseconds) noexcept
{ {
std::cout << "Clicked at: " << microseconds << '\n';
update(microseconds); update(microseconds);
return _active_note; return _active_note;
} }

Loading…
Cancel
Save