2021-06-07 14:19:58 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "note.h"
|
|
|
|
#include "precisionevaluator.h"
|
2021-06-08 14:32:36 -04:00
|
|
|
#include "classicinputtype.h"
|
2021-06-21 15:10:50 -04:00
|
|
|
#include "classicnotestate/classicnotestate.h"
|
2021-06-07 14:19:58 -04:00
|
|
|
|
2021-06-09 14:08:58 -04:00
|
|
|
#include <memory>
|
2021-06-21 15:10:50 -04:00
|
|
|
#include <array>
|
2021-06-09 14:08:58 -04:00
|
|
|
|
|
|
|
struct Coordinates
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
|
|
|
|
inline Coordinates operator+(const Coordinates& right) noexcept
|
|
|
|
{
|
|
|
|
return {right.x + x, right.y - y};
|
|
|
|
}
|
|
|
|
}; // MOVE TO OWN HEADER ^
|
|
|
|
|
|
|
|
class ClassicSprite;
|
|
|
|
|
2021-06-07 14:19:58 -04:00
|
|
|
class ClassicNote : public Note
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2021-06-11 12:58:44 -04:00
|
|
|
enum class Grade
|
2021-06-07 14:19:58 -04:00
|
|
|
{
|
|
|
|
PERFECT,
|
|
|
|
GOOD,
|
|
|
|
BAD
|
|
|
|
};
|
|
|
|
|
2021-06-09 14:08:58 -04:00
|
|
|
explicit ClassicNote(const std::vector<microsec>& intervals, microsec perfect_offset,
|
|
|
|
Action action, const Coordinates& coord);
|
2021-06-07 14:19:58 -04:00
|
|
|
virtual ~ClassicNote() = default;
|
2021-06-09 14:08:58 -04:00
|
|
|
|
2021-06-21 15:10:50 -04:00
|
|
|
virtual bool isActive() const override;
|
2021-06-11 12:58:44 -04:00
|
|
|
virtual void update(const microsec &music_offset) override;
|
2021-06-09 14:08:58 -04:00
|
|
|
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
2021-06-08 14:32:36 -04:00
|
|
|
|
2021-06-21 15:10:50 -04:00
|
|
|
virtual void putToGame(const microsec &offset) override;
|
|
|
|
virtual bool isExpired() const override;
|
|
|
|
|
2021-06-11 12:58:44 -04:00
|
|
|
Grade input(ClassicInputType&& input_data);
|
2021-06-09 14:08:58 -04:00
|
|
|
Action action() const;
|
|
|
|
|
|
|
|
std::shared_ptr<ClassicSprite> sprite() const noexcept;
|
2021-06-11 12:58:44 -04:00
|
|
|
void saveAppearanceTime(const microsec& offset);
|
2021-06-09 14:08:58 -04:00
|
|
|
void setSprite(const std::shared_ptr<ClassicSprite>& sprite) noexcept;
|
2021-06-11 12:58:44 -04:00
|
|
|
const Coordinates& getCoordinates() const noexcept;
|
2021-06-07 14:19:58 -04:00
|
|
|
|
|
|
|
private:
|
2021-06-09 14:08:58 -04:00
|
|
|
const Coordinates _coordinates;
|
2021-06-11 12:58:44 -04:00
|
|
|
const PrecisionEvaluator<Grade> _evaluator;
|
2021-06-09 14:08:58 -04:00
|
|
|
const Action _action;
|
|
|
|
|
|
|
|
std::shared_ptr<ClassicSprite> _sprite;
|
2021-06-11 12:58:44 -04:00
|
|
|
microsec _appearance_time;
|
|
|
|
float _trail_path_percent; //100% for sprite falling trajectory
|
2021-06-21 15:10:50 -04:00
|
|
|
|
|
|
|
std::array<std::shared_ptr<ClassicNoteState>, ClassicNoteState::COUNT> _states;
|
|
|
|
ClassicNoteState::Value _current_state;
|
2021-06-07 14:19:58 -04:00
|
|
|
};
|