forked from NaiJi/project-kyoku
Reorganize folders and project structure
This commit is contained in:
parent
09f74932ea
commit
76a69b534d
|
@ -5,7 +5,7 @@ project(project-kyoku LANGUAGES CXX)
|
|||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
file(GLOB SOURCES "*.h" "*.cpp" "*/*.h" "*/*.cpp")
|
||||
file(GLOB SOURCES "src/*.cpp" "src/classicgame/*")
|
||||
|
||||
# STATIC #
|
||||
# You need to build SFML from sources with cmake
|
||||
|
@ -15,8 +15,7 @@ set(SFML_LIB_DIR
|
|||
${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)
|
||||
set(SFML_INCL_DIR ${CMAKE_SOURCE_DIR}/SFML-2.5.1/include)
|
||||
include_directories(${SFML_INCL_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/notesprites ${CMAKE_SOURCE_DIR}/timelineviews)
|
||||
include_directories(${SFML_INCL_DIR} ${CMAKE_SOURCE_DIR}/include)
|
||||
add_executable(project-kyoku ${SOURCES})
|
||||
target_link_libraries(project-kyoku ${SFML_LIB_DIR})
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef INPUTTYPE_H
|
||||
#define INPUTTYPE_H
|
||||
|
||||
#include <SFML/System/Clock.hpp>
|
||||
|
||||
using microsec = sf::Int64;
|
||||
|
||||
class InputType
|
||||
{
|
||||
public:
|
||||
explicit InputType(const microsec& timestamp);
|
||||
virtual ~InputType() = 0;
|
||||
|
||||
const microsec& timestamp() const;
|
||||
|
||||
private:
|
||||
microsec _timestamp;
|
||||
};
|
||||
|
||||
#endif // INPUTTYPE_H
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef PRECISIONEVALUATOR_H
|
||||
#define PRECISIONEVALUATOR_H
|
||||
|
||||
#include <SFML/System/Clock.hpp>
|
||||
|
||||
using microsec = sf::Int64;
|
||||
|
||||
template<typename GRADE>
|
||||
class PrecisionEvaluator
|
||||
{
|
||||
public:
|
||||
|
||||
PrecisionEvaluator(microsec offset, microsec life_span_offset);
|
||||
|
||||
microsec offset() const noexcept;
|
||||
bool isActive(microsec music_play_offset) const noexcept;
|
||||
GRADE calculatePrecision(microsec odds) const;
|
||||
|
||||
static void resetPrecisionQualifier(microsec qualifier = 500000);
|
||||
|
||||
private:
|
||||
microsec _offset;
|
||||
microsec _start_handling_offset;
|
||||
microsec _end_handling_offset;
|
||||
|
||||
static microsec _precision_qualifier;
|
||||
};
|
||||
|
||||
#endif // PRECISIONEVALUATOR_H
|
97
note.h
97
note.h
|
@ -1,97 +0,0 @@
|
|||
#ifndef NOTE_H
|
||||
#define NOTE_H
|
||||
|
||||
#include <SFML/System/Clock.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/Graphics/RectangleShape.hpp> // TEMP MOCK
|
||||
#include <SFML/Graphics/RenderTarget.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
using microsec = sf::Int64;
|
||||
using coordinates = sf::Vector2i;
|
||||
|
||||
class Sprite : public sf::Drawable // MOCK
|
||||
{
|
||||
public:
|
||||
Sprite(sf::RectangleShape shape) : _shape(shape), _attached(false) {};
|
||||
bool isAttached() const noexcept
|
||||
{ return _attached; }
|
||||
|
||||
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override
|
||||
{
|
||||
target.draw(_shape, states);
|
||||
}
|
||||
|
||||
void setCoordinates(coordinates cords) noexcept
|
||||
{ _shape.setPosition(cords.x, cords.y); }
|
||||
|
||||
void setAttachment(bool attached) noexcept
|
||||
{ _attached = attached; }
|
||||
|
||||
private:
|
||||
sf::RectangleShape _shape;
|
||||
bool _attached;
|
||||
};
|
||||
|
||||
struct NoteGrade
|
||||
{
|
||||
int score;
|
||||
enum class Rating
|
||||
{
|
||||
WRONG,
|
||||
BAD,
|
||||
GOOD,
|
||||
GREAT
|
||||
} rating;
|
||||
|
||||
NoteGrade(int s, Rating r) : score(s), rating(r) {}
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
class Note : public sf::Drawable
|
||||
{
|
||||
public:
|
||||
enum class Arrow
|
||||
{
|
||||
UP,
|
||||
RIGHT,
|
||||
DOWN,
|
||||
LEFT,
|
||||
|
||||
NONE
|
||||
};
|
||||
|
||||
Note(microsec offset, microsec life_span_offset, Note::Arrow type = Note::Arrow::UP);
|
||||
|
||||
void setPosition(coordinates position);
|
||||
coordinates position() const noexcept;
|
||||
microsec offset() const noexcept;
|
||||
Note::Arrow type() const noexcept;
|
||||
|
||||
NoteGrade onTap(Arrow arrow_type, microsec tap_time_stamp);
|
||||
bool isActive(microsec music_play_offset) const noexcept;
|
||||
|
||||
void resetSprite(const std::shared_ptr<Sprite>& sprite = nullptr) noexcept;
|
||||
|
||||
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
||||
|
||||
static void resetPrecisionQualifier(microsec qualifier = 500000);
|
||||
|
||||
private:
|
||||
coordinates _position;
|
||||
microsec _offset;
|
||||
microsec _start_handling_offset;
|
||||
microsec _end_handling_offset;
|
||||
Arrow _type = Arrow::UP;
|
||||
|
||||
static microsec _precision_qualifier;
|
||||
NoteGrade calculatePrecision(microsec odds) const;
|
||||
|
||||
std::shared_ptr<Sprite> _sprite;
|
||||
};
|
||||
|
||||
#endif // NOTE_H
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef CLASSICACTIONS_H
|
||||
#define CLASSICACTIONS_H
|
||||
|
||||
enum class Action
|
||||
{
|
||||
NONE,
|
||||
|
||||
PRESS_UP, RELEASE_UP,
|
||||
PRESS_RIGHT, RELEASE_RIGHT,
|
||||
PRESS_DOWN, RELEASE_DOWN,
|
||||
PRESS_LEFT, RELEASE_LEFT,
|
||||
|
||||
PRESS_SLIDER_RIGHT, RELEASE_SLIDER_RIGHT,
|
||||
PRESS_SLIDER_LEFT, RELEASE_SLIDER_LEFT
|
||||
};
|
||||
|
||||
#endif // CLASSICACTIONS_H
|
|
@ -0,0 +1,19 @@
|
|||
#include "classicinputtype.h"
|
||||
|
||||
ClassicInputType::ClassicInputType(const microsec& timestamp, Action action) :
|
||||
InputType(timestamp),
|
||||
_action(action)
|
||||
{}
|
||||
|
||||
ClassicInputType::~ClassicInputType()
|
||||
{}
|
||||
|
||||
bool ClassicInputType::operator==(const Action& comparing_action) const
|
||||
{
|
||||
return _action == comparing_action;
|
||||
}
|
||||
|
||||
bool ClassicInputType::operator==(const ClassicInputType& comparing_action) const
|
||||
{
|
||||
return _action == comparing_action._action;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef CLASSICINPUTTYPE_H
|
||||
#define CLASSICINPUTTYPE_H
|
||||
|
||||
#include "classicactions.h"
|
||||
#include "inputtype.h"
|
||||
|
||||
class ClassicInputType : public InputType
|
||||
{
|
||||
public:
|
||||
explicit ClassicInputType(const microsec& timestamp, Action action);
|
||||
virtual ~ClassicInputType() override;
|
||||
|
||||
bool operator==(const Action& comparing_action) const;
|
||||
bool operator==(const ClassicInputType& comparing_action) const;
|
||||
|
||||
private:
|
||||
Action _action;
|
||||
};
|
||||
|
||||
#endif // CLASSICINPUTTYPE_H
|
|
@ -0,0 +1,13 @@
|
|||
#include "inputtype.h"
|
||||
|
||||
InputType::InputType(const microsec ×tamp) :
|
||||
_timestamp(timestamp)
|
||||
{}
|
||||
|
||||
InputType::~InputType()
|
||||
{}
|
||||
|
||||
const microsec& InputType::timestamp() const
|
||||
{
|
||||
return _timestamp;
|
||||
}
|
Loading…
Reference in New Issue