forked from NaiJi/project-kyoku
Implement classic arrow sprite interface
This commit is contained in:
parent
bbed8247ea
commit
09f74932ea
|
@ -9,18 +9,19 @@ file(GLOB SOURCES "*.h" "*.cpp" "*/*.h" "*/*.cpp")
|
||||||
|
|
||||||
# STATIC #
|
# STATIC #
|
||||||
# You need to build SFML from sources with cmake
|
# You need to build SFML from sources with cmake
|
||||||
#set(SFML_LIB_DIR
|
set(SFML_LIB_DIR
|
||||||
# ${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-graphics.so.2.5
|
${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-graphics.so.2.5
|
||||||
# ${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-system.so.2.5
|
${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-system.so.2.5
|
||||||
# ${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-window.so.2.5
|
${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-window.so.2.5
|
||||||
# ${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-audio.so.2.5)
|
${CMAKE_SOURCE_DIR}/SFML-2.5.1/lib/libsfml-audio.so.2.5)
|
||||||
#set(SFML_INCL_DIR ${CMAKE_SOURCE_DIR}/SFML-2.5.1/include)
|
set(SFML_INCL_DIR ${CMAKE_SOURCE_DIR}/SFML-2.5.1/include)
|
||||||
#include_directories(${SFML_INCL_DIR})
|
include_directories(${SFML_INCL_DIR})
|
||||||
#add_executable(project-kyoku ${SOURCES})
|
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/notesprites ${CMAKE_SOURCE_DIR}/timelineviews)
|
||||||
#target_link_libraries(project-kyoku ${SFML_LIB_DIR})
|
add_executable(project-kyoku ${SOURCES})
|
||||||
|
target_link_libraries(project-kyoku ${SFML_LIB_DIR})
|
||||||
|
|
||||||
# DYNAMIC #
|
# DYNAMIC #
|
||||||
# You only need to install SFML from your package manager
|
# You only need to install SFML from your package manager
|
||||||
find_package(SFML REQUIRED graphics window system)
|
#find_package(SFML REQUIRED graphics window system)
|
||||||
add_executable(project-kyoku ${SOURCES})
|
#add_executable(project-kyoku ${SOURCES})
|
||||||
target_link_libraries(project-kyoku sfml-system sfml-audio sfml-graphics sfml-network)
|
#target_link_libraries(project-kyoku sfml-system sfml-audio sfml-graphics sfml-network)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <SFML/Graphics/Color.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
#include <SFML/Window/Event.hpp>
|
#include <SFML/Window/Event.hpp>
|
||||||
#include "timelineviews/classicviewmanager.h"
|
#include "classicviewmanager.h"
|
||||||
|
|
||||||
const sf::Time TIME_PER_FRAME = sf::seconds(1.f / 60.f);
|
const sf::Time TIME_PER_FRAME = sf::seconds(1.f / 60.f);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#ifndef CLASSICARROW_H
|
#ifndef CLASSICARROW_H
|
||||||
#define CLASSICARROW_H
|
#define CLASSICARROW_H
|
||||||
|
|
||||||
#include "notesprite.h"
|
#include "notegraphicsentity.h"
|
||||||
|
|
||||||
class ClassicArrow : public NoteSprite
|
#include <SFML/Graphics/RectangleShape.hpp>
|
||||||
|
|
||||||
|
class ClassicArrow : public NoteGraphicsEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -20,8 +22,19 @@ public:
|
||||||
|
|
||||||
virtual void update() override;
|
virtual void update() override;
|
||||||
|
|
||||||
private:
|
virtual void onKeyPressed() override;
|
||||||
|
virtual void onKeyReleased() override;
|
||||||
|
|
||||||
|
virtual void show() override;
|
||||||
|
virtual void killAsExpired() override;
|
||||||
|
virtual void reset() override;
|
||||||
|
|
||||||
|
virtual bool isActive() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
sf::RectangleShape static_sprite;
|
||||||
|
sf::RectangleShape trail_sprite;
|
||||||
|
sf::VertexArray trail_vertex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CLASSICARROW_H
|
#endif // CLASSICARROW_H
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "notegraphicsentity.h"
|
||||||
|
|
||||||
|
NoteGraphicsEntity::NoteGraphicsEntity() :
|
||||||
|
_attached(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void NoteGraphicsEntity::attach() noexcept
|
||||||
|
{
|
||||||
|
_attached = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoteGraphicsEntity::detach() noexcept
|
||||||
|
{
|
||||||
|
_attached = false;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef NOTEGRAPHICSENTITY_H
|
||||||
|
#define NOTEGRAPHICSENTITY_H
|
||||||
|
|
||||||
|
#include <SFML/Graphics/Drawable.hpp>
|
||||||
|
#include <SFML/Graphics/Transformable.hpp>
|
||||||
|
|
||||||
|
class NoteGraphicsEntity : public sf::Drawable, public sf::Transformable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit NoteGraphicsEntity();
|
||||||
|
virtual ~NoteGraphicsEntity() = 0;
|
||||||
|
|
||||||
|
virtual void update() = 0;
|
||||||
|
|
||||||
|
virtual void attach() noexcept final;
|
||||||
|
virtual void detach() noexcept final;
|
||||||
|
|
||||||
|
virtual void onKeyPressed() = 0;
|
||||||
|
virtual void onKeyReleased() = 0;
|
||||||
|
|
||||||
|
virtual void show() = 0;
|
||||||
|
virtual void killAsExpired() = 0;
|
||||||
|
virtual void reset() = 0;
|
||||||
|
|
||||||
|
virtual bool isActive() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool _attached;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,21 +0,0 @@
|
||||||
#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;
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
#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
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "timeline.h"
|
#include "timeline.h"
|
||||||
#include "note.h"
|
#include "note.h"
|
||||||
#include "timelineviews/timelineviewmanager.h"
|
#include "timelineviewmanager.h"
|
||||||
|
|
||||||
#include <SFML/Graphics/RenderTarget.hpp>
|
#include <SFML/Graphics/RenderTarget.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "classicviewmanager.h"
|
#include "classicviewmanager.h"
|
||||||
#include "../note.h"
|
#include "note.h"
|
||||||
#include <SFML/Graphics/RectangleShape.hpp>
|
#include <SFML/Graphics/RectangleShape.hpp>
|
||||||
|
|
||||||
static constexpr std::size_t RESERVED_SIZE = 20;
|
static constexpr std::size_t RESERVED_SIZE = 20;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CLASSICDIVAVIEWMANAGER_H
|
#define CLASSICDIVAVIEWMANAGER_H
|
||||||
|
|
||||||
#include "timelineviewmanager.h"
|
#include "timelineviewmanager.h"
|
||||||
|
#include "classicarrow.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -17,17 +18,6 @@ public:
|
||||||
virtual void initNoteGraphics(Note *note) override;
|
virtual void initNoteGraphics(Note *note) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
enum Button
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
SHOULDER_RIGHT,
|
|
||||||
SHOULDER_LEFT,
|
|
||||||
|
|
||||||
AMOUNT_OF_KINDS
|
|
||||||
};
|
|
||||||
|
|
||||||
using SpritePoll = std::vector<std::shared_ptr<Sprite>>;
|
using SpritePoll = std::vector<std::shared_ptr<Sprite>>;
|
||||||
using SpriteDispatcher = std::array<SpritePoll, AMOUNT_OF_KINDS>;
|
using SpriteDispatcher = std::array<SpritePoll, AMOUNT_OF_KINDS>;
|
||||||
SpriteDispatcher _sprite_dispatcher;
|
SpriteDispatcher _sprite_dispatcher;
|
||||||
|
|
Loading…
Reference in New Issue