#ifndef NOTE_H #define NOTE_H #include #include #include // TEMP MOCK #include #include //////////////////////////////// using microsec = sf::Int64; using coordinates = sf::Vector2i; class Sprite : public sf::Drawable // MOCK { public: Sprite(sf::RectangleShape shape) : _shape(shape), _attached(false) {}; bool isAttached() const noexcept { return _attached; } virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override { target.draw(_shape, states); } void setCoordinates(coordinates cords) noexcept { _shape.setPosition(cords.x, cords.y); } void setAttachment(bool attached) noexcept { _attached = attached; } private: sf::RectangleShape _shape; bool _attached; }; struct NoteGrade { int score; enum class Rating { WRONG, BAD, GOOD, GREAT } rating; NoteGrade(int s, Rating r) : score(s), rating(r) {} }; //////////////////////////////// class Note : public sf::Drawable { 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; Note::Arrow type() const noexcept; NoteGrade onTap(Arrow arrow_type, microsec tap_time_stamp); bool isActive(microsec music_play_offset) const noexcept; void resetSprite(const std::shared_ptr& sprite = nullptr) noexcept; virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override; 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; std::shared_ptr _sprite; }; #endif // NOTE_H