FIx offset mistakes
This commit is contained in:
parent
a4d7d26e98
commit
e8d1724b45
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ private:
|
|||
sf::Font _font;
|
||||
sf::Text _grade;
|
||||
|
||||
sf::Text _tap_time;
|
||||
|
||||
Timeline _timeline;
|
||||
DebugHelper _debug;
|
||||
|
||||
|
|
7
note.cpp
7
note.cpp
|
@ -1,10 +1,11 @@
|
|||
#include "note.h"
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
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)
|
||||
{}
|
||||
|
||||
|
|
13
timeline.cpp
13
timeline.cpp
|
@ -1,6 +1,8 @@
|
|||
#include "timeline.h"
|
||||
#include "note.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue