project-kyoku/src/classicgame/classicnote.h

84 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
};
2021-07-15 04:45:52 +02:00
struct ClassicNoteInitializer
{
std::vector<microsec> intervals;
microsec perfect_offset;
struct Element
{
Type type;
Coordinates coordinates;
std::vector<Coordinates> falling_curve_interpolation;
std::array<sf::Keyboard::Key, 2> keys;
};
std::vector<Element> elements;
};
explicit ClassicNote(ClassicNoteInitializer&& init, 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;
2021-06-07 20:19:58 +02:00
private:
2021-07-14 17:24:47 +02:00
struct NoteElement
{
2021-07-15 04:45:52 +02:00
std::shared_ptr<ClassicSprite> sprite;
std::array<std::shared_ptr<ClassicAnimationScenario>, 5> animations;
2021-07-15 04:45:52 +02:00
std::array<sf::Keyboard::Key, 2> keys;
Coordinates coordinates;
Type type;
2021-07-14 17:24:47 +02:00
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
};