project-kyoku/src/classicgame/classicnote.h

76 lines
1.8 KiB
C
Raw Normal View History

2021-06-07 20:19:58 +02:00
#pragma once
#include "note.h"
#include "precisionevaluator.h"
2021-06-24 00:43:13 +02:00
#include "classicactions.h"
2021-06-07 20:19:58 +02:00
#include <memory>
#include <array>
class ClassicSprite;
2021-06-24 00:43:13 +02:00
class ClassicGraphicsManager;
class ClassicAnimationScenario;
2021-06-07 20:19:58 +02:00
class ClassicNote : public Note
{
public:
2021-06-11 18:58:44 +02:00
enum class Grade
2021-06-07 20:19:58 +02:00
{
PERFECT,
GOOD,
BAD
};
2021-06-24 00:43:13 +02:00
enum State
{
NONE,
FLYING,
ACTIVE,
DYING,
DEAD
2021-06-24 00:43:13 +02:00
};
explicit ClassicNote(const std::vector<microsec>& intervals, microsec perfect_offset,
Type type, const Coordinates& coord,
const std::unique_ptr<ClassicGraphicsManager>& manager);
2021-06-07 20:19:58 +02:00
virtual ~ClassicNote() = default;
virtual bool isActive() const override;
2021-06-11 18:58:44 +02:00
virtual void update(const microsec &music_offset) override;
virtual void input(PlayerInput&& inputdata) override;
2021-06-22 20:20:08 +02:00
virtual void putToGame(const microsec &music_offset) override;
virtual bool isInGame() const override;
virtual bool isExpired() const override;
virtual void draw() const override;
Type type() const noexcept;
std::shared_ptr<ClassicSprite> sprite() const noexcept;
void setSprite(const std::shared_ptr<ClassicSprite>& sprite) noexcept;
2021-06-11 18:58:44 +02:00
const Coordinates& getCoordinates() const noexcept;
2021-06-07 20:19:58 +02:00
private:
2021-07-14 17:24:47 +02:00
struct NoteElement
{
std::shared_ptr<ClassicSprite> _sprite;
std::array<std::shared_ptr<ClassicAnimationScenario>, 5> _animations;
2021-07-14 17:24:47 +02:00
const std::array<const sf::Keyboard::Key, 2> _keys;
const Coordinates _coordinates;
const Type _type;
bool pressed = false;
sf::Keyboard::Key pressed_as;
};
std::vector<NoteElement> _elements;
const PrecisionEvaluator<Grade> _evaluator;
const std::unique_ptr<ClassicGraphicsManager>& _graphics_manager;
2021-06-24 00:43:13 +02:00
State _state;
2021-06-07 20:19:58 +02:00
};