project-kyoku/note.h

64 lines
1.2 KiB
C++

#ifndef NOTE_H
#define NOTE_H
#include <SFML/System/Clock.hpp>
#include <SFML/System/Vector2.hpp>
////////////////////////////////
using microsec = sf::Int64;
using coordinates = sf::Vector2i;
struct NoteGrade
{
int score;
enum class Rating
{
WRONG,
BAD,
GOOD,
GREAT
} rating;
NoteGrade(int s, Rating r) : score(s), rating(r) {}
};
////////////////////////////////
class Note
{
public:
enum class Arrow
{
UP,
RIGHT,
DOWN,
LEFT,
NONE
};
Note(microsec offset, microsec life_span_offset, Note::Arrow type = Note::Arrow::UP);
void setPosition(coordinates position);
coordinates position() const noexcept;
microsec offset() const noexcept;
NoteGrade onTap(Arrow arrow_type, microsec tap_time_stamp) const;
bool isActive(microsec music_play_offset) const noexcept;
static void resetPrecisionQualifier(microsec qualifier = 500000);
private:
coordinates _position;
microsec _offset;
microsec _start_handling_offset;
microsec _end_handling_offset;
Arrow _type = Arrow::UP;
static microsec _precision_qualifier;
NoteGrade calculatePrecision(microsec odds) const;
};
#endif // NOTE_H