Implement abstraction for note sprites
parent
8a7602af78
commit
bbed8247ea
@ -0,0 +1,12 @@
|
||||
#include "classicarrow.h"
|
||||
|
||||
ClassicArrow::ClassicArrow()
|
||||
{}
|
||||
|
||||
ClassicArrow::~ClassicArrow()
|
||||
{}
|
||||
|
||||
void ClassicArrow::update()
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef CLASSICARROW_H
|
||||
#define CLASSICARROW_H
|
||||
|
||||
#include "notesprite.h"
|
||||
|
||||
class ClassicArrow : public NoteSprite
|
||||
{
|
||||
public:
|
||||
|
||||
enum class Type
|
||||
{
|
||||
ARROW_UP,
|
||||
ARROW_RIGHT,
|
||||
ARROW_DOWN,
|
||||
ARROW_LEFT
|
||||
};
|
||||
|
||||
explicit ClassicArrow();
|
||||
virtual ~ClassicArrow() override;
|
||||
|
||||
virtual void update() override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // CLASSICARROW_H
|
@ -0,0 +1,21 @@
|
||||
#include "notesprite.h"
|
||||
|
||||
NoteSprite::NoteSprite() :
|
||||
_state(State::DETACHED),
|
||||
_attached(false)
|
||||
{}
|
||||
|
||||
void NoteSprite::attach() noexcept
|
||||
{
|
||||
_attached = true;
|
||||
}
|
||||
|
||||
void NoteSprite::detach() noexcept
|
||||
{
|
||||
_attached = false;
|
||||
}
|
||||
|
||||
void NoteSprite::initState(State nextState) noexcept
|
||||
{
|
||||
_state = nextState;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#ifndef NOTESPRITE_H
|
||||
#define NOTESPRITE_H
|
||||
|
||||
#include <SFML/Graphics/Drawable.hpp>
|
||||
#include <SFML/Graphics/Transformable.hpp>
|
||||
|
||||
class NoteSprite : public sf::Drawable, public sf::Transformable
|
||||
{
|
||||
public:
|
||||
|
||||
enum class State
|
||||
{
|
||||
APPEARING,
|
||||
ACTIVE,
|
||||
TAPPED,
|
||||
DYING,
|
||||
|
||||
DETACHED
|
||||
};
|
||||
|
||||
explicit NoteSprite();
|
||||
virtual ~NoteSprite() = 0;
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
virtual void attach() noexcept final;
|
||||
virtual void detach() noexcept final;
|
||||
|
||||
virtual void initState(State nextState) noexcept final;
|
||||
|
||||
protected:
|
||||
State _state;
|
||||
bool _attached;
|
||||
};
|
||||
|
||||
#endif // NOTESPRITE_H
|
Loading…
Reference in New Issue