From 00273ab2fdf453a3fe82092e0516a5188eed5a15 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Tue, 28 Sep 2021 06:48:06 +0300 Subject: [PATCH] Implement inheritance tree for Note --- CMakeLists.txt | 9 +- core/CMakeLists.txt | 3 +- core/shared/core/inputtype.h | 5 +- modes/classicmode/CMakeLists.txt | 8 +- modes/classicmode/game/classicactions.h | 5 +- modes/classicmode/game/classicarrownote.cpp | 137 +++++++++++++++++ modes/classicmode/game/classicarrownote.h | 41 ++++++ modes/classicmode/game/classicgame.cpp | 8 +- modes/classicmode/game/classicgame.h | 2 - modes/classicmode/game/classicmapcreator.cpp | 23 +-- modes/classicmode/game/classicnote.cpp | 138 +----------------- modes/classicmode/game/classicnote.h | 64 ++------ modes/classicmode/game/context.h | 10 ++ modes/classicmode/game/holdmanager.cpp | 6 + modes/classicmode/game/holdmanager.h | 18 +++ .../initializers/arrowelementinitializer.h | 10 ++ .../game/initializers/arrownoteinitializer.h | 12 ++ .../game/initializers/elementinitializer.h | 14 ++ .../game/initializers/noteinitializer.h | 14 ++ tools/CMakeLists.txt | 2 + 20 files changed, 311 insertions(+), 218 deletions(-) create mode 100644 modes/classicmode/game/classicarrownote.cpp create mode 100644 modes/classicmode/game/classicarrownote.h create mode 100644 modes/classicmode/game/context.h create mode 100644 modes/classicmode/game/holdmanager.cpp create mode 100644 modes/classicmode/game/holdmanager.h create mode 100644 modes/classicmode/game/initializers/arrowelementinitializer.h create mode 100644 modes/classicmode/game/initializers/arrownoteinitializer.h create mode 100644 modes/classicmode/game/initializers/elementinitializer.h create mode 100644 modes/classicmode/game/initializers/noteinitializer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 325a359..1318a4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ set(CMAKE_THREAD_LIBS_INIT "-lpthread") file(GLOB_RECURSE SOURCES "src/main.cpp" "src/application/*.cpp" "src/application/*.h") add_executable(project-kyoku ${SOURCES}) -option(SFML_BUILT "SFML_BUILT" ON) +option(SFML_BUILT "SFML_BUILT" OFF) if(SFML_BUILT) set(SFML_LIB_DIR @@ -30,25 +30,24 @@ if(SFML_BUILT) set(SFML_INCL_DIR ${CMAKE_SOURCE_DIR}/SFML-2.5.1/include) target_link_libraries(project-kyoku ${SFML_LIB_DIR}) else() - find_package(SFML) + find_package(SFML REQUIRED graphics window system) + include_directories(${SFML_INCL_DIR} ${CMAKE_SOURCE_DIR}/include) target_link_libraries(project-kyoku sfml-system sfml-audio sfml-graphics sfml-network) endif() include_directories(${SFML_INCL_DIR} ${CMAKE_SOURCE_DIR}/include) SET(CMAKE_INSTALL_PREFIX /) +# When new game modes appear, aggregate them into a ONE subdirectory if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modes/classicmode/CMakeLists.txt") add_subdirectory(modes/classicmode) - target_include_directories(project-kyoku PRIVATE ${CMAKE_SOURCE_DIR}/modes/classicmode/shared) target_link_libraries(project-kyoku classicmode) endif() if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tools/CMakeLists.txt") add_subdirectory(tools) - target_include_directories(project-kyoku PRIVATE ${CMAKE_SOURCE_DIR}/tools/shared) target_link_libraries(project-kyoku tools) endif() if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/CMakeLists.txt") add_subdirectory(core) - target_include_directories(project-kyoku PRIVATE ${CMAKE_SOURCE_DIR}/core/shared) target_link_libraries(project-kyoku core) endif() diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 1ab5eda..557d413 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -4,7 +4,6 @@ project(core) set(CMAKE_INCLUDE_CURRENT_DIR ON) include_directories(${CMAKE_SOURCE_DIR}/include) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/shared) file(GLOB_RECURSE HEADERS "shared/*.h") file(GLOB_RECURSE SOURCES "src/*.cpp") @@ -12,3 +11,5 @@ file(GLOB_RECURSE SOURCES "src/*.cpp") add_library(core STATIC ${SOURCES} ${HEADERS}) target_include_directories(core PRIVATE ${CMAKE_SOURCE_DIR}/tools/shared) target_link_libraries(core tools) + +target_include_directories(project-kyoku PRIVATE ${CMAKE_SOURCE_DIR}/core/shared) diff --git a/core/shared/core/inputtype.h b/core/shared/core/inputtype.h index 2274218..08bb8d5 100644 --- a/core/shared/core/inputtype.h +++ b/core/shared/core/inputtype.h @@ -1,5 +1,4 @@ -#ifndef INPUTTYPE_H -#define INPUTTYPE_H +#pragma once #include #include "tools/mathutils.h" @@ -9,5 +8,3 @@ struct PlayerInput microsec timestamp; sf::Event event; }; - -#endif // INPUTTYPE_H diff --git a/modes/classicmode/CMakeLists.txt b/modes/classicmode/CMakeLists.txt index 1012ded..0fea7ef 100644 --- a/modes/classicmode/CMakeLists.txt +++ b/modes/classicmode/CMakeLists.txt @@ -3,13 +3,17 @@ cmake_minimum_required(VERSION 2.8.8) project(classicmode) set(CMAKE_INCLUDE_CURRENT_DIR ON) -include_directories(${CMAKE_SOURCE_DIR}/shared) +include_directories(${CMAKE_SOURCE_DIR}/include) -file(GLOB_RECURSE HEADERS "shared/*.h") +file(GLOB_RECURSE HEADERS "shared/*.h" ) file(GLOB_RECURSE SOURCES "editor/*.h" "editor/*.cpp" "game/*.h" "game/*.cpp" "./classicfactory.cpp") add_library(classicmode STATIC ${SOURCES} ${HEADERS}) target_include_directories(classicmode PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_include_directories(classicmode PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/game) target_include_directories(classicmode PRIVATE ${CMAKE_SOURCE_DIR}/tools/shared) target_include_directories(classicmode PRIVATE ${CMAKE_SOURCE_DIR}/core/shared) target_link_libraries(classicmode tools core) + +target_include_directories(project-kyoku PRIVATE ${CMAKE_SOURCE_DIR}/modes/classicmode/shared) + diff --git a/modes/classicmode/game/classicactions.h b/modes/classicmode/game/classicactions.h index bae7fa6..1e7e0d7 100644 --- a/modes/classicmode/game/classicactions.h +++ b/modes/classicmode/game/classicactions.h @@ -1,5 +1,4 @@ -#ifndef CLASSICACTIONS_H -#define CLASSICACTIONS_H +#pragma once enum class Action { @@ -28,5 +27,3 @@ enum class Type SLIDER_RIGHT, SLIDER_LEFT }; - -#endif // CLASSICACTIONS_H diff --git a/modes/classicmode/game/classicarrownote.cpp b/modes/classicmode/game/classicarrownote.cpp new file mode 100644 index 0000000..c1a6f85 --- /dev/null +++ b/modes/classicmode/game/classicarrownote.cpp @@ -0,0 +1,137 @@ +#include "classicarrownote.h" +#include "classicgraphicsmanager.h" + +// Replace with interface by dependency injection +#include "classicflyinganimationscenario.h" +#include "classicdyinganimationscenario.h" +// + +ClassicArrowNote::ClassicArrowNote(ArrowNoteInitializer&& init) : + ClassicNote(std::move(init.initializer)), + _is_hold(init.hold) +{ + _elements.resize(init.elements.size()); + + for (std::size_t i = 0; i < _elements.size(); ++i) + { + _elements[i].keys = init.elements[i].element.keys; + _elements[i].coordinates = init.elements[i].element.coordinates; + _elements[i].type = init.elements[i].type; + + // Animations will be injected into note. + _elements[i].animations[State::NONE] = nullptr; + _elements[i].animations[State::FLYING] = std::make_shared(); + _elements[i].animations[State::ACTIVE] = _elements[i].animations[State::FLYING]; + _elements[i].animations[State::DYING] = std::make_shared(); + _elements[i].animations[State::DEAD] = nullptr; + } +} + +void ClassicArrowNote::putToGame(const microsec &music_offset) +{ + _state = State::FLYING; + + for (auto& element : _elements) + { + element.sprite = _context->graphics_manager->getSprite(element.type); + element.sprite->setCoordinates(element.coordinates, 0., 9.); + element.animations[_state]->launch(element.sprite, music_offset, offset()); + } +} + +void ClassicArrowNote::input(PlayerInput&& inputdata) +{ + auto grade = ClassicNote::Grade::BAD; + + bool input_valid = std::any_of(_elements.begin(), _elements.end(), + [inputdata=inputdata](auto& element) + { + if (element.pressed) + return false; + + auto key_iterator = std::find(element.keys.begin(), element.keys.end(), inputdata.event.key.code); + bool found_key = key_iterator != element.keys.end(); + if (found_key) + { + element.pressed = true; + element.pressed_as = inputdata.event.key.code; + } + + return found_key; + }); + + bool all_pressed = allElementsPressed(); + + if (all_pressed) + grade = _evaluator.calculatePrecision(inputdata.timestamp); + + if (all_pressed || !input_valid) + { + _state = State::DYING; + for (auto& element : _elements) + element.animations[_state]->launch(element.sprite, inputdata.timestamp, offset()); + } + + std::cout << "User input: " << static_cast(grade) << "\n"; +} + +void ClassicArrowNote::draw() const +{ + for (std::size_t i = 0; i < _elements.size(); ++i) + { + if (i >= 1) + _context->graphics_manager->drawLine(_elements[i-1].sprite->trailCoordinates(), _elements[i].sprite->trailCoordinates()); + + _context->graphics_manager->draw(_elements[i].sprite); + } +} + +void ClassicArrowNote::update(const microsec& music_offset) +{ + switch (_state) + { + default: return; + break; + + case State::FLYING: + if (_evaluator.isActive(music_offset)) + _state = State::ACTIVE; + break; + + case State::DYING: + if (_elements[0].animations[_state]->isDone()) + _state = State::DEAD; + break; + + case State::ACTIVE: + if (!_evaluator.isActive(music_offset)) + { + _state = State::DYING; + for (auto& element : _elements) + element.animations[_state]->launch(element.sprite, music_offset, offset()); + } + break; + } + + for (auto& element : _elements) + if (element.animations[_state]) + element.animations[_state]->update(music_offset); +} + +bool ClassicArrowNote::allElementsPressed() const +{ + return std::all_of(_elements.begin(), _elements.end(), + [](const auto& element) + { + return element.pressed; + }); +} + +bool ClassicArrowNote::isPressedAs(sf::Keyboard::Key key) const +{ + return std::any_of(_elements.begin(), _elements.end(), + [key=key](const auto& element) + { + return key == element.pressed_as; + }); +} diff --git a/modes/classicmode/game/classicarrownote.h b/modes/classicmode/game/classicarrownote.h new file mode 100644 index 0000000..2ac8bc1 --- /dev/null +++ b/modes/classicmode/game/classicarrownote.h @@ -0,0 +1,41 @@ +#pragma once + +#include "classicnote.h" +#include "initializers/arrownoteinitializer.h" + +class ClassicArrowNote : public ClassicNote +{ +public: + explicit ClassicArrowNote(ArrowNoteInitializer&& init); + virtual ~ClassicArrowNote() = default; + + virtual void putToGame(const microsec& music_offset) override; + virtual void update(const microsec &music_offset) override; + virtual void input(PlayerInput&& inputdata) override; + virtual void draw() const override; + + bool allElementsPressed() const; + bool isPressedAs(sf::Keyboard::Key key) const; + +private: + + struct ArrowElement + { + std::shared_ptr sprite; + std::array, 5> animations; + sf::Keyboard::Key pressed_as = sf::Keyboard::Unknown; + + Coordinates coordinates; + std::vector falling_curve_interpolation; + std::array keys; + Type type = Type::NONE; + bool pressed = false; + + // Each note may consist of several buttons. + // For example, ↑ → or ↓ → ← + // Note Element represents this idea. + }; + + std::vector _elements; + bool _is_hold; +}; diff --git a/modes/classicmode/game/classicgame.cpp b/modes/classicmode/game/classicgame.cpp index 674691a..d988d47 100644 --- a/modes/classicmode/game/classicgame.cpp +++ b/modes/classicmode/game/classicgame.cpp @@ -100,18 +100,18 @@ void ClassicGame::input(PlayerInput&& inputdata) note->input(std::move(inputdata)); _slap.play(); - if (note->isHold() && note->allElementsPressed()) // also check for Type + /*if (note->isHold() && note->allElementsPressed()) // also check for Type { _notes_on_hold.emplace_back(note); std::cout << "HOLD initited by " << inputdata.event.key.code << '\n'; - } + }*/ } } break; case sf::Event::KeyReleased: { - bool key_match = std::any_of(_notes_on_hold.begin(), _notes_on_hold.end(), + /*bool key_match = std::any_of(_notes_on_hold.begin(), _notes_on_hold.end(), [key=inputdata.event.key.code](const auto& note) { return note->isPressedAs(key); @@ -121,7 +121,7 @@ void ClassicGame::input(PlayerInput&& inputdata) { _notes_on_hold.clear(); std::cout << "HOLD released by " << inputdata.event.key.code << '\n'; - } + }*/ } break; diff --git a/modes/classicmode/game/classicgame.h b/modes/classicmode/game/classicgame.h index cd2da10..885e4a3 100644 --- a/modes/classicmode/game/classicgame.h +++ b/modes/classicmode/game/classicgame.h @@ -33,8 +33,6 @@ private: std::map _buttons_to_pressed_actions; std::map _buttons_to_released_actions; - std::vector _notes_on_hold; - std::shared_ptr _graphics_manager; Timeline _timeline; diff --git a/modes/classicmode/game/classicmapcreator.cpp b/modes/classicmode/game/classicmapcreator.cpp index 8591a83..c916ffc 100644 --- a/modes/classicmode/game/classicmapcreator.cpp +++ b/modes/classicmode/game/classicmapcreator.cpp @@ -1,5 +1,5 @@ #include "classicmapcreator.h" -#include "classicnote.h" +#include "classicarrownote.h" // Replace with interface by dependency injection #include "classicflyinganimationscenario.h" @@ -33,23 +33,26 @@ Beatmap ClassicMapCreator::createBeatmap(const std::string& filepath) const int counter = 3; + const auto context = std::make_shared(Context{_graphics_manager}); + while (bpm_iterator < bpm_end) { - ClassicNote::ClassicNoteInitializer init; - ClassicNote::ClassicNoteInitializer::Element element; - init.intervals = input_intervals; - init.perfect_offset = bpm_iterator; + ArrowNoteInitializer init; + ArrowElementInitializer element; + init.initializer.intervals = input_intervals; + init.initializer.perfect_offset = bpm_iterator; init.hold = false; + init.initializer.context = context; - element.coordinates = {x, 390.}; - element.falling_curve_interpolation = {}; - element.keys = {sf::Keyboard::W, sf::Keyboard::Up}; + element.element.coordinates = {x, 390.}; + element.element.falling_curve_interpolation = {}; + element.element.keys = {sf::Keyboard::W, sf::Keyboard::Up}; element.type = Type::UP; if (counter == 0) { init.hold = true; - element.keys = {sf::Keyboard::D, sf::Keyboard::Right}; + element.element.keys = {sf::Keyboard::D, sf::Keyboard::Right}; element.type = Type::RIGHT; } @@ -57,7 +60,7 @@ Beatmap ClassicMapCreator::createBeatmap(const std::string& filepath) const init.elements = {element}; - notes.emplace_back(new ClassicNote(std::move(init), _graphics_manager)); + notes.emplace_back(new ClassicArrowNote(std::move(init))); bpm_iterator += tempo_interval; x += 70; diff --git a/modes/classicmode/game/classicnote.cpp b/modes/classicmode/game/classicnote.cpp index bfc27a2..4ce39c0 100644 --- a/modes/classicmode/game/classicnote.cpp +++ b/modes/classicmode/game/classicnote.cpp @@ -7,47 +7,18 @@ #include "classicdyinganimationscenario.h" // -ClassicNote::ClassicNote(ClassicNoteInitializer &&init, const std::shared_ptr& manager) : +ClassicNote::ClassicNote(NoteInitializer &&init) : Note(init.perfect_offset), _evaluator(init.intervals, _perfect_offset), - _graphics_manager(manager), - _state(State::NONE) -{ - _elements.resize(init.elements.size()); - _isHold = init.hold; - - for (std::size_t i = 0; i < _elements.size(); ++i) - { - _elements[i].keys = init.elements[i].keys; - _elements[i].coordinates = init.elements[i].coordinates; - _elements[i].type = init.elements[i].type; - - // Animations will be injected into note. - _elements[i].animations[State::NONE] = nullptr; - _elements[i].animations[State::FLYING] = std::make_shared(); - _elements[i].animations[State::ACTIVE] = _elements[i].animations[State::FLYING]; - _elements[i].animations[State::DYING] = std::make_shared(); - _elements[i].animations[State::DEAD] = nullptr; - } -} + _state(State::NONE), + _context(init.context) +{} bool ClassicNote::isActive() const { return _state == State::ACTIVE; } -void ClassicNote::putToGame(const microsec &music_offset) -{ - _state = State::FLYING; - - for (auto& element : _elements) - { - element.sprite = _graphics_manager->getSprite(element.type); - element.sprite->setCoordinates(element.coordinates, 0., 9.); - element.animations[_state]->launch(element.sprite, music_offset, offset()); - } -} - bool ClassicNote::isInGame() const { return _state == State::FLYING @@ -59,104 +30,3 @@ bool ClassicNote::shouldRemove() const { return _state == State::DEAD; } - -void ClassicNote::update(const microsec& music_offset) -{ - switch (_state) - { - default: return; - break; - - case State::FLYING: - if (_evaluator.isActive(music_offset)) - _state = State::ACTIVE; - break; - - case State::DYING: - if (_elements[0].animations[_state]->isDone()) - _state = State::DEAD; - break; - - case State::ACTIVE: - if (!_evaluator.isActive(music_offset)) - { - _state = State::DYING; - for (auto& element : _elements) - element.animations[_state]->launch(element.sprite, music_offset, offset()); - } - break; - } - - for (auto& element : _elements) - if (element.animations[_state]) - element.animations[_state]->update(music_offset); -} - -void ClassicNote::input(PlayerInput&& inputdata) -{ - auto grade = ClassicNote::Grade::BAD; - - bool input_valid = std::any_of(_elements.begin(), _elements.end(), - [inputdata=inputdata](auto& element) - { - if (element.pressed) - return false; - - auto key_iterator = std::find(element.keys.begin(), element.keys.end(), inputdata.event.key.code); - bool found_key = key_iterator != element.keys.end(); - if (found_key) - { - element.pressed = true; - element.pressed_as = inputdata.event.key.code; - } - - return found_key; - }); - - bool all_pressed = allElementsPressed(); - - if (all_pressed) - grade = _evaluator.calculatePrecision(inputdata.timestamp); - - if (all_pressed || !input_valid) - { - _state = State::DYING; - for (auto& element : _elements) - element.animations[_state]->launch(element.sprite, inputdata.timestamp, offset()); - } - - std::cout << "User input: " << static_cast(grade) << "\n"; -} - -void ClassicNote::draw() const -{ - for (std::size_t i = 0; i < _elements.size(); ++i) - { - if (i >= 1) - _graphics_manager->drawLine(_elements[i-1].sprite->trailCoordinates(), _elements[i].sprite->trailCoordinates()); - _graphics_manager->draw(_elements[i].sprite); - } -} - -bool ClassicNote::isHold() const -{ - return _isHold; -} - -bool ClassicNote::allElementsPressed() const -{ - return std::all_of(_elements.begin(), _elements.end(), - [](const auto& element) - { - return element.pressed; - }); -} - -bool ClassicNote::isPressedAs(sf::Keyboard::Key key) const -{ - return std::any_of(_elements.begin(), _elements.end(), - [key=key](const auto& element) - { - return key == element.pressed_as; - }); -} diff --git a/modes/classicmode/game/classicnote.h b/modes/classicmode/game/classicnote.h index 25c7733..38482da 100644 --- a/modes/classicmode/game/classicnote.h +++ b/modes/classicmode/game/classicnote.h @@ -1,14 +1,11 @@ #pragma once +#include "context.h" #include "core/note.h" #include "core/precisionevaluator.h" -#include "classicactions.h" - -#include -#include +#include "initializers/noteinitializer.h" class ClassicSprite; -class ClassicGraphicsManager; class ClassicAnimationScenario; class ClassicNote : public Note @@ -32,58 +29,21 @@ public: DEAD }; - struct ClassicNoteInitializer - { - std::vector intervals; - microsec perfect_offset; - bool hold; - - struct Element - { - Type type; - Coordinates coordinates; - std::vector falling_curve_interpolation; - std::array keys; - }; - - std::vector elements; - }; - - explicit ClassicNote(ClassicNoteInitializer&& init, const std::shared_ptr& manager); + explicit ClassicNote(NoteInitializer&& init); virtual ~ClassicNote() = default; - virtual bool isActive() const override; - virtual void update(const microsec &music_offset) override; - virtual void input(PlayerInput&& inputdata) override; - virtual void putToGame(const microsec &music_offset) override; - virtual bool isInGame() const override; - virtual bool shouldRemove() const override; - virtual void draw() const override; - - bool isHold() const; - bool allElementsPressed() const; - bool isPressedAs(sf::Keyboard::Key key) const; - -private: - - struct NoteElement - { - std::shared_ptr sprite; - std::array, 5> animations; - - std::array keys; - Coordinates coordinates; // Each note may consist of several buttons. - Type type; // For example, ↑ → or ↓ → ← - // Note Element represents this idea. - bool pressed = false; // Each ending button in such sequence - sf::Keyboard::Key pressed_as; // is an element. - }; + virtual bool isActive() const override final; + virtual bool isInGame() const override final; + virtual bool shouldRemove() const override final; - std::vector _elements; + virtual void putToGame(const microsec &music_offset) override = 0; + virtual void update(const microsec &music_offset) override = 0; + virtual void input(PlayerInput&& inputdata) override = 0; + virtual void draw() const override = 0; +protected: const PrecisionEvaluator _evaluator; - const std::shared_ptr _graphics_manager; State _state; - bool _isHold; + std::shared_ptr _context; }; diff --git a/modes/classicmode/game/context.h b/modes/classicmode/game/context.h new file mode 100644 index 0000000..5d53823 --- /dev/null +++ b/modes/classicmode/game/context.h @@ -0,0 +1,10 @@ +#pragma once + +#include + +class ClassicGraphicsManager; + +struct Context +{ + std::shared_ptr graphics_manager; +}; diff --git a/modes/classicmode/game/holdmanager.cpp b/modes/classicmode/game/holdmanager.cpp new file mode 100644 index 0000000..4e80bc1 --- /dev/null +++ b/modes/classicmode/game/holdmanager.cpp @@ -0,0 +1,6 @@ +#include "holdmanager.h" + + +/* THIS IS SIDEQUEST!!!! Right now I am working on the Editor >:C + * + * */ diff --git a/modes/classicmode/game/holdmanager.h b/modes/classicmode/game/holdmanager.h new file mode 100644 index 0000000..29ffbe3 --- /dev/null +++ b/modes/classicmode/game/holdmanager.h @@ -0,0 +1,18 @@ +#pragma once + +#include "core/inputtype.h" +#include + +class ClassicArrowNote; + +class HoldManager // Not important now +{ +public: + explicit HoldManager() = default; + + void emplace(ClassicArrowNote* note); + void checkRelease(sf::Keyboard::Key released_key); + +private: + std::vector _notes_on_hold; +}; diff --git a/modes/classicmode/game/initializers/arrowelementinitializer.h b/modes/classicmode/game/initializers/arrowelementinitializer.h new file mode 100644 index 0000000..c8236dc --- /dev/null +++ b/modes/classicmode/game/initializers/arrowelementinitializer.h @@ -0,0 +1,10 @@ +#pragma once + +#include "elementinitializer.h" +#include "classicactions.h" + +struct ArrowElementInitializer +{ + ElementInitializer element; + Type type = Type::NONE; +}; diff --git a/modes/classicmode/game/initializers/arrownoteinitializer.h b/modes/classicmode/game/initializers/arrownoteinitializer.h new file mode 100644 index 0000000..258153f --- /dev/null +++ b/modes/classicmode/game/initializers/arrownoteinitializer.h @@ -0,0 +1,12 @@ +#pragma once + +#include "noteinitializer.h" +#include "arrowelementinitializer.h" + +struct ArrowNoteInitializer +{ + NoteInitializer initializer; + bool hold = false; + + std::vector elements; +}; diff --git a/modes/classicmode/game/initializers/elementinitializer.h b/modes/classicmode/game/initializers/elementinitializer.h new file mode 100644 index 0000000..da4daaf --- /dev/null +++ b/modes/classicmode/game/initializers/elementinitializer.h @@ -0,0 +1,14 @@ +#pragma once + +#include "core/inputtype.h" +#include "tools/mathutils.h" + +#include +#include + +struct ElementInitializer +{ + Coordinates coordinates; + std::vector falling_curve_interpolation; + std::array keys; // needs initialization +}; diff --git a/modes/classicmode/game/initializers/noteinitializer.h b/modes/classicmode/game/initializers/noteinitializer.h new file mode 100644 index 0000000..cd5108d --- /dev/null +++ b/modes/classicmode/game/initializers/noteinitializer.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +#include "context.h" +#include "tools/mathutils.h" + +struct NoteInitializer +{ + std::shared_ptr context; + std::vector intervals; + microsec perfect_offset = 0; +}; diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 849dd93..92d4e92 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -10,3 +10,5 @@ file(GLOB_RECURSE HEADERS "shared/*.h" "include/*.h") file(GLOB_RECURSE SOURCES "src/*.cpp") add_library(tools STATIC ${SOURCES} ${HEADERS}) + +target_include_directories(project-kyoku PRIVATE ${CMAKE_SOURCE_DIR}/tools/shared)