From a35ca7c4accb2bc363a6b5286907ebdbdcb08eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 21:35:29 +0300 Subject: [PATCH 01/44] create Hero 2.0 --- core/CMakeLists.txt | 2 +- .../condition/KeyReleasedCondition.cpp | 15 ++++ .../condition/KeyReleasedCondition.hpp | 18 ++++ .../condition/LastStateCondition.cpp | 13 +++ .../condition/LastStateCondition.hpp | 20 +++++ core/event/management/controller/Idle.cpp | 6 ++ core/event/management/controller/Idle.hpp | 20 +++++ core/event/management/controller/Jump.cpp | 15 ++++ core/event/management/controller/Jump.hpp | 25 ++++++ core/event/management/controller/Run.cpp | 21 +++++ core/event/management/controller/Run.hpp | 29 +++++++ .../controller/statemachine/StateMachine.cpp | 5 ++ .../controller/statemachine/StateMachine.hpp | 3 + core/loader/LevelLoaderFromFile.cpp | 81 +++++++++-------- core/loader/LevelLoaderFromFile.hpp | 4 + game/mobs/hero/Hero.cpp | 86 +++++++++++++++++++ game/mobs/hero/Hero.hpp | 23 +++++ 17 files changed, 343 insertions(+), 43 deletions(-) create mode 100644 core/event/management/condition/KeyReleasedCondition.cpp create mode 100644 core/event/management/condition/KeyReleasedCondition.hpp create mode 100644 core/event/management/condition/LastStateCondition.cpp create mode 100644 core/event/management/condition/LastStateCondition.hpp create mode 100644 core/event/management/controller/Idle.cpp create mode 100644 core/event/management/controller/Idle.hpp create mode 100644 core/event/management/controller/Jump.cpp create mode 100644 core/event/management/controller/Jump.hpp create mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/Run.hpp create mode 100644 game/mobs/hero/Hero.cpp create mode 100644 game/mobs/hero/Hero.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b1ae6b4..a8995e7 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/condition/KeyReleasedCondition.cpp b/core/event/management/condition/KeyReleasedCondition.cpp new file mode 100644 index 0000000..fd9df64 --- /dev/null +++ b/core/event/management/condition/KeyReleasedCondition.cpp @@ -0,0 +1,15 @@ +#include "KeyReleasedCondition.hpp" +#include +#include +std::unordered_set mad::core::KeyReleasedCondition::triggers() { + return {mad::core::Event::Type::KeyReleased}; +} +bool mad::core::KeyReleasedCondition::is_triggered_by(const mad::core::Event &event) { + const auto &keystroke = const_cast_to(event); + return keystroke.key_id == m_key_id; +} + +mad::core::KeyReleasedCondition::KeyReleasedCondition(const int m_key_id) : m_key_id(m_key_id){ +} +void mad::core::KeyReleasedCondition::on_start() { +} diff --git a/core/event/management/condition/KeyReleasedCondition.hpp b/core/event/management/condition/KeyReleasedCondition.hpp new file mode 100644 index 0000000..ec846c9 --- /dev/null +++ b/core/event/management/condition/KeyReleasedCondition.hpp @@ -0,0 +1,18 @@ +#ifndef MAD_KEYRELEASEDCONDITION_HPP +#define MAD_KEYRELEASEDCONDITION_HPP + +#include "Condition.hpp" +namespace mad::core { + struct KeyReleasedCondition : Condition { + public: + explicit KeyReleasedCondition(int m_key_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + const int m_key_id; + }; +}// namespace mad::core + +#endif//MAD_KEYRELEASEDCONDITION_HPP diff --git a/core/event/management/condition/LastStateCondition.cpp b/core/event/management/condition/LastStateCondition.cpp new file mode 100644 index 0000000..a2fb453 --- /dev/null +++ b/core/event/management/condition/LastStateCondition.cpp @@ -0,0 +1,13 @@ +#include "LastStateCondition.hpp" + +bool mad::core::LastStateCondition::is_triggered_by(const mad::core::Event &event) { + return m_to_state_id == m_machine->get_previous_state_id(); +} +std::unordered_set mad::core::LastStateCondition::triggers() { + return {mad::core::Event::Type::KeyPressed, mad::core::Event::Type::Collision, mad::core::Event::Type::KeyHeld, mad::core::Event::Type::KeyReleased, mad::core::Event::Type::LevelPause, mad::core::Event::Type::Menu, mad::core::Event::Type::Movement, mad::core::Event::Type::Runner, mad::core::Event::Type::Visual, mad::core::Event::Type::WindowClose}; +} +void mad::core::LastStateCondition::on_start() { +} +mad::core::LastStateCondition::LastStateCondition(std::shared_ptr m_machine, mad::core::StateMachine::StateId m_to_state_id) : m_machine(m_machine), m_to_state_id(m_to_state_id){ + +} diff --git a/core/event/management/condition/LastStateCondition.hpp b/core/event/management/condition/LastStateCondition.hpp new file mode 100644 index 0000000..89ec58e --- /dev/null +++ b/core/event/management/condition/LastStateCondition.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_LASTSTATECONDITION_HPP +#define MAD_LASTSTATECONDITION_HPP + +#include "Condition.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" +namespace mad::core { + struct LastStateCondition : Condition { + public: + LastStateCondition(std::shared_ptr m_machine, StateMachine::StateId m_to_state_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + std::shared_ptr m_machine; + StateMachine::StateId m_to_state_id; + }; +}// namespace mad::core + +#endif//MAD_LASTSTATECONDITION_HPP diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp new file mode 100644 index 0000000..f3ef8dd --- /dev/null +++ b/core/event/management/controller/Idle.cpp @@ -0,0 +1,6 @@ +#include "Idle.hpp" +mad::core::Idle::Idle() { +} +void mad::core::Idle::control() { + +} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp new file mode 100644 index 0000000..e7ea1ff --- /dev/null +++ b/core/event/management/controller/Idle.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_IDLE_HPP +#define MAD_IDLE_HPP +#include "Controller.hpp" + +namespace mad::core { + + class Idle : public Controller { + public: + explicit Idle(); + + void control() override; + + private: + + }; + +} + + +#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp new file mode 100644 index 0000000..9e5dd5a --- /dev/null +++ b/core/event/management/controller/Jump.cpp @@ -0,0 +1,15 @@ +#include "Jump.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +} +void mad::core::Jump::control() { + + auto impulse = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); + }); + }; + + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); +} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp new file mode 100644 index 0000000..25d5cf1 --- /dev/null +++ b/core/event/management/controller/Jump.hpp @@ -0,0 +1,25 @@ +#ifndef MAD_JUMP_HPP +#define MAD_JUMP_HPP + +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" +namespace mad::core { + + class Jump : public Controller { + public: + + explicit Jump(std::shared_ptr world, Entity::Id entity_id); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + + }; + +} + +#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp new file mode 100644 index 0000000..3fe6107 --- /dev/null +++ b/core/event/management/controller/Run.cpp @@ -0,0 +1,21 @@ +#include "Run.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +} +void mad::core::Run::control() { + + auto force = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); + }); + }; + //SPDLOG_DEBUG("controller 2"); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); + } + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp new file mode 100644 index 0000000..00c03e5 --- /dev/null +++ b/core/event/management/controller/Run.hpp @@ -0,0 +1,29 @@ +#ifndef MAD_RUN_HPP +#define MAD_RUN_HPP +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Run : public Controller { + public: + enum class Direction { + Right, + Left, + }; + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + Direction dir; + + }; + +} + +#endif//MAD_RUN_HPP diff --git a/core/event/management/controller/statemachine/StateMachine.cpp b/core/event/management/controller/statemachine/StateMachine.cpp index b986148..ab5f66c 100644 --- a/core/event/management/controller/statemachine/StateMachine.cpp +++ b/core/event/management/controller/statemachine/StateMachine.cpp @@ -13,6 +13,7 @@ void mad::core::Transition::handle(const mad::core::Event &event) { if (!is_active || m_state_machine->has_made_transition) return; if (m_condition->is_triggered_by(event)) { m_state_machine->has_made_transition = true; + m_state_machine->m_previous_state_id = m_state_machine->m_current_state_id; m_state_machine->m_current_state_id = next_state; SPDLOG_DEBUG("current state {}", m_state_machine->m_current_state_id); for (auto &i : m_state_machine->m_transitions[current_state]) { @@ -41,6 +42,7 @@ mad::core::StateMachine::StateId mad::core::StateMachine::add_state(const std::s } void mad::core::StateMachine::set_initial_state(mad::core::StateMachine::StateId state_id) { m_current_state_id = state_id; + m_previous_state_id = state_id; for (auto &i : m_transitions[state_id]) { i->is_active = true; } @@ -52,3 +54,6 @@ void mad::core::StateMachine::add_transition(mad::core::StateMachine::StateId st } mad::core::StateMachine::StateMachine(std::shared_ptr m_dispatcher) : m_dispatcher(std::move(m_dispatcher)){ } +mad::core::StateMachine::StateId mad::core::StateMachine::get_previous_state_id() { + return m_previous_state_id; +} diff --git a/core/event/management/controller/statemachine/StateMachine.hpp b/core/event/management/controller/statemachine/StateMachine.hpp index 733e029..05e4791 100644 --- a/core/event/management/controller/statemachine/StateMachine.hpp +++ b/core/event/management/controller/statemachine/StateMachine.hpp @@ -21,9 +21,12 @@ namespace mad::core { void add_transition(StateId state_id_from, StateId state_id_to, std::shared_ptr transition_condition); void set_initial_state(StateId state_id); void control() override; + StateId get_previous_state_id(); + private: StateId m_current_state_id = -1; + StateId m_previous_state_id = -1; std::vector> m_states; std::vector>> m_transitions; std::shared_ptr m_dispatcher; diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 808610c..924c28b 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -1,9 +1,10 @@ #include "LevelLoaderFromFile.hpp" -#include "event/management/condition/KeyDownCondition.hpp" -#include "event/management/condition/KeyPressedCondition.hpp" -#include "event/management/condition/TimerCondition.hpp" -#include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/statemachine/StateMachine.hpp" +#include <../../game/mobs/hero/Hero.hpp> +#include +#include +#include +#include +#include #include @@ -19,7 +20,7 @@ namespace mad::core { std::unique_ptr LevelLoaderFromFile::load(std::shared_ptr global_dispatcher, std::shared_ptr system_listener) { - auto level_dispatcher = std::make_shared(); + level_dispatcher = std::make_shared(); auto world = std::make_shared(*level_dispatcher); @@ -27,17 +28,22 @@ namespace mad::core { m_config_json["camera"]["position"]["y"]}; auto camera = std::make_shared(camera_position, world); + controllers = {std::make_shared( + camera)}; + + Entity::Id hero_id = create_world(world); camera->turn_on(*level_dispatcher, hero_id); level_dispatcher->registry(camera); - level_dispatcher->registry(std::make_shared(world, hero_id)); + //level_dispatcher->registry(std::make_shared(world, hero_id)); + /* std::vector> controllers { std::make_shared(camera) };*/ - ///State Machine + /*///State Machine struct C1 : mad::core::Controller { void control() override { //SPDLOG_DEBUG("controller 1"); @@ -57,7 +63,7 @@ namespace mad::core { machine->set_initial_state(0); std::vector> controllers{machine, std::make_shared( - camera)}; + camera)};*/ auto level_runner = std::make_unique( system_listener, @@ -66,8 +72,7 @@ namespace mad::core { global_dispatcher, level_dispatcher, world, - controllers - ); + controllers); level_dispatcher->registry(std::make_shared(*level_runner)); level_dispatcher->registry(std::make_shared(*level_runner)); @@ -82,7 +87,7 @@ namespace mad::core { Entity::Id hero_id = 0; std::string map_line; while (std::getline(m_level_map, map_line)) { - for (char object: map_line) { + for (char object : map_line) { switch (m_objects[object]) { case Objects::UnstableBlock: { create_block(world, @@ -99,9 +104,8 @@ namespace mad::core { break; } case Objects::Hero: { - hero_id = create_hero(world, - {current_position_x, - current_position_y}); + Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); + hero_id = hero.get_hero_id(); break; } case Objects::Enemy1: { @@ -137,16 +141,14 @@ namespace mad::core { {{ImageStorage::TypeAction::Idle, std::make_shared(source, block_size, block_size, - StaticImage::TransformType::Tile) - }})); + StaticImage::TransformType::Tile)}})); Entity::Id square_id = world->create_physical_entity( 0, position, 0, image_storage, - is_stable - ); + is_stable); } Entity::Id LevelLoaderFromFile::create_hero(std::shared_ptr world, Vec2d position) { @@ -160,37 +162,32 @@ namespace mad::core { image_storage = std::make_shared( std::unordered_map>( {{ImageStorage::TypeAction::Idle, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], - m_config_json["hero"]["animated"]["actions"]["idle"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"]) - }, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], + m_config_json["hero"]["animated"]["actions"]["idle"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"])}, {ImageStorage::TypeAction::Run, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], - m_config_json["hero"]["animated"]["actions"]["run"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) - }} - ) - ); + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], + m_config_json["hero"]["animated"]["actions"]["run"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"])}})); hero_id = world->create_physical_entity( 0, position, 0, image_storage, - false, false - ); + false, false); return hero_id; } -} \ No newline at end of file +}// namespace mad::core \ No newline at end of file diff --git a/core/loader/LevelLoaderFromFile.hpp b/core/loader/LevelLoaderFromFile.hpp index e12e665..46d2f52 100644 --- a/core/loader/LevelLoaderFromFile.hpp +++ b/core/loader/LevelLoaderFromFile.hpp @@ -115,6 +115,10 @@ namespace mad::core { std::ifstream m_level_map; + std::vector> controllers; + + std::shared_ptr level_dispatcher; + std::unordered_map m_objects = { {'.', Objects::Empty}, {'#', Objects::StableBlock}, diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp new file mode 100644 index 0000000..8407ce7 --- /dev/null +++ b/game/mobs/hero/Hero.cpp @@ -0,0 +1,86 @@ +#include "Hero.hpp" +#include "event/management/condition/KeyDownCondition.hpp" +#include "event/management/condition/KeyPressedCondition.hpp" +#include "event/management/condition/KeyReleasedCondition.hpp" +#include "event/management/condition/LastStateCondition.hpp" +#include "event/management/condition/TimerCondition.hpp" +#include "event/management/condition/TrueCondition.hpp" +#include "event/management/controller/Idle.hpp" +#include "event/management/controller/Jump.hpp" +#include "event/management/controller/Run.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" +mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ + std::filesystem::path source(m_config_json["animated_resources"]); + source /= m_config_json["hero"]["source"]; + + std::shared_ptr image_storage; + + image_storage = std::make_shared( + std::unordered_map>( + {{ImageStorage::TypeAction::Idle, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], + m_config_json["hero"]["animated"]["actions"]["idle"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"]) + }, + {ImageStorage::TypeAction::Run, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], + m_config_json["hero"]["animated"]["actions"]["run"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }} + ) + ); + + hero_id = world->create_physical_entity( + 0, + position, + 0, + image_storage, + false, false + ); + + + ///State Machine + struct C1 : mad::core::Controller { + void control() override { + //SPDLOG_DEBUG("controller 1"); + }; + }; + struct C2 : mad::core::Controller { + void control() override { + //SPDLOG_DEBUG("controller 2"); + }; + }; + auto machine = std::make_shared( + std::shared_ptr(level_dispatcher)); + machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(2, 0, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(1, 2, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(2, 1, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(3, 0, std::make_shared(machine, 0)); + machine->add_transition(3, 1, std::make_shared(machine, 1)); + machine->add_transition(3, 2, std::make_shared(machine, 2)); + machine->set_initial_state(0); + controllers.push_back(machine); +} +mad::core::Entity::Id mad::core::Hero::get_hero_id() const { + return hero_id; +} diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp new file mode 100644 index 0000000..d8795df --- /dev/null +++ b/game/mobs/hero/Hero.hpp @@ -0,0 +1,23 @@ +#ifndef MAD_HERO_HPP +#define MAD_HERO_HPP + +#include "loader/LevelLoaderFromFile.hpp" +#include "world/LocalWorld.hpp" +#include +#include "world/entity/PhysicalEntity.hpp" +#include +namespace mad::core { + class Hero { + public: + Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers); + Entity::Id get_hero_id() const; + + private: + std::shared_ptr m_world; + Entity::Id hero_id; + std::shared_ptr level_dispatcher; + int last_pressed_key; + }; +}// namespace mad::core + +#endif//MAD_HERO_HPP From b36e8f9d015964fd72939c5db1bc13d61223849b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 22:04:45 +0300 Subject: [PATCH 02/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 6 ++++-- core/event/management/controller/Idle.hpp | 7 +++++-- core/event/management/controller/Run.cpp | 6 +++++- core/event/management/controller/Run.hpp | 6 +++--- core/world/LocalWorld.cpp | 3 +++ core/world/LocalWorld.hpp | 2 ++ game/mobs/hero/Hero.cpp | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp index f3ef8dd..282c2ba 100644 --- a/core/event/management/controller/Idle.cpp +++ b/core/event/management/controller/Idle.cpp @@ -1,6 +1,8 @@ #include "Idle.hpp" -mad::core::Idle::Idle() { +mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } -void mad::core::Idle::control() { +void mad::core::Idle::control() { + m_entity->set_action(ImageStorage::TypeAction::Idle); } diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp index e7ea1ff..fa94200 100644 --- a/core/event/management/controller/Idle.hpp +++ b/core/event/management/controller/Idle.hpp @@ -1,17 +1,20 @@ #ifndef MAD_IDLE_HPP #define MAD_IDLE_HPP #include "Controller.hpp" +#include "world/LocalWorld.hpp" namespace mad::core { class Idle : public Controller { public: - explicit Idle(); + explicit Idle(std::shared_ptr world, Entity::Id entity_id); void control() override; private: - + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity* m_entity; }; } diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp index 3fe6107..c8cfd7b 100644 --- a/core/event/management/controller/Run.cpp +++ b/core/event/management/controller/Run.cpp @@ -1,6 +1,8 @@ #include "Run.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +#include +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } void mad::core::Run::control() { @@ -11,6 +13,7 @@ void mad::core::Run::control() { }); }; //SPDLOG_DEBUG("controller 2"); + m_entity->set_action(ImageStorage::TypeAction::Run); if(dir == Direction::Right){ m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); } @@ -18,4 +21,5 @@ void mad::core::Run::control() { m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); } + } diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp index 00c03e5..07ed05c 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Run.hpp @@ -12,15 +12,15 @@ namespace mad::core { Right, Left, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); void control() override; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id m_entity_id; - std::shared_ptr key; Direction dir; + PhysicalEntity* m_entity; }; diff --git a/core/world/LocalWorld.cpp b/core/world/LocalWorld.cpp index b65987c..d104bdc 100644 --- a/core/world/LocalWorld.cpp +++ b/core/world/LocalWorld.cpp @@ -93,3 +93,6 @@ mad::core::Entity::Id mad::core::LocalWorld::create_physical_entity(int z_ind, m mad::core::Entity &mad::core::LocalWorld::get_entity(mad::core::Entity::Id id) noexcept { return m_storage.get_entity(id); } +mad::core::EntityStorage &mad::core::LocalWorld::get_storage() { + return m_storage; +} diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 14c38a8..4f4d4c6 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -34,6 +34,8 @@ namespace mad::core { Entity::Id create_physical_entity(int z_ind, Vec2d initial_position, float initial_rotation, std::shared_ptr image_storage, bool is_fixed = false, bool is_rotated = true) override; + EntityStorage& get_storage(); + private: std::shared_ptr>> m_step_events_queue; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 8407ce7..379854a 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -62,7 +62,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); machine->add_state(std::make_shared(world, hero_id)); From d9bd2dc635b5c26f6d87b2f73f2e304dd291cead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:01:08 +0300 Subject: [PATCH 03/44] set animations in statemachine --- core/CMakeLists.txt | 2 +- core/event/management/controller/Fall.cpp | 6 ++ core/event/management/controller/Fall.hpp | 17 +++ core/event/management/controller/FlyUp.cpp | 6 ++ core/event/management/controller/FlyUp.hpp | 18 ++++ .../management/controller/GroundMovement.cpp | 7 ++ .../management/controller/GroundMovement.hpp | 17 +++ core/event/management/controller/Idle.cpp | 8 -- core/event/management/controller/Idle.hpp | 23 ---- .../controller/{Jump.cpp => JumpImpulse.cpp} | 8 +- .../controller/{Jump.hpp => JumpImpulse.hpp} | 10 +- core/event/management/controller/Movement.cpp | 27 +++++ .../controller/{Run.hpp => Movement.hpp} | 18 ++-- core/event/management/controller/Run.cpp | 25 ----- .../event/management/controller/StartJump.cpp | 6 ++ .../event/management/controller/StartJump.hpp | 17 +++ core/visual/image/storage/ImageStorage.hpp | 5 +- core/world/LocalWorld.cpp | 3 + core/world/LocalWorld.hpp | 2 +- core/world/entity/PhysicalEntity.cpp | 10 +- core/world/entity/PhysicalEntity.hpp | 1 + game/mobs/hero/Hero.cpp | 98 ++++++++++++++++-- game/mobs/hero/Hero.hpp | 1 + .../hero/hero_fall/adventurer-fall-00.png | Bin 0 -> 1004 bytes .../hero/hero_fall/adventurer-fall-01.png | Bin 0 -> 999 bytes .../hero/hero_fly_up/adventurer-jump-03.png | Bin 0 -> 1019 bytes .../hero/hero_idle/adventurer-idle-00.png | Bin 0 -> 1134 bytes .../hero/hero_idle/adventurer-idle-01.png | Bin 0 -> 1127 bytes .../hero/hero_idle/adventurer-idle-02.png | Bin 0 -> 1206 bytes .../hero/hero_idle/adventurer-idle-03.png | Bin 0 -> 1110 bytes .../hero/hero_jump/adventurer-jump-00.png | Bin 0 -> 1095 bytes .../hero/hero_jump/adventurer-jump-01.png | Bin 0 -> 1049 bytes .../hero/hero_jump/adventurer-jump-02.png | Bin 0 -> 1094 bytes .../hero/hero_jump/adventurer-jump-03.png | Bin 0 -> 1019 bytes .../hero/hero_run/adventurer-run-00.png | Bin 0 -> 1073 bytes .../hero/hero_run/adventurer-run-01.png | Bin 0 -> 1043 bytes .../hero/hero_run/adventurer-run-02.png | Bin 0 -> 963 bytes .../hero/hero_run/adventurer-run-03.png | Bin 0 -> 1140 bytes .../hero/hero_run/adventurer-run-04.png | Bin 0 -> 1075 bytes .../hero/hero_run/adventurer-run-05.png | Bin 0 -> 859 bytes game/resources/levels/level_01/config.json | 54 +++++++--- game/resources/levels/level_01/map | 2 +- 42 files changed, 292 insertions(+), 99 deletions(-) create mode 100644 core/event/management/controller/Fall.cpp create mode 100644 core/event/management/controller/Fall.hpp create mode 100644 core/event/management/controller/FlyUp.cpp create mode 100644 core/event/management/controller/FlyUp.hpp create mode 100644 core/event/management/controller/GroundMovement.cpp create mode 100644 core/event/management/controller/GroundMovement.hpp delete mode 100644 core/event/management/controller/Idle.cpp delete mode 100644 core/event/management/controller/Idle.hpp rename core/event/management/controller/{Jump.cpp => JumpImpulse.cpp} (65%) rename core/event/management/controller/{Jump.hpp => JumpImpulse.hpp} (57%) create mode 100644 core/event/management/controller/Movement.cpp rename core/event/management/controller/{Run.hpp => Movement.hpp} (50%) delete mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/StartJump.cpp create mode 100644 core/event/management/controller/StartJump.hpp create mode 100644 game/resources/animated/hero/hero_fall/adventurer-fall-00.png create mode 100644 game/resources/animated/hero/hero_fall/adventurer-fall-01.png create mode 100644 game/resources/animated/hero/hero_fly_up/adventurer-jump-03.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-00.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-01.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-02.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-03.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-00.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-01.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-02.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-03.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-00.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-01.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-02.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-03.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-04.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-05.png diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index a8995e7..e5e0a8a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Fall.cpp b/core/event/management/controller/Fall.cpp new file mode 100644 index 0000000..ed817e6 --- /dev/null +++ b/core/event/management/controller/Fall.cpp @@ -0,0 +1,6 @@ +#include "Fall.hpp" + +mad::core::Fall::Fall(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Fall; + Idle_animation = ImageStorage::TypeAction::Fall; +} diff --git a/core/event/management/controller/Fall.hpp b/core/event/management/controller/Fall.hpp new file mode 100644 index 0000000..4e8274d --- /dev/null +++ b/core/event/management/controller/Fall.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_FALL_HPP +#define MAD_FALL_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Fall : public Movement { + public: + Fall(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_FALL_HPP diff --git a/core/event/management/controller/FlyUp.cpp b/core/event/management/controller/FlyUp.cpp new file mode 100644 index 0000000..969d7e2 --- /dev/null +++ b/core/event/management/controller/FlyUp.cpp @@ -0,0 +1,6 @@ +#include "FlyUp.hpp" + +mad::core::FlyUp::FlyUp(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Fly_up; + Idle_animation = ImageStorage::TypeAction::Fly_up; +} diff --git a/core/event/management/controller/FlyUp.hpp b/core/event/management/controller/FlyUp.hpp new file mode 100644 index 0000000..e87bc4a --- /dev/null +++ b/core/event/management/controller/FlyUp.hpp @@ -0,0 +1,18 @@ +#ifndef MAD_FLYUP_HPP +#define MAD_FLYUP_HPP + + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class FlyUp : public Movement { + public: + FlyUp(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_FLYUP_HPP diff --git a/core/event/management/controller/GroundMovement.cpp b/core/event/management/controller/GroundMovement.cpp new file mode 100644 index 0000000..b8e127e --- /dev/null +++ b/core/event/management/controller/GroundMovement.cpp @@ -0,0 +1,7 @@ + +#include "GroundMovement.hpp" + +mad::core::GroundMovement::GroundMovement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Run; + Idle_animation = ImageStorage::TypeAction::Idle; +} diff --git a/core/event/management/controller/GroundMovement.hpp b/core/event/management/controller/GroundMovement.hpp new file mode 100644 index 0000000..339fe34 --- /dev/null +++ b/core/event/management/controller/GroundMovement.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_GROUNDMOVEMENT_HPP +#define MAD_GROUNDMOVEMENT_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class GroundMovement : public Movement { + public: + GroundMovement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_GROUNDMOVEMENT_HPP diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp deleted file mode 100644 index 282c2ba..0000000 --- a/core/event/management/controller/Idle.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Idle.hpp" -mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} - -void mad::core::Idle::control() { - m_entity->set_action(ImageStorage::TypeAction::Idle); -} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp deleted file mode 100644 index fa94200..0000000 --- a/core/event/management/controller/Idle.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAD_IDLE_HPP -#define MAD_IDLE_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" - -namespace mad::core { - - class Idle : public Controller { - public: - explicit Idle(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - PhysicalEntity* m_entity; - }; - -} - - -#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/JumpImpulse.cpp similarity index 65% rename from core/event/management/controller/Jump.cpp rename to core/event/management/controller/JumpImpulse.cpp index 9e5dd5a..6ffc28d 100644 --- a/core/event/management/controller/Jump.cpp +++ b/core/event/management/controller/JumpImpulse.cpp @@ -1,8 +1,8 @@ -#include "Jump.hpp" +#include "JumpImpulse.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +mad::core::JumpImpulse::JumpImpulse(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { } -void mad::core::Jump::control() { +void mad::core::JumpImpulse::control() { auto impulse = [](mad::core::Vec2d dir) { return mad::core::LambdaIntent( @@ -11,5 +11,5 @@ void mad::core::Jump::control() { }); }; - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -2000000.0f})); } diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/JumpImpulse.hpp similarity index 57% rename from core/event/management/controller/Jump.hpp rename to core/event/management/controller/JumpImpulse.hpp index 25d5cf1..5e69a29 100644 --- a/core/event/management/controller/Jump.hpp +++ b/core/event/management/controller/JumpImpulse.hpp @@ -1,15 +1,15 @@ -#ifndef MAD_JUMP_HPP -#define MAD_JUMP_HPP +#ifndef MAD_JUMPIMPULSE_HPP +#define MAD_JUMPIMPULSE_HPP #include "Controller.hpp" #include "world/LocalWorld.hpp" #include "world/World.hpp" namespace mad::core { - class Jump : public Controller { + class JumpImpulse : public Controller { public: - explicit Jump(std::shared_ptr world, Entity::Id entity_id); + explicit JumpImpulse(std::shared_ptr world, Entity::Id entity_id); void control() override; @@ -22,4 +22,4 @@ namespace mad::core { } -#endif//MAD_JUMP_HPP +#endif//MAD_JUMPIMPULSE_HPP diff --git a/core/event/management/controller/Movement.cpp b/core/event/management/controller/Movement.cpp new file mode 100644 index 0000000..a580c78 --- /dev/null +++ b/core/event/management/controller/Movement.cpp @@ -0,0 +1,27 @@ +#include "Movement.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Movement::Movement(std::shared_ptr world, Entity::Id entity_id, mad::core::Movement::Direction dir, float velocity) : m_world(world), m_entity_id(entity_id), dir(dir), velocity(velocity){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); +} +void mad::core::Movement::control() { + auto set_horizontal_velocity = [](float vel) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).set_linear_horizontal_velocity(vel, event_dispatcher); + }); + }; + if(dir == Direction::Right || dir == Direction::Left){ + m_entity->set_action(Move_animation); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(velocity)); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(-velocity)); + } + } + else if(dir == Direction::Idle){ + m_entity->set_action(Idle_animation); + } + + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Movement.hpp similarity index 50% rename from core/event/management/controller/Run.hpp rename to core/event/management/controller/Movement.hpp index 07ed05c..2bac02d 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Movement.hpp @@ -1,18 +1,21 @@ -#ifndef MAD_RUN_HPP -#define MAD_RUN_HPP +#ifndef MAD_MOVEMENT_HPP +#define MAD_MOVEMENT_HPP + + #include "Controller.hpp" #include "world/LocalWorld.hpp" #include "world/World.hpp" namespace mad::core { - class Run : public Controller { + class Movement : public Controller { public: enum class Direction { Right, Left, + Idle, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Movement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); void control() override; @@ -21,9 +24,12 @@ namespace mad::core { Entity::Id m_entity_id; Direction dir; PhysicalEntity* m_entity; - + float velocity; + protected: + ImageStorage::TypeAction Move_animation; + ImageStorage::TypeAction Idle_animation; }; } -#endif//MAD_RUN_HPP +#endif//MAD_MOVEMENT_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp deleted file mode 100644 index c8cfd7b..0000000 --- a/core/event/management/controller/Run.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Run.hpp" -#include "world/intent/LambdaIntent.hpp" -#include -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} -void mad::core::Run::control() { - - auto force = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); - }); - }; - //SPDLOG_DEBUG("controller 2"); - m_entity->set_action(ImageStorage::TypeAction::Run); - if(dir == Direction::Right){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); - } - else if(dir == Direction::Left){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); - } - - -} diff --git a/core/event/management/controller/StartJump.cpp b/core/event/management/controller/StartJump.cpp new file mode 100644 index 0000000..c124a52 --- /dev/null +++ b/core/event/management/controller/StartJump.cpp @@ -0,0 +1,6 @@ +#include "StartJump.hpp" + +mad::core::StartJump::StartJump(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Jump; + Idle_animation = ImageStorage::TypeAction::Jump; +} diff --git a/core/event/management/controller/StartJump.hpp b/core/event/management/controller/StartJump.hpp new file mode 100644 index 0000000..ea4df13 --- /dev/null +++ b/core/event/management/controller/StartJump.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_STARTJUMP_HPP +#define MAD_STARTJUMP_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class StartJump : public Movement { + public: + StartJump(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_STARTJUMP_HPP diff --git a/core/visual/image/storage/ImageStorage.hpp b/core/visual/image/storage/ImageStorage.hpp index 5699096..d866bd0 100644 --- a/core/visual/image/storage/ImageStorage.hpp +++ b/core/visual/image/storage/ImageStorage.hpp @@ -13,7 +13,10 @@ namespace mad::core { enum class TypeAction { Idle, Run, - Attack + Attack, + Jump, + Fly_up, + Fall, }; explicit ImageStorage(std::unordered_map> actions); diff --git a/core/world/LocalWorld.cpp b/core/world/LocalWorld.cpp index d104bdc..efa14c6 100644 --- a/core/world/LocalWorld.cpp +++ b/core/world/LocalWorld.cpp @@ -54,6 +54,9 @@ void mad::core::LocalWorld::produce(mad::core::EventDispatcher &dispatcher) { for (Entity::Id entity_id : m_storage.extract(TrueFilter())) { if (auto physical_entity = cast_to_or_null(m_storage.get_entity(entity_id)); physical_entity != nullptr) { physical_entity->synchronize_position_with_viewable(); + if(abs(physical_entity->get_linear_velocity().get_y()) > 0.01){ + //SPDLOG_DEBUG("vel {}", physical_entity->get_linear_velocity().get_y()); + } } } diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 4f4d4c6..4cb88c3 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -22,7 +22,7 @@ namespace mad::core { class LocalWorld : public World { public: - explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 30.0f}); + explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 60.0f}); bool manipulate(const Filter &filter, const Intent &intent) override; diff --git a/core/world/entity/PhysicalEntity.cpp b/core/world/entity/PhysicalEntity.cpp index 9b58177..6f94482 100644 --- a/core/world/entity/PhysicalEntity.cpp +++ b/core/world/entity/PhysicalEntity.cpp @@ -37,8 +37,10 @@ mad::core::PhysicalEntity::PhysicalEntity(std::int32_t id, int z_ind, Vec2d init b2FixtureDef fixtureDef; fixtureDef.shape = &dynamicBox; fixtureDef.density = 1.0f; - fixtureDef.friction = 0.3f; - fixtureDef.restitution = 0.2f; + fixtureDef.friction = 0.0f; + fixtureDef.restitution = 0.0f; + body->SetLinearDamping(0.0000000001); + body->SetAngularDamping(0); body->CreateFixture(&fixtureDef); body->SetTransform(body->GetPosition(), initial_rotation); @@ -69,6 +71,10 @@ void mad::core::PhysicalEntity::apply_force_to_center(mad::core::Vec2d force, ma void mad::core::PhysicalEntity::set_linear_velocity(mad::core::Vec2d velocity, mad::core::EventDispatcher &dispatcher) { body->SetLinearVelocity(velocity); } +void mad::core::PhysicalEntity::set_linear_horizontal_velocity(float velocity, mad::core::EventDispatcher &dispatcher) { + body->SetLinearVelocity({velocity, body->GetLinearVelocity().y}); +} + void mad::core::PhysicalEntity::apply_angular_impulse(float impulse, mad::core::EventDispatcher &dispatcher, bool awake) { body->ApplyAngularImpulse(impulse, awake); } diff --git a/core/world/entity/PhysicalEntity.hpp b/core/world/entity/PhysicalEntity.hpp index fff81c2..6c3e0fd 100644 --- a/core/world/entity/PhysicalEntity.hpp +++ b/core/world/entity/PhysicalEntity.hpp @@ -45,6 +45,7 @@ namespace mad::core { void apply_angular_impulse(float impulse, EventDispatcher &dispatcher, bool awake = true); void apply_torque(float torque, EventDispatcher &dispatcher, bool awake = true); void set_linear_velocity(Vec2d velocity, EventDispatcher &dispatcher); + void set_linear_horizontal_velocity(float velocity, EventDispatcher &dispatcher); void set_angular_velocity(float velocity, EventDispatcher &dispatcher); void set_linear_damping(float linear_damping, EventDispatcher &dispatcher); void set_angular_damping(float angular_damping, EventDispatcher &dispatcher); diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 379854a..dcee27d 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,9 +5,12 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Idle.hpp" -#include "event/management/controller/Jump.hpp" -#include "event/management/controller/Run.hpp" +#include "event/management/controller/Fall.hpp" +#include "event/management/controller/FlyUp.hpp" +#include "event/management/controller/GroundMovement.hpp" +#include "event/management/controller/JumpImpulse.hpp" +#include "event/management/controller/Movement.hpp" +#include "event/management/controller/StartJump.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -36,6 +39,36 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }, + {ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fly_up, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fall, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -62,10 +95,21 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -75,9 +119,43 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(3, 0, std::make_shared(machine, 0)); - machine->add_transition(3, 1, std::make_shared(machine, 1)); - machine->add_transition(3, 2, std::make_shared(machine, 2)); + + machine->add_transition(3, 5, std::make_shared()); + machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); + + float t = 1; + + machine->add_transition(4, 8, std::make_shared(t)); + machine->add_transition(5, 8, std::make_shared(t)); + machine->add_transition(6, 8, std::make_shared(t)); + + machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(7, 11, std::make_shared(t)); + machine->add_transition(8, 11, std::make_shared(t)); + machine->add_transition(9, 11, std::make_shared(t)); + + machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(10, 0, std::make_shared(t)); + machine->add_transition(11, 0, std::make_shared(t)); + machine->add_transition(12, 0, std::make_shared(t)); + + + + + + + machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index d8795df..70c3953 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,6 +17,7 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; + float horizontal_velocity = 81; }; }// namespace mad::core diff --git a/game/resources/animated/hero/hero_fall/adventurer-fall-00.png b/game/resources/animated/hero/hero_fall/adventurer-fall-00.png new file mode 100644 index 0000000000000000000000000000000000000000..3a4b30fb90d8d77f591fa2c00b728f6fdcaa5c5b GIT binary patch literal 1004 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 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-00.png b/game/resources/animated/hero/hero_idle/adventurer-idle-00.png new file mode 100644 index 0000000000000000000000000000000000000000..3bd528e863cf02b31c7cd6cc923034015a745f60 GIT binary patch literal 1134 zcmV-!1d;oRP)XYxd z%)~`q3?`ZwGQ&ccn#forX7!Td>ckZaLiyKW|4~Z0K3wjV%Cb%FX*7mUa?{h_J?H#> z-*e9IoO5BDZMNBFn|}eR7@dB2<}{55_p2LisYFsLmv;d0=u2-2_gN~uMotB8iwUFd#mtzN=4xA) zAxbo+g>+vGbF8_FbMFNJ_`}`Dp+!`H!Qd#nZ=9zuAmR2Mp)Vj&_4x7sX0ihuZma}A z$(*4MShLx9a6Utg)5*Zu9{kVxwD+HkajLRTeXR(|E^Pb#ampt>J@mb*^nS`@JPv@r zvJTJ$6dThc6Yl6_IuWN@cB;yJgmB;qrsra`{xV_+dU9X0QUB|k*GWC~jN$u@w_i0I z0w8Ecs%59TAwYu~rxVbE*QvGJ`B^IpJx@#}d$^;Mh4kjLVR2!C$#|T)4=w|mApNPm z@Ey~0F#s~zWi##z*z$~oJ36_YP4R$3E|`tbjbV=d8ezxl?-Eq{nQ|luS+!(uKm8m* zrJuzG?FMkL@u&a^8e0|;OW(%h*rh7-5ddS90hacZLeD#!+Du(|lL~to;NkgK-e)E{ z#_-Km9@%Gpg>Sis<<%9G`3RHoI4wOt&;kUNexl)!#L(yJQYN<^G*r1gTBAvA_iF3t z0${h-CoE64oFhvs={wrJ2O9pWlgSaX`l!~0+!^(5FYgyK$$rlOLRKFS*ZTpec6$g} zeWZ`QfI~V=Q0X_}dNZbWE&ZGTjKF52zfoZ?GnUo#T+Dc?+#YfR-9#oX6|@n7kaI*2 z=t|Fds=Rw~W^w>DFh<4t4h7m$1IP_@OIPeQs@_HfTNbjAOiHXTuh>sPW7nFE-ogod zF{iJ*m4bGs+!B*n73>)8MIik0cH;PBL{h7&EXyPkg@>hXt1B;+dIyGt`W61oK9es+ zmhBr&`e3P`iJ8geM7uTrJ@R*ItoNSe`>FF!5iVq}O{LwI*Apm$kezE;wPO9&yT4pw z%XzUgBwWZ+JkEGBMfxruP2h($07*qoM6N<$f|lkf AqW}N^ literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-01.png b/game/resources/animated/hero/hero_idle/adventurer-idle-01.png new file mode 100644 index 0000000000000000000000000000000000000000..230c1cb30f47fc1ae3db9e1f34429b345a4926dd GIT binary patch literal 1127 zcmV-t1ep7YP)ESc;_C9 zN~YPOF@}(l7a8lA02vurp5=gLRm^pN?Vjl0Cv3cj&Psl!Yu-+WQxzf z_?nL9Z2+i?D%)EE8o+#ft|W(Nn#kTxpH?ATq)a-;z~v|a*Qal20iTyEp=)$BZ$oh^ zj1GrUoC<(O2{NI~tbv+3nM^vTRmc|hcKQGa_`JqlT~rO-!m((WCbE*wNjjP4hwOaW z`!M0?l(8O;PH`o4%@~&oris{O3vR_G0kkyPH9*^ysvsPlLUAe_{4B^|R}USJx*6>1 zF-VDqkX$|AyPMXgYHesF!cF&i=8iqZWOe?G-hAU=k#79NRT}y}7XFS1samZ~)c}Ok zhw!hVQqWL)cSsAncVOXtrc#(FG~FvdPv=EukP7`~6b zdql(|h>M6$0-)AiL(H{;|HBIac&e(5%Xj)aeT#N`OaBZ)i0A|gQQ3WzQ1~LFc9j8_ zg8`R=-(G%=Q1~J<@mT=UnH3T40f8-wPGwg@4HS`Zx_mfYzM_5m4ZrG0z? zfTgh1yHZtwlV`YzKENoH5Ld90WHhmRW%xKx)vpNQ-!ibUMA zljWT+0T2pbH0!zurioNqZGWgf5!r)ddKIV3N9}qvAYaY0-+X{wYAsY3QoT$Q3C~Xy z%`0DjPikit>SY!eqRhl+i!Ok%Q+xiMEedR;%G}hiWYbvy8i?Uo*eC!?>+-@q&4JxQ z{0kwXlepA(lDoY3QU#oe>lt&aNcVZSL@c8b={src5dqUgVu=K)A3{dj%uQYAQd~n( z6jZhNM@mr?&cs#xTgs`-S1Vy(cj3AENarrBR;vc+M06jTq9_1lvso#4`Fo*$h4orG ztX8WKoxcm=L_D^?4suPIn6G&ugcI@KvBthyE2^rp)w+?oTdhc{s`7*_iMKq<+s}#X zv!Db-?6*=HK%2bGefBa&hJuU?1#wCl+T>*boMkzoEj*Nfh@+|sfPmLSt!=}+(~=YI zstCe~=vd8Wr5eYbMY0M@nKYS9mBe33h%6-%BvQ+~`pE@DcIw+vGPyNlzLFCgA>l-p t5(y@gDVG1_?{6}h!e+4ue^34w_#H}Ld7*XQd&mF)002ovPDHLkV1mdw8z%q& literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-02.png b/game/resources/animated/hero/hero_idle/adventurer-idle-02.png new file mode 100644 index 0000000000000000000000000000000000000000..2668b590bc2ab2ffead9465e8f2538ae88cd34c8 GIT binary patch literal 1206 zcmV;n1WEgeP)t%mk;?vU!GyH0*Y1*|JHBF2?Ep!3V(Y$=@}%tAyU6o77fqMR6#M z-0+|{6abAhR6>SP1BIJqqKk1YTQMmjn21F-;Z!UVKy{^61GE<+*?4>tC=P|AUk}h%cZAyKo%Gcm z(MgGhkXpUiR?m*g0`2;+mwV2OOt-wmc){8poqX?Tl5X%+KNTIH3-1vjr`C?j0suUV z$0)rodwgb<{pHmJPxZsgrnUL6e#Ko-`lmLGLdebp`wr1|(M?6~cbd0$4^zPaW&PLm z`Tgb9`uM`=4I-~J>b_5W^sa~y#AIad6Dy6}(mHGR08r#Cq}XoP=P!)j(8n%W=I6Dc z&|}zevwNEk(^*lLB%2Bb@aHd4`spPAitTp&=Q{HvQ^5cL(dA`YPJV1O1V8{0fJW~v zEkS1FmjRsqK60B*Fyy(+h*hOK-$r-7jk|BX!;t4PbF)6Cf&sF#vb3jPe3gOG6~i$Y zDlKo*VZyN`a?KWCEfWp1^Nd&_+v85c zXJP~97h`zkVzzC07JwDMzD!%br$||w)WjRI;j9?SNTD@Pdsvoxyj6l!5&)Uiudz_` zCZ(Vu`5W8|30E;DG199bLsI)vYWB5ZMO4kK6J@Fg6 z2tb+4+^jEUjT0F2ou|}wfU6zt0Q%Digj|RT5?4Fgd936K?29n~D)3{Q4d{CF_vNuG zr=@dpPePnhp8p1hi16rP=;E2yC;N{X_gD0Bri0&($Q*oKHS4-OJt(QjqR_f0!@ z;+YSVkXX0tilT5Q4MYrEY#tnhb%EB@*FAEL*=#oIHU+|u-@=SXzc>9Ioqr19M9Onb z?6rhZRh2yRgG}X_kyKS>uO&=LW{eLG?h@)(IFX{9EX`)Ovr}H+Noxkf*9REBK7d1t zvQu6Fz>yIba^$W@T5fg#cS$itmIvk?rg*ws0cj+%5{pTNwoOU0Y*U6b9*(5NUs{OF zheCuR3p9UuNtb=`{Rq+cs{Vf|E;d8LiOh#WjE5sEM3??jXFMFiVloNulm7+&0QQ2K U4h?yP-v9sr07*qoM6N<$f=IDF&Hw-a literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-03.png b/game/resources/animated/hero/hero_idle/adventurer-idle-03.png new file mode 100644 index 0000000000000000000000000000000000000000..53207e8a2f1ed323478a1e16c27559eff02c46ba GIT binary patch literal 1110 zcmV-c1gZOpP)BW*kqGUHreDqK&gh)Q%4Wc(RPn0?Mv$^rB>Slz@cWE!eOWhbOWU%kSjcK7uN1{}-fQQ} z6T1jSqQ-bA66IX*qS3Av6$`PcW;~ir0qE+m3qU-Owi1d&(OeowKAK>xZ;;;mJ&g4Y z8lq$)Wv`w-@i4nP++ut(%pac9EWGh3)9%6=z4G#r4Yu*)=V={!S9*;|Ikk3oxB&=d zj?#3a@2~HBJe*8Q_!|Lt(@lL;ijrIB3K^_WDaQrcilC!UKo7@>ZH=>#PVZUL)N55RCwrCh{{yq}c>prmRT<%d3NsQOI7}+H z$`*^w5HTB{XL%_?-@q|~p;2b+I$_ldK;OV1!O$qnONEQG=fTIBxV%PpOXa0nc4~+F z`|)cY>a4Y5xOIoI%F9a;dVakIJ5&IYnVcb{H50?3TKJI$UU>6UV-7Nel;vT#zaPgP zb|QLQ)LCnJGb<^I~ZP+YC=agV*wD@zwQ*yafRP28j0k9CgVzi4Qia1mY$xIGFq?VLYF%?tp z<}_B(>vU3_(AlAr)ccxgQZ0sIv33C1){Q4N20*=gm-yOd?DNICJr`Q&~=?U%lctbXF<_*oqe_xzM34bKG`ERu5=;w zR+9kOqponb-NfYh1e46vuxfYUac ziD~?J=z~qAO)-9yX!;Qo1F=N|uA&lbf!(FJEO1%(3%bzpVPRc_KIk1@%>I&_+?=^N zbN+MAoS6$*vSi7UB}DrKD$J1^)>(^GZCt4JQ83kG^uPM?^ETds90k@u_&!t4u=}u zY5U0dZRv5B(lhW20D8X8V80jN*a-1>Oy0}izeQO_<`Rpds92N1@r112ZWk{dc@%(9 zUnu|{cPWvX2ztH_u;N_>$}(cpawybo0-$DxT>^66-ip`fPk-a}`O}%nw5vdwkke;} zc%o(#@4rzCz@LR*;eY#MSs%0F_4(2Bb&j6xqqnJ@+PXq|o7&T&RFI>}(NIepTb{N6 zoa`QZ9%JNNe69z`8NEr^F7W>mqPa@Y>J~WiAEebS_*LYItJivz%&(+t47Ic|5i!`T zyQFt&l%d)u(_@uAR|psePi?J984je@?!v8dI`$Qa{Q9FRLQp3Jkln-m#10-#+XsK^ z<8gwNOxp+;2EgBffDejXVlKJBd#B$q9fN5hLoIDg$0HQjb@}d67n+$)og+;x?L<3I z0jv|Xgv6WD681X?ycq;s3{>sEp5!s$H=ofWcP4Cb)7c=81PhhgOP%%p2Eh246O5lZ zK{$~FV7B8pvmM8Ql;9;yAB?8*Ik#{J@6;#(!=S|FS~c#}EC7TPNd~Q3fRr$&W}&XC zK^V8k8Q`+4_Uwa{nEzZMri6s=#8=stS9#KZ3wwrr=Qa-$p&$fqvf;p60-)Gg!Iz&L zW8liyY%VM^6N>38O1dNhhQaKTh-;l6vZ=HjS0ag1vyfZ!3;>g%AP;L6X2Zj>%-u{Z zJ|WJX?^4n^P2aULJ5lh*fz+x4ll~E0q{@o^PXVX`!hi)B^##;vcQ@9fTP&F-LB@VsOQ2bl-F`DEv94J)>-t-*T*#Y;8>n;$_S>RVE(9sH-c1Y0 zvmhdo2>WeO)zhjMV$(EfOD3dq>42 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-01.png b/game/resources/animated/hero/hero_jump/adventurer-jump-01.png new file mode 100644 index 0000000000000000000000000000000000000000..b20e0343c77fa6ecb46aa2cfeccfa0f8699f6427 GIT binary patch literal 1049 zcmV+!1m^pRP)izazx1zV>AS_=w^KI)u_p$@kw8d z8Z_}?I+1`ebIQV8e1SL@rB)%5O*>i`mI9@=rF306K6KO;>(f0?+D~$mbI&>Vch2|z z&iVa*P@+VM5+zEMC{d!s{{^AS(D4qpG+PZKmCP{mZ6MeG!RZqm+`C8S&rQVQqFmbn zK+E&5DOrD;5-WhS+Da;!k!Gub;~nl?e6Y$cYPpWjx2G9fSCZsURGO5T6H6@Wh-qXgeND}8}r zZjLVyWZXNQYpXYN zp_$%3me*qJEYsvrV*>yS;Sej!*${k`5H-sd<{}XQ9)00(_QS6;I8L>Qmp_^2op;~X zyA6FpW_tTrO(nS7TrP(i8wvy%jb_o_^OTGao&hKjv&r?AcADC{Mbpu4j@+v+fa(?k zNZ-;8YTvsEfY&#M|Cb+xf9gjXlXJ5A>1@J_51wIS!_5T@q;+k*r7rgY~MT|%O%1c6w%=$Of{ zjk4|8SQ1U9nKIV{Sz$J-iMIXiB64#cFJtnKS9FQdC*;;z!MoQt2EbzQcT8L6-nY-g zLO29-zp?$1Hw8eoZ4Y05dJ^xYi&QzBdbXmwM9CF{n<6d`4p8Z;W7mdc?N%C_)r7J6 zF#s0BAsVbER-@Nst@{{>wFPnRvk@gBSa+?p8Hqwad9!~USPc3}Br?>P1<_<0CO-#Y zKM(~>z>UBKYTd__)mplY40UzMts!;OZnWAchr_bi7(EWbtLML0mJC5>W?zoS^EV^% z9)`mbP1FAIjizb*n?OD2I$9^MT!A89J<{nY#^dcA(u$rM zrAKKi%7s|0R$0Zm?6$;dyd7e%%_IPJ8`HQfh*&H}w~yB&|KhI)(S z=kKnv+myyB)?|-E5K3i~dq=sDXe5F!I7fUvB>>^H-BmC?8&BXg8`R(S{|bKrE6Hcb TLPIqs00000NkvXXu0mjfd%y9w literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-02.png b/game/resources/animated/hero/hero_jump/adventurer-jump-02.png new file mode 100644 index 0000000000000000000000000000000000000000..ba27779940e0644fb74d1bfdf8d863c973b2036d GIT binary patch literal 1094 zcmV-M1iAZ(P)9&_Hb*pLGr17@BNpIHcLz6VIq9Z$3eaQFaa_%|z ze1G5b`+d(j7b>Wrf(k154lQ`Zg1OY=G(7-If~C8q^Ti*J8+XY(D$?y9!1J5 zf5M|Xf+o2|nxC8J!%t4Iy?s-mzy01W034=W8mA>0$qB*jRfIp|Geg0(M4}S~F|!># zw1@6veDE2*(0nvC1ZWLy6FraJQ#NOnoX}Sz(Ch>t6kJ<)Y6-1m%=+HLBxa&?J^2DQ zkB8w)*|Pa85u)0vMC^)=r$#j+(TT$QNOXd;Bj-!Tc6RqN5*Z@cy4jqajg`%5iIC97 zdH@Fc?quigB_h!Yygo0_elSe9v$teya_Xu87>Nu~R~Il>&vt#V#OzH07w_(EQKL|imLx2|t`pb&Rl8hwYaG`g16x#W7Bag}WvKO9D zXdvo&lVuTlCSCTzS|S8s%dvhlGCd9tKLM-+4{-ChUjcA3*KT@f4|*mooOVaqeA0zn z=-$uFf`;Ga1z>&fL5$Ddp?Tjy0OpPzBD~=i9#2jIknpV$2L}3YnAehw_+4J}=F({1cM#WbSPG}q?KhtdfR_5@EjZPzQ0r8wb*cc2*;@J3*XzYF3@M8#t+a~0QR8r|3Qp6sRo`fuhN`M%->-@xMM&No0CSm) zsBt>Y8izxCb2N_8|=8zN{kOn~on7XZ4h|G!G>w#F9m zyRHkD&BmBZ}hywXp0V{x${B9%;Xm)|A;j+`08tteno6-d7{sy3UM%AF&ss)~SN6v{_-7K$M~ zBdKJP%X9P0XS2dE3`>JAhV+bFo}0&|REz0!hF8ygFMIk5D)_hY2che3yBE_uw*UYD M07*qoM6N<$f+g)C)c^nh literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-03.png b/game/resources/animated/hero/hero_jump/adventurer-jump-03.png new file mode 100644 index 0000000000000000000000000000000000000000..0458013c8dae7ecf137a009f0de9d2dc5fb7c074 GIT binary patch literal 1019 zcmVHJ^vVQpW(c}v>cx7okus_yS(ar3JEV;Dv^i{T*}CJ!)paNe35`SSfONF=l! zfW7aWCmQKi<8np@U@|#OD7;U}X4ATOYG%Z2X%Oj!JjvU?Z<()*PbP=)cmj$ZKEwCO zbgZ90WQm~5tDH#>bK#RtJ|3JQ?FmtyS|@kT(RcSbI!3=B?FrEp8z36#=0K~dYCWb} znYc1@oeQ6J^7;5-(w?Gf;@xf^;Nxl-P9-+XO^*CP`o^R#Zo`aB$NI?@msJx0-@G>s zZyp99=nnv}IC~9%k5(%| zgQ|^Wi_4m7RHD*^+h!)0-)J$@{$l{#TTFA$vBS`han%o-j`eRjr2tVj(s%Sl!ls8? z9zDk729a5B#A>w?A0Dk%hKi~;dwL}+9OfpLR|{pKnwQei-9=`-#B9N-StrZ#=2b~? zx$NZg`Tuuny)<;We7U8Nc4q@OAE2qmBNLi?=++(Sd^S3k&`4O#U%FF5pJ=u>7Tc)aNMsJ!I0LfnUS0%aqGb{ z%WG@GE7tgSbb{u_5^jrG>~K0r7fWJ~-MHU~n*FoC{mNd&ZfX=OYb7rJG^NG|Uw;8M p_r>7Qc&+H`sH2WL>Zs%K#Gfd5Tp^4i<(B{e002ovPDHLkV1llc@^t_J literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-00.png b/game/resources/animated/hero/hero_run/adventurer-run-00.png new file mode 100644 index 0000000000000000000000000000000000000000..e3d7cc057f4e6efed4564cae0c022f961089639c GIT binary patch literal 1073 zcmV-11kU@3P)-L~*N`~w~w_wx-vWOaAj0Tr1#<;j-qKOzD_ka(^N1x1$ z&X}lV2_{Q)VF4#B!HhU@z*x40Ez6)V7<6!9m(sy)IX>LAw!&0yZ+Wrbm)@Rp`uqOA z=llEh^b~T)A%`4t$iX_qMiZX+;2^tqRmjw_h`u0vsvm&8jUQWz>&!g0^&zql;pC6) zJX`%F0Q#&><(?`Da5p?{d1Lcz%I`np*6j&d72L-8!K(nMMJiVYh6s(`VsSAd|K;Nk z#fA!bZGVu^@-%(Xt5gNIq0j2cxzuMX*lg|-ExsH?$kr~SC)Ak_N2Quh8qsEH@Zyge1)v9?%~&S7b$(z zgDb2ub|=g$m4ZV-fv>2HLqWkcQ7F2)&s*Zk%Gd93!(jks7Ilifssy-RI{?7G-8=dI z{b2xJetZwSWbWnAcQ>hPX%I!v9kIk|tB|z>oVj5NC^^=_NT{8O;Y-Q&k6q|7#XP{7 z8v~-LzuywKtvxceI7g|sP!@aDq=523fN@PrTeo#{DU;zT$^(Jqx=dk$V4#(ATw%W^(;IwIr58P~L=fN@Qupt)7J zVa z&){|!1JJt?GzVSgOUZ*>pZuj0=e-HB!?;aTo3(>5fvnv}T2D=<^+p1T@=Bopo)kCZ zZhFslXT-N5_mQ9Po0leC*Ma4lZ`x47VEEdbS*=-l{*;_B-_4(N6HDpRT34nkj4wxdQmg3?G zuQ`7Cx4w*dv*L)7pD#BB0=!dE#14OcTC$J0T>_xg<)E#*&lVAo1tBrRNPR16%lye? zzd3gWpVJ9hIKOOfcBi7qc}+tqiYWB^Y5KM^ZNBC7?{-s~ymkki*EB{KBDfrRgtR%k r!#@Ou!00000NkvXXu0mjf3}y^* literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-01.png b/game/resources/animated/hero/hero_run/adventurer-run-01.png new file mode 100644 index 0000000000000000000000000000000000000000..96d832012e63466c4cfc2b9e5b864f7af21b1e72 GIT binary patch literal 1043 zcmV+u1nm2XP)2%@jT z9`t2H%IuT4maPSmLF4|wS~9H8Qm|=8m&G(IH~o{`n_eH%dw08vy4<7%$rmo1^SkHX z-|ut&p96K(Raaeg)m0Z_JDlG5>J!tMU()g-sDuD`sqfQ@{wcW+>&Z3v{V<(}+X2uP zG@kE>nE-!g9#mYhTLyBb_W*#IzPCcGt(Eb~DLN0gql6WHnMk076#$b8dr3nTV|^mU z+FH>TG&}E1SE4NeIn#T9VxhFjo=DCyJ~?Hl-KeG@cY98fiNDPoN1O2aJZAdd3cY$O ziR2tgSmE@yw}^M0qVtsq@vc)gR3)nFtToi#O-o=mK99_9Uy$swMq@xR!|yF~{mxyk zOuokc8`qd^D%an~AD!Ot{rPJ%;)4%AugJG+kfH8wJ6+Iqe6noDn)ceZk?9Gds>)B# z9Rgraq=n$+Apnj)+W~KS07zV%p?jc5gkRkV_g__wS<7A%e6ma`mm`(S5mi+HqN+-< zZxF^lV^5@o`AnME*WZmyPjH+L0AfvhsT2aL08-F(;ge-EmCM;S3&OHBQ*H@Msm9fE zIaEfbC)|brQ~@MkD3HnL?R->K9|4@bB34(k;ApjlY?4sVSpZU(&Jjg*8v;-TkQH6G z(@qH1$DiNdX#SBL24Fsu1|Waw9E&UE??UgEq2%E~SL3x>E4%PX5~*Cy^huH^7{;ao z^O-d7y#M7U`_+qI5d7^jQtLri0k{U~zkS=8-B7FFtY-218-a3{`a8{M((DI}xnEty zQPaJa)vW^YuYndO6JwjoEM$}Dr8OaY+^x-9vT2O3wE-|XcmaTB#|+jiOG2iB{_nLe N002ovPDHLkV1oY={2u@S literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-02.png b/game/resources/animated/hero/hero_run/adventurer-run-02.png new file mode 100644 index 0000000000000000000000000000000000000000..2e3b74df0890213dc31ab88d93038a14e31daed2 GIT binary patch literal 963 zcmV;!13dhRP) z<(}{RpYNRWoqM57nKEU{lqpl@u0xdC;is?fXM5W=nQu#|ap7<|0qB19h@pNhg@?92 zhYqv?$mLW<41M)GiFksO-<+YRqa6TsQN_E%CjsUobA|_YLs6prAH){Z65#sG4e4vz z%$2|x0InJr!BK^&$?GJO3At`3>rgTwIebl<^{cw5>h}D$5lk2IaC^1hKK{fml&NX` zUYVNKGm~#OLcwd~%idlI;Hz!cZ3{_NY_humsM(#A4YlJ8olG%bjodPG8-;0lI@&q- zfu9#Y`-DUH{=&e`J#cZ*a2y2-xut2M(rT4wCq{MK-mN?IxxV<39iD>52lo*Hyvg5~ zB*vA%7`>rE&i4qQi}Niokm(g%xN0blg16s+?ru_=CILKdw{G{NbY)*Sm!a;pZc+32K|^sAEaX^cCx9*_7hq0QzKCGR&n{-O z&-29Oc=Ot|JHGvjN{dB=qfx9C6#^g}jp~6u`~2GkLw;IQVVr&aIQ#kuZ(8QZ`&;q2 z-FVz?>@8ah8dTFOyMJQkU$x=PTaW7PU}X!>?0+E}$feWbmE#{9_G7w`!BgiXK!@*X z-8OvUD8G&=0C;cxLAA}wWAA^@@QI`JzkAqFOrZdBA36{_`W^@Yg>T6taF67vAJ={pH@W?%q$#{aRDn-pij#6yD z@;7+Nz3ouqa7oPiQL)T?#UuuA+70S{AfS@n&4fe+Rv^+Y2DKI2|md)8fP7KvDWF lSsnQ=t7}Gb2L|)5<{u@>Infw4#AN^g002ovPDHLkV1mT5)A0ZR literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-03.png b/game/resources/animated/hero/hero_run/adventurer-run-03.png new file mode 100644 index 0000000000000000000000000000000000000000..a512930ec81d583aac03630d3d9fa7e4441facf0 GIT binary patch literal 1140 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 Date: Sat, 14 May 2022 21:35:29 +0300 Subject: [PATCH 04/44] create Hero 2.0 --- core/CMakeLists.txt | 2 +- .../condition/KeyReleasedCondition.cpp | 15 ++++ .../condition/KeyReleasedCondition.hpp | 18 ++++ .../condition/LastStateCondition.cpp | 13 +++ .../condition/LastStateCondition.hpp | 20 +++++ core/event/management/controller/Idle.cpp | 6 ++ core/event/management/controller/Idle.hpp | 20 +++++ core/event/management/controller/Jump.cpp | 15 ++++ core/event/management/controller/Jump.hpp | 25 ++++++ core/event/management/controller/Run.cpp | 21 +++++ core/event/management/controller/Run.hpp | 29 +++++++ .../controller/statemachine/StateMachine.cpp | 5 ++ .../controller/statemachine/StateMachine.hpp | 3 + core/loader/LevelLoaderFromFile.cpp | 45 +++++----- core/loader/LevelLoaderFromFile.hpp | 4 + game/mobs/hero/Hero.cpp | 86 +++++++++++++++++++ game/mobs/hero/Hero.hpp | 23 +++++ 17 files changed, 327 insertions(+), 23 deletions(-) create mode 100644 core/event/management/condition/KeyReleasedCondition.cpp create mode 100644 core/event/management/condition/KeyReleasedCondition.hpp create mode 100644 core/event/management/condition/LastStateCondition.cpp create mode 100644 core/event/management/condition/LastStateCondition.hpp create mode 100644 core/event/management/controller/Idle.cpp create mode 100644 core/event/management/controller/Idle.hpp create mode 100644 core/event/management/controller/Jump.cpp create mode 100644 core/event/management/controller/Jump.hpp create mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/Run.hpp create mode 100644 game/mobs/hero/Hero.cpp create mode 100644 game/mobs/hero/Hero.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b1ae6b4..a8995e7 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/condition/KeyReleasedCondition.cpp b/core/event/management/condition/KeyReleasedCondition.cpp new file mode 100644 index 0000000..fd9df64 --- /dev/null +++ b/core/event/management/condition/KeyReleasedCondition.cpp @@ -0,0 +1,15 @@ +#include "KeyReleasedCondition.hpp" +#include +#include +std::unordered_set mad::core::KeyReleasedCondition::triggers() { + return {mad::core::Event::Type::KeyReleased}; +} +bool mad::core::KeyReleasedCondition::is_triggered_by(const mad::core::Event &event) { + const auto &keystroke = const_cast_to(event); + return keystroke.key_id == m_key_id; +} + +mad::core::KeyReleasedCondition::KeyReleasedCondition(const int m_key_id) : m_key_id(m_key_id){ +} +void mad::core::KeyReleasedCondition::on_start() { +} diff --git a/core/event/management/condition/KeyReleasedCondition.hpp b/core/event/management/condition/KeyReleasedCondition.hpp new file mode 100644 index 0000000..ec846c9 --- /dev/null +++ b/core/event/management/condition/KeyReleasedCondition.hpp @@ -0,0 +1,18 @@ +#ifndef MAD_KEYRELEASEDCONDITION_HPP +#define MAD_KEYRELEASEDCONDITION_HPP + +#include "Condition.hpp" +namespace mad::core { + struct KeyReleasedCondition : Condition { + public: + explicit KeyReleasedCondition(int m_key_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + const int m_key_id; + }; +}// namespace mad::core + +#endif//MAD_KEYRELEASEDCONDITION_HPP diff --git a/core/event/management/condition/LastStateCondition.cpp b/core/event/management/condition/LastStateCondition.cpp new file mode 100644 index 0000000..a2fb453 --- /dev/null +++ b/core/event/management/condition/LastStateCondition.cpp @@ -0,0 +1,13 @@ +#include "LastStateCondition.hpp" + +bool mad::core::LastStateCondition::is_triggered_by(const mad::core::Event &event) { + return m_to_state_id == m_machine->get_previous_state_id(); +} +std::unordered_set mad::core::LastStateCondition::triggers() { + return {mad::core::Event::Type::KeyPressed, mad::core::Event::Type::Collision, mad::core::Event::Type::KeyHeld, mad::core::Event::Type::KeyReleased, mad::core::Event::Type::LevelPause, mad::core::Event::Type::Menu, mad::core::Event::Type::Movement, mad::core::Event::Type::Runner, mad::core::Event::Type::Visual, mad::core::Event::Type::WindowClose}; +} +void mad::core::LastStateCondition::on_start() { +} +mad::core::LastStateCondition::LastStateCondition(std::shared_ptr m_machine, mad::core::StateMachine::StateId m_to_state_id) : m_machine(m_machine), m_to_state_id(m_to_state_id){ + +} diff --git a/core/event/management/condition/LastStateCondition.hpp b/core/event/management/condition/LastStateCondition.hpp new file mode 100644 index 0000000..89ec58e --- /dev/null +++ b/core/event/management/condition/LastStateCondition.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_LASTSTATECONDITION_HPP +#define MAD_LASTSTATECONDITION_HPP + +#include "Condition.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" +namespace mad::core { + struct LastStateCondition : Condition { + public: + LastStateCondition(std::shared_ptr m_machine, StateMachine::StateId m_to_state_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + std::shared_ptr m_machine; + StateMachine::StateId m_to_state_id; + }; +}// namespace mad::core + +#endif//MAD_LASTSTATECONDITION_HPP diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp new file mode 100644 index 0000000..f3ef8dd --- /dev/null +++ b/core/event/management/controller/Idle.cpp @@ -0,0 +1,6 @@ +#include "Idle.hpp" +mad::core::Idle::Idle() { +} +void mad::core::Idle::control() { + +} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp new file mode 100644 index 0000000..e7ea1ff --- /dev/null +++ b/core/event/management/controller/Idle.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_IDLE_HPP +#define MAD_IDLE_HPP +#include "Controller.hpp" + +namespace mad::core { + + class Idle : public Controller { + public: + explicit Idle(); + + void control() override; + + private: + + }; + +} + + +#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp new file mode 100644 index 0000000..9e5dd5a --- /dev/null +++ b/core/event/management/controller/Jump.cpp @@ -0,0 +1,15 @@ +#include "Jump.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +} +void mad::core::Jump::control() { + + auto impulse = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); + }); + }; + + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); +} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp new file mode 100644 index 0000000..25d5cf1 --- /dev/null +++ b/core/event/management/controller/Jump.hpp @@ -0,0 +1,25 @@ +#ifndef MAD_JUMP_HPP +#define MAD_JUMP_HPP + +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" +namespace mad::core { + + class Jump : public Controller { + public: + + explicit Jump(std::shared_ptr world, Entity::Id entity_id); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + + }; + +} + +#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp new file mode 100644 index 0000000..3fe6107 --- /dev/null +++ b/core/event/management/controller/Run.cpp @@ -0,0 +1,21 @@ +#include "Run.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +} +void mad::core::Run::control() { + + auto force = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); + }); + }; + //SPDLOG_DEBUG("controller 2"); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); + } + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp new file mode 100644 index 0000000..00c03e5 --- /dev/null +++ b/core/event/management/controller/Run.hpp @@ -0,0 +1,29 @@ +#ifndef MAD_RUN_HPP +#define MAD_RUN_HPP +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Run : public Controller { + public: + enum class Direction { + Right, + Left, + }; + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + Direction dir; + + }; + +} + +#endif//MAD_RUN_HPP diff --git a/core/event/management/controller/statemachine/StateMachine.cpp b/core/event/management/controller/statemachine/StateMachine.cpp index b986148..ab5f66c 100644 --- a/core/event/management/controller/statemachine/StateMachine.cpp +++ b/core/event/management/controller/statemachine/StateMachine.cpp @@ -13,6 +13,7 @@ void mad::core::Transition::handle(const mad::core::Event &event) { if (!is_active || m_state_machine->has_made_transition) return; if (m_condition->is_triggered_by(event)) { m_state_machine->has_made_transition = true; + m_state_machine->m_previous_state_id = m_state_machine->m_current_state_id; m_state_machine->m_current_state_id = next_state; SPDLOG_DEBUG("current state {}", m_state_machine->m_current_state_id); for (auto &i : m_state_machine->m_transitions[current_state]) { @@ -41,6 +42,7 @@ mad::core::StateMachine::StateId mad::core::StateMachine::add_state(const std::s } void mad::core::StateMachine::set_initial_state(mad::core::StateMachine::StateId state_id) { m_current_state_id = state_id; + m_previous_state_id = state_id; for (auto &i : m_transitions[state_id]) { i->is_active = true; } @@ -52,3 +54,6 @@ void mad::core::StateMachine::add_transition(mad::core::StateMachine::StateId st } mad::core::StateMachine::StateMachine(std::shared_ptr m_dispatcher) : m_dispatcher(std::move(m_dispatcher)){ } +mad::core::StateMachine::StateId mad::core::StateMachine::get_previous_state_id() { + return m_previous_state_id; +} diff --git a/core/event/management/controller/statemachine/StateMachine.hpp b/core/event/management/controller/statemachine/StateMachine.hpp index 733e029..05e4791 100644 --- a/core/event/management/controller/statemachine/StateMachine.hpp +++ b/core/event/management/controller/statemachine/StateMachine.hpp @@ -21,9 +21,12 @@ namespace mad::core { void add_transition(StateId state_id_from, StateId state_id_to, std::shared_ptr transition_condition); void set_initial_state(StateId state_id); void control() override; + StateId get_previous_state_id(); + private: StateId m_current_state_id = -1; + StateId m_previous_state_id = -1; std::vector> m_states; std::vector>> m_transitions; std::shared_ptr m_dispatcher; diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 4b19898..9276a96 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -1,9 +1,10 @@ #include "LevelLoaderFromFile.hpp" -#include "event/management/condition/KeyDownCondition.hpp" -#include "event/management/condition/KeyPressedCondition.hpp" -#include "event/management/condition/TimerCondition.hpp" -#include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/statemachine/StateMachine.hpp" +#include <../../game/mobs/hero/Hero.hpp> +#include +#include +#include +#include +#include #include @@ -18,7 +19,7 @@ namespace mad::core { std::unique_ptr LevelLoaderFromFile::load(std::shared_ptr global_dispatcher, std::shared_ptr system_listener) { - auto level_dispatcher = std::make_shared(); + level_dispatcher = std::make_shared(); auto world = std::make_shared(*level_dispatcher); @@ -26,17 +27,22 @@ namespace mad::core { m_config_json["camera"]["position"]["y"]}; auto camera = std::make_shared(camera_position, world); + controllers = {std::make_shared( + camera)}; + + Entity::Id hero_id = create_world(world); camera->turn_on(*level_dispatcher, hero_id); level_dispatcher->registry(camera); - level_dispatcher->registry(std::make_shared(world, hero_id)); + //level_dispatcher->registry(std::make_shared(world, hero_id)); + /* std::vector> controllers { std::make_shared(camera) };*/ - ///State Machine + /*///State Machine struct C1 : mad::core::Controller { void control() override { //SPDLOG_DEBUG("controller 1"); @@ -56,7 +62,7 @@ namespace mad::core { machine->set_initial_state(0); std::vector> controllers{machine, std::make_shared( - camera)}; + camera)};*/ auto level_runner = std::make_unique( system_listener, @@ -65,8 +71,7 @@ namespace mad::core { global_dispatcher, level_dispatcher, world, - controllers - ); + controllers); level_dispatcher->registry(std::make_shared(*level_runner)); level_dispatcher->registry(std::make_shared(*level_runner)); @@ -82,7 +87,7 @@ namespace mad::core { Entity::Id hero_id = 0; std::string map_line; while (std::getline(m_level_map, map_line)) { - for (char object: map_line) { + for (char object : map_line) { switch (m_objects[object]) { case Objects::UnstableBlock: { create_block(world, @@ -99,9 +104,8 @@ namespace mad::core { break; } case Objects::Hero: { - hero_id = create_hero(world, - {current_position_x, - current_position_y}); + Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); + hero_id = hero.get_hero_id(); break; } case Objects::Enemy1: { @@ -137,16 +141,14 @@ namespace mad::core { {{ImageStorage::TypeAction::Idle, std::make_shared(source, block_size, block_size, - StaticImage::TransformType::Tile) - }})); + StaticImage::TransformType::Tile)}})); Entity::Id square_id = world->create_physical_entity( 0, position, 0, image_storage, - is_stable - ); + is_stable); } Entity::Id LevelLoaderFromFile::create_hero(std::shared_ptr world, Vec2d position) { @@ -185,10 +187,9 @@ namespace mad::core { position, 0, image_storage, - false, false - ); + false, false); return hero_id; } -} \ No newline at end of file +}// namespace mad::core \ No newline at end of file diff --git a/core/loader/LevelLoaderFromFile.hpp b/core/loader/LevelLoaderFromFile.hpp index e12e665..46d2f52 100644 --- a/core/loader/LevelLoaderFromFile.hpp +++ b/core/loader/LevelLoaderFromFile.hpp @@ -115,6 +115,10 @@ namespace mad::core { std::ifstream m_level_map; + std::vector> controllers; + + std::shared_ptr level_dispatcher; + std::unordered_map m_objects = { {'.', Objects::Empty}, {'#', Objects::StableBlock}, diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp new file mode 100644 index 0000000..8407ce7 --- /dev/null +++ b/game/mobs/hero/Hero.cpp @@ -0,0 +1,86 @@ +#include "Hero.hpp" +#include "event/management/condition/KeyDownCondition.hpp" +#include "event/management/condition/KeyPressedCondition.hpp" +#include "event/management/condition/KeyReleasedCondition.hpp" +#include "event/management/condition/LastStateCondition.hpp" +#include "event/management/condition/TimerCondition.hpp" +#include "event/management/condition/TrueCondition.hpp" +#include "event/management/controller/Idle.hpp" +#include "event/management/controller/Jump.hpp" +#include "event/management/controller/Run.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" +mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ + std::filesystem::path source(m_config_json["animated_resources"]); + source /= m_config_json["hero"]["source"]; + + std::shared_ptr image_storage; + + image_storage = std::make_shared( + std::unordered_map>( + {{ImageStorage::TypeAction::Idle, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], + m_config_json["hero"]["animated"]["actions"]["idle"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"]) + }, + {ImageStorage::TypeAction::Run, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], + m_config_json["hero"]["animated"]["actions"]["run"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }} + ) + ); + + hero_id = world->create_physical_entity( + 0, + position, + 0, + image_storage, + false, false + ); + + + ///State Machine + struct C1 : mad::core::Controller { + void control() override { + //SPDLOG_DEBUG("controller 1"); + }; + }; + struct C2 : mad::core::Controller { + void control() override { + //SPDLOG_DEBUG("controller 2"); + }; + }; + auto machine = std::make_shared( + std::shared_ptr(level_dispatcher)); + machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(2, 0, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(1, 2, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(2, 1, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(3, 0, std::make_shared(machine, 0)); + machine->add_transition(3, 1, std::make_shared(machine, 1)); + machine->add_transition(3, 2, std::make_shared(machine, 2)); + machine->set_initial_state(0); + controllers.push_back(machine); +} +mad::core::Entity::Id mad::core::Hero::get_hero_id() const { + return hero_id; +} diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp new file mode 100644 index 0000000..d8795df --- /dev/null +++ b/game/mobs/hero/Hero.hpp @@ -0,0 +1,23 @@ +#ifndef MAD_HERO_HPP +#define MAD_HERO_HPP + +#include "loader/LevelLoaderFromFile.hpp" +#include "world/LocalWorld.hpp" +#include +#include "world/entity/PhysicalEntity.hpp" +#include +namespace mad::core { + class Hero { + public: + Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers); + Entity::Id get_hero_id() const; + + private: + std::shared_ptr m_world; + Entity::Id hero_id; + std::shared_ptr level_dispatcher; + int last_pressed_key; + }; +}// namespace mad::core + +#endif//MAD_HERO_HPP From 5859a7189e60261d67692adee96986b8dd7f31b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 22:04:45 +0300 Subject: [PATCH 05/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 6 ++++-- core/event/management/controller/Idle.hpp | 7 +++++-- core/event/management/controller/Run.cpp | 6 +++++- core/event/management/controller/Run.hpp | 6 +++--- core/world/LocalWorld.cpp | 3 +++ core/world/LocalWorld.hpp | 2 ++ game/mobs/hero/Hero.cpp | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp index f3ef8dd..282c2ba 100644 --- a/core/event/management/controller/Idle.cpp +++ b/core/event/management/controller/Idle.cpp @@ -1,6 +1,8 @@ #include "Idle.hpp" -mad::core::Idle::Idle() { +mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } -void mad::core::Idle::control() { +void mad::core::Idle::control() { + m_entity->set_action(ImageStorage::TypeAction::Idle); } diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp index e7ea1ff..fa94200 100644 --- a/core/event/management/controller/Idle.hpp +++ b/core/event/management/controller/Idle.hpp @@ -1,17 +1,20 @@ #ifndef MAD_IDLE_HPP #define MAD_IDLE_HPP #include "Controller.hpp" +#include "world/LocalWorld.hpp" namespace mad::core { class Idle : public Controller { public: - explicit Idle(); + explicit Idle(std::shared_ptr world, Entity::Id entity_id); void control() override; private: - + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity* m_entity; }; } diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp index 3fe6107..c8cfd7b 100644 --- a/core/event/management/controller/Run.cpp +++ b/core/event/management/controller/Run.cpp @@ -1,6 +1,8 @@ #include "Run.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +#include +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } void mad::core::Run::control() { @@ -11,6 +13,7 @@ void mad::core::Run::control() { }); }; //SPDLOG_DEBUG("controller 2"); + m_entity->set_action(ImageStorage::TypeAction::Run); if(dir == Direction::Right){ m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); } @@ -18,4 +21,5 @@ void mad::core::Run::control() { m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); } + } diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp index 00c03e5..07ed05c 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Run.hpp @@ -12,15 +12,15 @@ namespace mad::core { Right, Left, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); void control() override; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id m_entity_id; - std::shared_ptr key; Direction dir; + PhysicalEntity* m_entity; }; diff --git a/core/world/LocalWorld.cpp b/core/world/LocalWorld.cpp index b65987c..d104bdc 100644 --- a/core/world/LocalWorld.cpp +++ b/core/world/LocalWorld.cpp @@ -93,3 +93,6 @@ mad::core::Entity::Id mad::core::LocalWorld::create_physical_entity(int z_ind, m mad::core::Entity &mad::core::LocalWorld::get_entity(mad::core::Entity::Id id) noexcept { return m_storage.get_entity(id); } +mad::core::EntityStorage &mad::core::LocalWorld::get_storage() { + return m_storage; +} diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 14c38a8..4f4d4c6 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -34,6 +34,8 @@ namespace mad::core { Entity::Id create_physical_entity(int z_ind, Vec2d initial_position, float initial_rotation, std::shared_ptr image_storage, bool is_fixed = false, bool is_rotated = true) override; + EntityStorage& get_storage(); + private: std::shared_ptr>> m_step_events_queue; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 8407ce7..379854a 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -62,7 +62,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); machine->add_state(std::make_shared(world, hero_id)); From c97f35cc674153c3916e767f13ce6907cbccb455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:01:08 +0300 Subject: [PATCH 06/44] set animations in statemachine --- core/CMakeLists.txt | 2 +- core/event/management/controller/Fall.cpp | 6 ++ core/event/management/controller/Fall.hpp | 17 +++ core/event/management/controller/FlyUp.cpp | 6 ++ core/event/management/controller/FlyUp.hpp | 18 ++++ .../management/controller/GroundMovement.cpp | 7 ++ .../management/controller/GroundMovement.hpp | 17 +++ core/event/management/controller/Idle.cpp | 8 -- core/event/management/controller/Idle.hpp | 23 ---- .../controller/{Jump.cpp => JumpImpulse.cpp} | 8 +- .../controller/{Jump.hpp => JumpImpulse.hpp} | 10 +- core/event/management/controller/Movement.cpp | 27 +++++ .../controller/{Run.hpp => Movement.hpp} | 18 ++-- core/event/management/controller/Run.cpp | 25 ----- .../event/management/controller/StartJump.cpp | 6 ++ .../event/management/controller/StartJump.hpp | 17 +++ core/visual/image/storage/ImageStorage.hpp | 5 +- core/world/LocalWorld.cpp | 3 + core/world/LocalWorld.hpp | 2 +- core/world/entity/PhysicalEntity.cpp | 10 +- core/world/entity/PhysicalEntity.hpp | 1 + game/mobs/hero/Hero.cpp | 98 ++++++++++++++++-- game/mobs/hero/Hero.hpp | 1 + .../hero/hero_fall/adventurer-fall-00.png | Bin 0 -> 1004 bytes .../hero/hero_fall/adventurer-fall-01.png | Bin 0 -> 999 bytes .../hero/hero_fly_up/adventurer-jump-03.png | Bin 0 -> 1019 bytes .../hero/hero_idle/adventurer-idle-00.png | Bin 0 -> 1134 bytes .../hero/hero_idle/adventurer-idle-01.png | Bin 0 -> 1127 bytes .../hero/hero_idle/adventurer-idle-02.png | Bin 0 -> 1206 bytes .../hero/hero_idle/adventurer-idle-03.png | Bin 0 -> 1110 bytes .../hero/hero_jump/adventurer-jump-00.png | Bin 0 -> 1095 bytes .../hero/hero_jump/adventurer-jump-01.png | Bin 0 -> 1049 bytes .../hero/hero_jump/adventurer-jump-02.png | Bin 0 -> 1094 bytes .../hero/hero_jump/adventurer-jump-03.png | Bin 0 -> 1019 bytes .../hero/hero_run/adventurer-run-00.png | Bin 0 -> 1073 bytes .../hero/hero_run/adventurer-run-01.png | Bin 0 -> 1043 bytes .../hero/hero_run/adventurer-run-02.png | Bin 0 -> 963 bytes .../hero/hero_run/adventurer-run-03.png | Bin 0 -> 1140 bytes .../hero/hero_run/adventurer-run-04.png | Bin 0 -> 1075 bytes .../hero/hero_run/adventurer-run-05.png | Bin 0 -> 859 bytes game/resources/levels/level_01/config.json | 53 ++++++++-- game/resources/levels/level_01/map | 2 +- 42 files changed, 292 insertions(+), 98 deletions(-) create mode 100644 core/event/management/controller/Fall.cpp create mode 100644 core/event/management/controller/Fall.hpp create mode 100644 core/event/management/controller/FlyUp.cpp create mode 100644 core/event/management/controller/FlyUp.hpp create mode 100644 core/event/management/controller/GroundMovement.cpp create mode 100644 core/event/management/controller/GroundMovement.hpp delete mode 100644 core/event/management/controller/Idle.cpp delete mode 100644 core/event/management/controller/Idle.hpp rename core/event/management/controller/{Jump.cpp => JumpImpulse.cpp} (65%) rename core/event/management/controller/{Jump.hpp => JumpImpulse.hpp} (57%) create mode 100644 core/event/management/controller/Movement.cpp rename core/event/management/controller/{Run.hpp => Movement.hpp} (50%) delete mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/StartJump.cpp create mode 100644 core/event/management/controller/StartJump.hpp create mode 100644 game/resources/animated/hero/hero_fall/adventurer-fall-00.png create mode 100644 game/resources/animated/hero/hero_fall/adventurer-fall-01.png create mode 100644 game/resources/animated/hero/hero_fly_up/adventurer-jump-03.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-00.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-01.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-02.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-03.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-00.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-01.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-02.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-03.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-00.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-01.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-02.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-03.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-04.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-05.png diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index a8995e7..e5e0a8a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Fall.cpp b/core/event/management/controller/Fall.cpp new file mode 100644 index 0000000..ed817e6 --- /dev/null +++ b/core/event/management/controller/Fall.cpp @@ -0,0 +1,6 @@ +#include "Fall.hpp" + +mad::core::Fall::Fall(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Fall; + Idle_animation = ImageStorage::TypeAction::Fall; +} diff --git a/core/event/management/controller/Fall.hpp b/core/event/management/controller/Fall.hpp new file mode 100644 index 0000000..4e8274d --- /dev/null +++ b/core/event/management/controller/Fall.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_FALL_HPP +#define MAD_FALL_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Fall : public Movement { + public: + Fall(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_FALL_HPP diff --git a/core/event/management/controller/FlyUp.cpp b/core/event/management/controller/FlyUp.cpp new file mode 100644 index 0000000..969d7e2 --- /dev/null +++ b/core/event/management/controller/FlyUp.cpp @@ -0,0 +1,6 @@ +#include "FlyUp.hpp" + +mad::core::FlyUp::FlyUp(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Fly_up; + Idle_animation = ImageStorage::TypeAction::Fly_up; +} diff --git a/core/event/management/controller/FlyUp.hpp b/core/event/management/controller/FlyUp.hpp new file mode 100644 index 0000000..e87bc4a --- /dev/null +++ b/core/event/management/controller/FlyUp.hpp @@ -0,0 +1,18 @@ +#ifndef MAD_FLYUP_HPP +#define MAD_FLYUP_HPP + + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class FlyUp : public Movement { + public: + FlyUp(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_FLYUP_HPP diff --git a/core/event/management/controller/GroundMovement.cpp b/core/event/management/controller/GroundMovement.cpp new file mode 100644 index 0000000..b8e127e --- /dev/null +++ b/core/event/management/controller/GroundMovement.cpp @@ -0,0 +1,7 @@ + +#include "GroundMovement.hpp" + +mad::core::GroundMovement::GroundMovement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Run; + Idle_animation = ImageStorage::TypeAction::Idle; +} diff --git a/core/event/management/controller/GroundMovement.hpp b/core/event/management/controller/GroundMovement.hpp new file mode 100644 index 0000000..339fe34 --- /dev/null +++ b/core/event/management/controller/GroundMovement.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_GROUNDMOVEMENT_HPP +#define MAD_GROUNDMOVEMENT_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class GroundMovement : public Movement { + public: + GroundMovement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_GROUNDMOVEMENT_HPP diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp deleted file mode 100644 index 282c2ba..0000000 --- a/core/event/management/controller/Idle.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Idle.hpp" -mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} - -void mad::core::Idle::control() { - m_entity->set_action(ImageStorage::TypeAction::Idle); -} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp deleted file mode 100644 index fa94200..0000000 --- a/core/event/management/controller/Idle.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAD_IDLE_HPP -#define MAD_IDLE_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" - -namespace mad::core { - - class Idle : public Controller { - public: - explicit Idle(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - PhysicalEntity* m_entity; - }; - -} - - -#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/JumpImpulse.cpp similarity index 65% rename from core/event/management/controller/Jump.cpp rename to core/event/management/controller/JumpImpulse.cpp index 9e5dd5a..6ffc28d 100644 --- a/core/event/management/controller/Jump.cpp +++ b/core/event/management/controller/JumpImpulse.cpp @@ -1,8 +1,8 @@ -#include "Jump.hpp" +#include "JumpImpulse.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +mad::core::JumpImpulse::JumpImpulse(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { } -void mad::core::Jump::control() { +void mad::core::JumpImpulse::control() { auto impulse = [](mad::core::Vec2d dir) { return mad::core::LambdaIntent( @@ -11,5 +11,5 @@ void mad::core::Jump::control() { }); }; - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -2000000.0f})); } diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/JumpImpulse.hpp similarity index 57% rename from core/event/management/controller/Jump.hpp rename to core/event/management/controller/JumpImpulse.hpp index 25d5cf1..5e69a29 100644 --- a/core/event/management/controller/Jump.hpp +++ b/core/event/management/controller/JumpImpulse.hpp @@ -1,15 +1,15 @@ -#ifndef MAD_JUMP_HPP -#define MAD_JUMP_HPP +#ifndef MAD_JUMPIMPULSE_HPP +#define MAD_JUMPIMPULSE_HPP #include "Controller.hpp" #include "world/LocalWorld.hpp" #include "world/World.hpp" namespace mad::core { - class Jump : public Controller { + class JumpImpulse : public Controller { public: - explicit Jump(std::shared_ptr world, Entity::Id entity_id); + explicit JumpImpulse(std::shared_ptr world, Entity::Id entity_id); void control() override; @@ -22,4 +22,4 @@ namespace mad::core { } -#endif//MAD_JUMP_HPP +#endif//MAD_JUMPIMPULSE_HPP diff --git a/core/event/management/controller/Movement.cpp b/core/event/management/controller/Movement.cpp new file mode 100644 index 0000000..a580c78 --- /dev/null +++ b/core/event/management/controller/Movement.cpp @@ -0,0 +1,27 @@ +#include "Movement.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Movement::Movement(std::shared_ptr world, Entity::Id entity_id, mad::core::Movement::Direction dir, float velocity) : m_world(world), m_entity_id(entity_id), dir(dir), velocity(velocity){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); +} +void mad::core::Movement::control() { + auto set_horizontal_velocity = [](float vel) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).set_linear_horizontal_velocity(vel, event_dispatcher); + }); + }; + if(dir == Direction::Right || dir == Direction::Left){ + m_entity->set_action(Move_animation); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(velocity)); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(-velocity)); + } + } + else if(dir == Direction::Idle){ + m_entity->set_action(Idle_animation); + } + + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Movement.hpp similarity index 50% rename from core/event/management/controller/Run.hpp rename to core/event/management/controller/Movement.hpp index 07ed05c..2bac02d 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Movement.hpp @@ -1,18 +1,21 @@ -#ifndef MAD_RUN_HPP -#define MAD_RUN_HPP +#ifndef MAD_MOVEMENT_HPP +#define MAD_MOVEMENT_HPP + + #include "Controller.hpp" #include "world/LocalWorld.hpp" #include "world/World.hpp" namespace mad::core { - class Run : public Controller { + class Movement : public Controller { public: enum class Direction { Right, Left, + Idle, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Movement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); void control() override; @@ -21,9 +24,12 @@ namespace mad::core { Entity::Id m_entity_id; Direction dir; PhysicalEntity* m_entity; - + float velocity; + protected: + ImageStorage::TypeAction Move_animation; + ImageStorage::TypeAction Idle_animation; }; } -#endif//MAD_RUN_HPP +#endif//MAD_MOVEMENT_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp deleted file mode 100644 index c8cfd7b..0000000 --- a/core/event/management/controller/Run.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Run.hpp" -#include "world/intent/LambdaIntent.hpp" -#include -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} -void mad::core::Run::control() { - - auto force = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); - }); - }; - //SPDLOG_DEBUG("controller 2"); - m_entity->set_action(ImageStorage::TypeAction::Run); - if(dir == Direction::Right){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); - } - else if(dir == Direction::Left){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); - } - - -} diff --git a/core/event/management/controller/StartJump.cpp b/core/event/management/controller/StartJump.cpp new file mode 100644 index 0000000..c124a52 --- /dev/null +++ b/core/event/management/controller/StartJump.cpp @@ -0,0 +1,6 @@ +#include "StartJump.hpp" + +mad::core::StartJump::StartJump(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Jump; + Idle_animation = ImageStorage::TypeAction::Jump; +} diff --git a/core/event/management/controller/StartJump.hpp b/core/event/management/controller/StartJump.hpp new file mode 100644 index 0000000..ea4df13 --- /dev/null +++ b/core/event/management/controller/StartJump.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_STARTJUMP_HPP +#define MAD_STARTJUMP_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class StartJump : public Movement { + public: + StartJump(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_STARTJUMP_HPP diff --git a/core/visual/image/storage/ImageStorage.hpp b/core/visual/image/storage/ImageStorage.hpp index 5699096..d866bd0 100644 --- a/core/visual/image/storage/ImageStorage.hpp +++ b/core/visual/image/storage/ImageStorage.hpp @@ -13,7 +13,10 @@ namespace mad::core { enum class TypeAction { Idle, Run, - Attack + Attack, + Jump, + Fly_up, + Fall, }; explicit ImageStorage(std::unordered_map> actions); diff --git a/core/world/LocalWorld.cpp b/core/world/LocalWorld.cpp index d104bdc..efa14c6 100644 --- a/core/world/LocalWorld.cpp +++ b/core/world/LocalWorld.cpp @@ -54,6 +54,9 @@ void mad::core::LocalWorld::produce(mad::core::EventDispatcher &dispatcher) { for (Entity::Id entity_id : m_storage.extract(TrueFilter())) { if (auto physical_entity = cast_to_or_null(m_storage.get_entity(entity_id)); physical_entity != nullptr) { physical_entity->synchronize_position_with_viewable(); + if(abs(physical_entity->get_linear_velocity().get_y()) > 0.01){ + //SPDLOG_DEBUG("vel {}", physical_entity->get_linear_velocity().get_y()); + } } } diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 4f4d4c6..4cb88c3 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -22,7 +22,7 @@ namespace mad::core { class LocalWorld : public World { public: - explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 30.0f}); + explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 60.0f}); bool manipulate(const Filter &filter, const Intent &intent) override; diff --git a/core/world/entity/PhysicalEntity.cpp b/core/world/entity/PhysicalEntity.cpp index 9b58177..6f94482 100644 --- a/core/world/entity/PhysicalEntity.cpp +++ b/core/world/entity/PhysicalEntity.cpp @@ -37,8 +37,10 @@ mad::core::PhysicalEntity::PhysicalEntity(std::int32_t id, int z_ind, Vec2d init b2FixtureDef fixtureDef; fixtureDef.shape = &dynamicBox; fixtureDef.density = 1.0f; - fixtureDef.friction = 0.3f; - fixtureDef.restitution = 0.2f; + fixtureDef.friction = 0.0f; + fixtureDef.restitution = 0.0f; + body->SetLinearDamping(0.0000000001); + body->SetAngularDamping(0); body->CreateFixture(&fixtureDef); body->SetTransform(body->GetPosition(), initial_rotation); @@ -69,6 +71,10 @@ void mad::core::PhysicalEntity::apply_force_to_center(mad::core::Vec2d force, ma void mad::core::PhysicalEntity::set_linear_velocity(mad::core::Vec2d velocity, mad::core::EventDispatcher &dispatcher) { body->SetLinearVelocity(velocity); } +void mad::core::PhysicalEntity::set_linear_horizontal_velocity(float velocity, mad::core::EventDispatcher &dispatcher) { + body->SetLinearVelocity({velocity, body->GetLinearVelocity().y}); +} + void mad::core::PhysicalEntity::apply_angular_impulse(float impulse, mad::core::EventDispatcher &dispatcher, bool awake) { body->ApplyAngularImpulse(impulse, awake); } diff --git a/core/world/entity/PhysicalEntity.hpp b/core/world/entity/PhysicalEntity.hpp index fff81c2..6c3e0fd 100644 --- a/core/world/entity/PhysicalEntity.hpp +++ b/core/world/entity/PhysicalEntity.hpp @@ -45,6 +45,7 @@ namespace mad::core { void apply_angular_impulse(float impulse, EventDispatcher &dispatcher, bool awake = true); void apply_torque(float torque, EventDispatcher &dispatcher, bool awake = true); void set_linear_velocity(Vec2d velocity, EventDispatcher &dispatcher); + void set_linear_horizontal_velocity(float velocity, EventDispatcher &dispatcher); void set_angular_velocity(float velocity, EventDispatcher &dispatcher); void set_linear_damping(float linear_damping, EventDispatcher &dispatcher); void set_angular_damping(float angular_damping, EventDispatcher &dispatcher); diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 379854a..dcee27d 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,9 +5,12 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Idle.hpp" -#include "event/management/controller/Jump.hpp" -#include "event/management/controller/Run.hpp" +#include "event/management/controller/Fall.hpp" +#include "event/management/controller/FlyUp.hpp" +#include "event/management/controller/GroundMovement.hpp" +#include "event/management/controller/JumpImpulse.hpp" +#include "event/management/controller/Movement.hpp" +#include "event/management/controller/StartJump.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -36,6 +39,36 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }, + {ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fly_up, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fall, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -62,10 +95,21 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -75,9 +119,43 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(3, 0, std::make_shared(machine, 0)); - machine->add_transition(3, 1, std::make_shared(machine, 1)); - machine->add_transition(3, 2, std::make_shared(machine, 2)); + + machine->add_transition(3, 5, std::make_shared()); + machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); + + float t = 1; + + machine->add_transition(4, 8, std::make_shared(t)); + machine->add_transition(5, 8, std::make_shared(t)); + machine->add_transition(6, 8, std::make_shared(t)); + + machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(7, 11, std::make_shared(t)); + machine->add_transition(8, 11, std::make_shared(t)); + machine->add_transition(9, 11, std::make_shared(t)); + + machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(10, 0, std::make_shared(t)); + machine->add_transition(11, 0, std::make_shared(t)); + machine->add_transition(12, 0, std::make_shared(t)); + + + + + + + machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index d8795df..70c3953 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,6 +17,7 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; + float horizontal_velocity = 81; }; }// namespace mad::core diff --git a/game/resources/animated/hero/hero_fall/adventurer-fall-00.png b/game/resources/animated/hero/hero_fall/adventurer-fall-00.png new file mode 100644 index 0000000000000000000000000000000000000000..3a4b30fb90d8d77f591fa2c00b728f6fdcaa5c5b GIT binary patch literal 1004 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 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-00.png b/game/resources/animated/hero/hero_idle/adventurer-idle-00.png new file mode 100644 index 0000000000000000000000000000000000000000..3bd528e863cf02b31c7cd6cc923034015a745f60 GIT binary patch literal 1134 zcmV-!1d;oRP)XYxd z%)~`q3?`ZwGQ&ccn#forX7!Td>ckZaLiyKW|4~Z0K3wjV%Cb%FX*7mUa?{h_J?H#> z-*e9IoO5BDZMNBFn|}eR7@dB2<}{55_p2LisYFsLmv;d0=u2-2_gN~uMotB8iwUFd#mtzN=4xA) zAxbo+g>+vGbF8_FbMFNJ_`}`Dp+!`H!Qd#nZ=9zuAmR2Mp)Vj&_4x7sX0ihuZma}A z$(*4MShLx9a6Utg)5*Zu9{kVxwD+HkajLRTeXR(|E^Pb#ampt>J@mb*^nS`@JPv@r zvJTJ$6dThc6Yl6_IuWN@cB;yJgmB;qrsra`{xV_+dU9X0QUB|k*GWC~jN$u@w_i0I z0w8Ecs%59TAwYu~rxVbE*QvGJ`B^IpJx@#}d$^;Mh4kjLVR2!C$#|T)4=w|mApNPm z@Ey~0F#s~zWi##z*z$~oJ36_YP4R$3E|`tbjbV=d8ezxl?-Eq{nQ|luS+!(uKm8m* zrJuzG?FMkL@u&a^8e0|;OW(%h*rh7-5ddS90hacZLeD#!+Du(|lL~to;NkgK-e)E{ z#_-Km9@%Gpg>Sis<<%9G`3RHoI4wOt&;kUNexl)!#L(yJQYN<^G*r1gTBAvA_iF3t z0${h-CoE64oFhvs={wrJ2O9pWlgSaX`l!~0+!^(5FYgyK$$rlOLRKFS*ZTpec6$g} zeWZ`QfI~V=Q0X_}dNZbWE&ZGTjKF52zfoZ?GnUo#T+Dc?+#YfR-9#oX6|@n7kaI*2 z=t|Fds=Rw~W^w>DFh<4t4h7m$1IP_@OIPeQs@_HfTNbjAOiHXTuh>sPW7nFE-ogod zF{iJ*m4bGs+!B*n73>)8MIik0cH;PBL{h7&EXyPkg@>hXt1B;+dIyGt`W61oK9es+ zmhBr&`e3P`iJ8geM7uTrJ@R*ItoNSe`>FF!5iVq}O{LwI*Apm$kezE;wPO9&yT4pw z%XzUgBwWZ+JkEGBMfxruP2h($07*qoM6N<$f|lkf AqW}N^ literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-01.png b/game/resources/animated/hero/hero_idle/adventurer-idle-01.png new file mode 100644 index 0000000000000000000000000000000000000000..230c1cb30f47fc1ae3db9e1f34429b345a4926dd GIT binary patch literal 1127 zcmV-t1ep7YP)ESc;_C9 zN~YPOF@}(l7a8lA02vurp5=gLRm^pN?Vjl0Cv3cj&Psl!Yu-+WQxzf z_?nL9Z2+i?D%)EE8o+#ft|W(Nn#kTxpH?ATq)a-;z~v|a*Qal20iTyEp=)$BZ$oh^ zj1GrUoC<(O2{NI~tbv+3nM^vTRmc|hcKQGa_`JqlT~rO-!m((WCbE*wNjjP4hwOaW z`!M0?l(8O;PH`o4%@~&oris{O3vR_G0kkyPH9*^ysvsPlLUAe_{4B^|R}USJx*6>1 zF-VDqkX$|AyPMXgYHesF!cF&i=8iqZWOe?G-hAU=k#79NRT}y}7XFS1samZ~)c}Ok zhw!hVQqWL)cSsAncVOXtrc#(FG~FvdPv=EukP7`~6b zdql(|h>M6$0-)AiL(H{;|HBIac&e(5%Xj)aeT#N`OaBZ)i0A|gQQ3WzQ1~LFc9j8_ zg8`R=-(G%=Q1~J<@mT=UnH3T40f8-wPGwg@4HS`Zx_mfYzM_5m4ZrG0z? zfTgh1yHZtwlV`YzKENoH5Ld90WHhmRW%xKx)vpNQ-!ibUMA zljWT+0T2pbH0!zurioNqZGWgf5!r)ddKIV3N9}qvAYaY0-+X{wYAsY3QoT$Q3C~Xy z%`0DjPikit>SY!eqRhl+i!Ok%Q+xiMEedR;%G}hiWYbvy8i?Uo*eC!?>+-@q&4JxQ z{0kwXlepA(lDoY3QU#oe>lt&aNcVZSL@c8b={src5dqUgVu=K)A3{dj%uQYAQd~n( z6jZhNM@mr?&cs#xTgs`-S1Vy(cj3AENarrBR;vc+M06jTq9_1lvso#4`Fo*$h4orG ztX8WKoxcm=L_D^?4suPIn6G&ugcI@KvBthyE2^rp)w+?oTdhc{s`7*_iMKq<+s}#X zv!Db-?6*=HK%2bGefBa&hJuU?1#wCl+T>*boMkzoEj*Nfh@+|sfPmLSt!=}+(~=YI zstCe~=vd8Wr5eYbMY0M@nKYS9mBe33h%6-%BvQ+~`pE@DcIw+vGPyNlzLFCgA>l-p t5(y@gDVG1_?{6}h!e+4ue^34w_#H}Ld7*XQd&mF)002ovPDHLkV1mdw8z%q& literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-02.png b/game/resources/animated/hero/hero_idle/adventurer-idle-02.png new file mode 100644 index 0000000000000000000000000000000000000000..2668b590bc2ab2ffead9465e8f2538ae88cd34c8 GIT binary patch literal 1206 zcmV;n1WEgeP)t%mk;?vU!GyH0*Y1*|JHBF2?Ep!3V(Y$=@}%tAyU6o77fqMR6#M z-0+|{6abAhR6>SP1BIJqqKk1YTQMmjn21F-;Z!UVKy{^61GE<+*?4>tC=P|AUk}h%cZAyKo%Gcm z(MgGhkXpUiR?m*g0`2;+mwV2OOt-wmc){8poqX?Tl5X%+KNTIH3-1vjr`C?j0suUV z$0)rodwgb<{pHmJPxZsgrnUL6e#Ko-`lmLGLdebp`wr1|(M?6~cbd0$4^zPaW&PLm z`Tgb9`uM`=4I-~J>b_5W^sa~y#AIad6Dy6}(mHGR08r#Cq}XoP=P!)j(8n%W=I6Dc z&|}zevwNEk(^*lLB%2Bb@aHd4`spPAitTp&=Q{HvQ^5cL(dA`YPJV1O1V8{0fJW~v zEkS1FmjRsqK60B*Fyy(+h*hOK-$r-7jk|BX!;t4PbF)6Cf&sF#vb3jPe3gOG6~i$Y zDlKo*VZyN`a?KWCEfWp1^Nd&_+v85c zXJP~97h`zkVzzC07JwDMzD!%br$||w)WjRI;j9?SNTD@Pdsvoxyj6l!5&)Uiudz_` zCZ(Vu`5W8|30E;DG199bLsI)vYWB5ZMO4kK6J@Fg6 z2tb+4+^jEUjT0F2ou|}wfU6zt0Q%Digj|RT5?4Fgd936K?29n~D)3{Q4d{CF_vNuG zr=@dpPePnhp8p1hi16rP=;E2yC;N{X_gD0Bri0&($Q*oKHS4-OJt(QjqR_f0!@ z;+YSVkXX0tilT5Q4MYrEY#tnhb%EB@*FAEL*=#oIHU+|u-@=SXzc>9Ioqr19M9Onb z?6rhZRh2yRgG}X_kyKS>uO&=LW{eLG?h@)(IFX{9EX`)Ovr}H+Noxkf*9REBK7d1t zvQu6Fz>yIba^$W@T5fg#cS$itmIvk?rg*ws0cj+%5{pTNwoOU0Y*U6b9*(5NUs{OF zheCuR3p9UuNtb=`{Rq+cs{Vf|E;d8LiOh#WjE5sEM3??jXFMFiVloNulm7+&0QQ2K U4h?yP-v9sr07*qoM6N<$f=IDF&Hw-a literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-03.png b/game/resources/animated/hero/hero_idle/adventurer-idle-03.png new file mode 100644 index 0000000000000000000000000000000000000000..53207e8a2f1ed323478a1e16c27559eff02c46ba GIT binary patch literal 1110 zcmV-c1gZOpP)BW*kqGUHreDqK&gh)Q%4Wc(RPn0?Mv$^rB>Slz@cWE!eOWhbOWU%kSjcK7uN1{}-fQQ} z6T1jSqQ-bA66IX*qS3Av6$`PcW;~ir0qE+m3qU-Owi1d&(OeowKAK>xZ;;;mJ&g4Y z8lq$)Wv`w-@i4nP++ut(%pac9EWGh3)9%6=z4G#r4Yu*)=V={!S9*;|Ikk3oxB&=d zj?#3a@2~HBJe*8Q_!|Lt(@lL;ijrIB3K^_WDaQrcilC!UKo7@>ZH=>#PVZUL)N55RCwrCh{{yq}c>prmRT<%d3NsQOI7}+H z$`*^w5HTB{XL%_?-@q|~p;2b+I$_ldK;OV1!O$qnONEQG=fTIBxV%PpOXa0nc4~+F z`|)cY>a4Y5xOIoI%F9a;dVakIJ5&IYnVcb{H50?3TKJI$UU>6UV-7Nel;vT#zaPgP zb|QLQ)LCnJGb<^I~ZP+YC=agV*wD@zwQ*yafRP28j0k9CgVzi4Qia1mY$xIGFq?VLYF%?tp z<}_B(>vU3_(AlAr)ccxgQZ0sIv33C1){Q4N20*=gm-yOd?DNICJr`Q&~=?U%lctbXF<_*oqe_xzM34bKG`ERu5=;w zR+9kOqponb-NfYh1e46vuxfYUac ziD~?J=z~qAO)-9yX!;Qo1F=N|uA&lbf!(FJEO1%(3%bzpVPRc_KIk1@%>I&_+?=^N zbN+MAoS6$*vSi7UB}DrKD$J1^)>(^GZCt4JQ83kG^uPM?^ETds90k@u_&!t4u=}u zY5U0dZRv5B(lhW20D8X8V80jN*a-1>Oy0}izeQO_<`Rpds92N1@r112ZWk{dc@%(9 zUnu|{cPWvX2ztH_u;N_>$}(cpawybo0-$DxT>^66-ip`fPk-a}`O}%nw5vdwkke;} zc%o(#@4rzCz@LR*;eY#MSs%0F_4(2Bb&j6xqqnJ@+PXq|o7&T&RFI>}(NIepTb{N6 zoa`QZ9%JNNe69z`8NEr^F7W>mqPa@Y>J~WiAEebS_*LYItJivz%&(+t47Ic|5i!`T zyQFt&l%d)u(_@uAR|psePi?J984je@?!v8dI`$Qa{Q9FRLQp3Jkln-m#10-#+XsK^ z<8gwNOxp+;2EgBffDejXVlKJBd#B$q9fN5hLoIDg$0HQjb@}d67n+$)og+;x?L<3I z0jv|Xgv6WD681X?ycq;s3{>sEp5!s$H=ofWcP4Cb)7c=81PhhgOP%%p2Eh246O5lZ zK{$~FV7B8pvmM8Ql;9;yAB?8*Ik#{J@6;#(!=S|FS~c#}EC7TPNd~Q3fRr$&W}&XC zK^V8k8Q`+4_Uwa{nEzZMri6s=#8=stS9#KZ3wwrr=Qa-$p&$fqvf;p60-)Gg!Iz&L zW8liyY%VM^6N>38O1dNhhQaKTh-;l6vZ=HjS0ag1vyfZ!3;>g%AP;L6X2Zj>%-u{Z zJ|WJX?^4n^P2aULJ5lh*fz+x4ll~E0q{@o^PXVX`!hi)B^##;vcQ@9fTP&F-LB@VsOQ2bl-F`DEv94J)>-t-*T*#Y;8>n;$_S>RVE(9sH-c1Y0 zvmhdo2>WeO)zhjMV$(EfOD3dq>42 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-01.png b/game/resources/animated/hero/hero_jump/adventurer-jump-01.png new file mode 100644 index 0000000000000000000000000000000000000000..b20e0343c77fa6ecb46aa2cfeccfa0f8699f6427 GIT binary patch literal 1049 zcmV+!1m^pRP)izazx1zV>AS_=w^KI)u_p$@kw8d z8Z_}?I+1`ebIQV8e1SL@rB)%5O*>i`mI9@=rF306K6KO;>(f0?+D~$mbI&>Vch2|z z&iVa*P@+VM5+zEMC{d!s{{^AS(D4qpG+PZKmCP{mZ6MeG!RZqm+`C8S&rQVQqFmbn zK+E&5DOrD;5-WhS+Da;!k!Gub;~nl?e6Y$cYPpWjx2G9fSCZsURGO5T6H6@Wh-qXgeND}8}r zZjLVyWZXNQYpXYN zp_$%3me*qJEYsvrV*>yS;Sej!*${k`5H-sd<{}XQ9)00(_QS6;I8L>Qmp_^2op;~X zyA6FpW_tTrO(nS7TrP(i8wvy%jb_o_^OTGao&hKjv&r?AcADC{Mbpu4j@+v+fa(?k zNZ-;8YTvsEfY&#M|Cb+xf9gjXlXJ5A>1@J_51wIS!_5T@q;+k*r7rgY~MT|%O%1c6w%=$Of{ zjk4|8SQ1U9nKIV{Sz$J-iMIXiB64#cFJtnKS9FQdC*;;z!MoQt2EbzQcT8L6-nY-g zLO29-zp?$1Hw8eoZ4Y05dJ^xYi&QzBdbXmwM9CF{n<6d`4p8Z;W7mdc?N%C_)r7J6 zF#s0BAsVbER-@Nst@{{>wFPnRvk@gBSa+?p8Hqwad9!~USPc3}Br?>P1<_<0CO-#Y zKM(~>z>UBKYTd__)mplY40UzMts!;OZnWAchr_bi7(EWbtLML0mJC5>W?zoS^EV^% z9)`mbP1FAIjizb*n?OD2I$9^MT!A89J<{nY#^dcA(u$rM zrAKKi%7s|0R$0Zm?6$;dyd7e%%_IPJ8`HQfh*&H}w~yB&|KhI)(S z=kKnv+myyB)?|-E5K3i~dq=sDXe5F!I7fUvB>>^H-BmC?8&BXg8`R(S{|bKrE6Hcb TLPIqs00000NkvXXu0mjfd%y9w literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-02.png b/game/resources/animated/hero/hero_jump/adventurer-jump-02.png new file mode 100644 index 0000000000000000000000000000000000000000..ba27779940e0644fb74d1bfdf8d863c973b2036d GIT binary patch literal 1094 zcmV-M1iAZ(P)9&_Hb*pLGr17@BNpIHcLz6VIq9Z$3eaQFaa_%|z ze1G5b`+d(j7b>Wrf(k154lQ`Zg1OY=G(7-If~C8q^Ti*J8+XY(D$?y9!1J5 zf5M|Xf+o2|nxC8J!%t4Iy?s-mzy01W034=W8mA>0$qB*jRfIp|Geg0(M4}S~F|!># zw1@6veDE2*(0nvC1ZWLy6FraJQ#NOnoX}Sz(Ch>t6kJ<)Y6-1m%=+HLBxa&?J^2DQ zkB8w)*|Pa85u)0vMC^)=r$#j+(TT$QNOXd;Bj-!Tc6RqN5*Z@cy4jqajg`%5iIC97 zdH@Fc?quigB_h!Yygo0_elSe9v$teya_Xu87>Nu~R~Il>&vt#V#OzH07w_(EQKL|imLx2|t`pb&Rl8hwYaG`g16x#W7Bag}WvKO9D zXdvo&lVuTlCSCTzS|S8s%dvhlGCd9tKLM-+4{-ChUjcA3*KT@f4|*mooOVaqeA0zn z=-$uFf`;Ga1z>&fL5$Ddp?Tjy0OpPzBD~=i9#2jIknpV$2L}3YnAehw_+4J}=F({1cM#WbSPG}q?KhtdfR_5@EjZPzQ0r8wb*cc2*;@J3*XzYF3@M8#t+a~0QR8r|3Qp6sRo`fuhN`M%->-@xMM&No0CSm) zsBt>Y8izxCb2N_8|=8zN{kOn~on7XZ4h|G!G>w#F9m zyRHkD&BmBZ}hywXp0V{x${B9%;Xm)|A;j+`08tteno6-d7{sy3UM%AF&ss)~SN6v{_-7K$M~ zBdKJP%X9P0XS2dE3`>JAhV+bFo}0&|REz0!hF8ygFMIk5D)_hY2che3yBE_uw*UYD M07*qoM6N<$f+g)C)c^nh literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-03.png b/game/resources/animated/hero/hero_jump/adventurer-jump-03.png new file mode 100644 index 0000000000000000000000000000000000000000..0458013c8dae7ecf137a009f0de9d2dc5fb7c074 GIT binary patch literal 1019 zcmVHJ^vVQpW(c}v>cx7okus_yS(ar3JEV;Dv^i{T*}CJ!)paNe35`SSfONF=l! zfW7aWCmQKi<8np@U@|#OD7;U}X4ATOYG%Z2X%Oj!JjvU?Z<()*PbP=)cmj$ZKEwCO zbgZ90WQm~5tDH#>bK#RtJ|3JQ?FmtyS|@kT(RcSbI!3=B?FrEp8z36#=0K~dYCWb} znYc1@oeQ6J^7;5-(w?Gf;@xf^;Nxl-P9-+XO^*CP`o^R#Zo`aB$NI?@msJx0-@G>s zZyp99=nnv}IC~9%k5(%| zgQ|^Wi_4m7RHD*^+h!)0-)J$@{$l{#TTFA$vBS`han%o-j`eRjr2tVj(s%Sl!ls8? z9zDk729a5B#A>w?A0Dk%hKi~;dwL}+9OfpLR|{pKnwQei-9=`-#B9N-StrZ#=2b~? zx$NZg`Tuuny)<;We7U8Nc4q@OAE2qmBNLi?=++(Sd^S3k&`4O#U%FF5pJ=u>7Tc)aNMsJ!I0LfnUS0%aqGb{ z%WG@GE7tgSbb{u_5^jrG>~K0r7fWJ~-MHU~n*FoC{mNd&ZfX=OYb7rJG^NG|Uw;8M p_r>7Qc&+H`sH2WL>Zs%K#Gfd5Tp^4i<(B{e002ovPDHLkV1llc@^t_J literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-00.png b/game/resources/animated/hero/hero_run/adventurer-run-00.png new file mode 100644 index 0000000000000000000000000000000000000000..e3d7cc057f4e6efed4564cae0c022f961089639c GIT binary patch literal 1073 zcmV-11kU@3P)-L~*N`~w~w_wx-vWOaAj0Tr1#<;j-qKOzD_ka(^N1x1$ z&X}lV2_{Q)VF4#B!HhU@z*x40Ez6)V7<6!9m(sy)IX>LAw!&0yZ+Wrbm)@Rp`uqOA z=llEh^b~T)A%`4t$iX_qMiZX+;2^tqRmjw_h`u0vsvm&8jUQWz>&!g0^&zql;pC6) zJX`%F0Q#&><(?`Da5p?{d1Lcz%I`np*6j&d72L-8!K(nMMJiVYh6s(`VsSAd|K;Nk z#fA!bZGVu^@-%(Xt5gNIq0j2cxzuMX*lg|-ExsH?$kr~SC)Ak_N2Quh8qsEH@Zyge1)v9?%~&S7b$(z zgDb2ub|=g$m4ZV-fv>2HLqWkcQ7F2)&s*Zk%Gd93!(jks7Ilifssy-RI{?7G-8=dI z{b2xJetZwSWbWnAcQ>hPX%I!v9kIk|tB|z>oVj5NC^^=_NT{8O;Y-Q&k6q|7#XP{7 z8v~-LzuywKtvxceI7g|sP!@aDq=523fN@PrTeo#{DU;zT$^(Jqx=dk$V4#(ATw%W^(;IwIr58P~L=fN@Qupt)7J zVa z&){|!1JJt?GzVSgOUZ*>pZuj0=e-HB!?;aTo3(>5fvnv}T2D=<^+p1T@=Bopo)kCZ zZhFslXT-N5_mQ9Po0leC*Ma4lZ`x47VEEdbS*=-l{*;_B-_4(N6HDpRT34nkj4wxdQmg3?G zuQ`7Cx4w*dv*L)7pD#BB0=!dE#14OcTC$J0T>_xg<)E#*&lVAo1tBrRNPR16%lye? zzd3gWpVJ9hIKOOfcBi7qc}+tqiYWB^Y5KM^ZNBC7?{-s~ymkki*EB{KBDfrRgtR%k r!#@Ou!00000NkvXXu0mjf3}y^* literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-01.png b/game/resources/animated/hero/hero_run/adventurer-run-01.png new file mode 100644 index 0000000000000000000000000000000000000000..96d832012e63466c4cfc2b9e5b864f7af21b1e72 GIT binary patch literal 1043 zcmV+u1nm2XP)2%@jT z9`t2H%IuT4maPSmLF4|wS~9H8Qm|=8m&G(IH~o{`n_eH%dw08vy4<7%$rmo1^SkHX z-|ut&p96K(Raaeg)m0Z_JDlG5>J!tMU()g-sDuD`sqfQ@{wcW+>&Z3v{V<(}+X2uP zG@kE>nE-!g9#mYhTLyBb_W*#IzPCcGt(Eb~DLN0gql6WHnMk076#$b8dr3nTV|^mU z+FH>TG&}E1SE4NeIn#T9VxhFjo=DCyJ~?Hl-KeG@cY98fiNDPoN1O2aJZAdd3cY$O ziR2tgSmE@yw}^M0qVtsq@vc)gR3)nFtToi#O-o=mK99_9Uy$swMq@xR!|yF~{mxyk zOuokc8`qd^D%an~AD!Ot{rPJ%;)4%AugJG+kfH8wJ6+Iqe6noDn)ceZk?9Gds>)B# z9Rgraq=n$+Apnj)+W~KS07zV%p?jc5gkRkV_g__wS<7A%e6ma`mm`(S5mi+HqN+-< zZxF^lV^5@o`AnME*WZmyPjH+L0AfvhsT2aL08-F(;ge-EmCM;S3&OHBQ*H@Msm9fE zIaEfbC)|brQ~@MkD3HnL?R->K9|4@bB34(k;ApjlY?4sVSpZU(&Jjg*8v;-TkQH6G z(@qH1$DiNdX#SBL24Fsu1|Waw9E&UE??UgEq2%E~SL3x>E4%PX5~*Cy^huH^7{;ao z^O-d7y#M7U`_+qI5d7^jQtLri0k{U~zkS=8-B7FFtY-218-a3{`a8{M((DI}xnEty zQPaJa)vW^YuYndO6JwjoEM$}Dr8OaY+^x-9vT2O3wE-|XcmaTB#|+jiOG2iB{_nLe N002ovPDHLkV1oY={2u@S literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-02.png b/game/resources/animated/hero/hero_run/adventurer-run-02.png new file mode 100644 index 0000000000000000000000000000000000000000..2e3b74df0890213dc31ab88d93038a14e31daed2 GIT binary patch literal 963 zcmV;!13dhRP) z<(}{RpYNRWoqM57nKEU{lqpl@u0xdC;is?fXM5W=nQu#|ap7<|0qB19h@pNhg@?92 zhYqv?$mLW<41M)GiFksO-<+YRqa6TsQN_E%CjsUobA|_YLs6prAH){Z65#sG4e4vz z%$2|x0InJr!BK^&$?GJO3At`3>rgTwIebl<^{cw5>h}D$5lk2IaC^1hKK{fml&NX` zUYVNKGm~#OLcwd~%idlI;Hz!cZ3{_NY_humsM(#A4YlJ8olG%bjodPG8-;0lI@&q- zfu9#Y`-DUH{=&e`J#cZ*a2y2-xut2M(rT4wCq{MK-mN?IxxV<39iD>52lo*Hyvg5~ zB*vA%7`>rE&i4qQi}Niokm(g%xN0blg16s+?ru_=CILKdw{G{NbY)*Sm!a;pZc+32K|^sAEaX^cCx9*_7hq0QzKCGR&n{-O z&-29Oc=Ot|JHGvjN{dB=qfx9C6#^g}jp~6u`~2GkLw;IQVVr&aIQ#kuZ(8QZ`&;q2 z-FVz?>@8ah8dTFOyMJQkU$x=PTaW7PU}X!>?0+E}$feWbmE#{9_G7w`!BgiXK!@*X z-8OvUD8G&=0C;cxLAA}wWAA^@@QI`JzkAqFOrZdBA36{_`W^@Yg>T6taF67vAJ={pH@W?%q$#{aRDn-pij#6yD z@;7+Nz3ouqa7oPiQL)T?#UuuA+70S{AfS@n&4fe+Rv^+Y2DKI2|md)8fP7KvDWF lSsnQ=t7}Gb2L|)5<{u@>Infw4#AN^g002ovPDHLkV1mT5)A0ZR literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-03.png b/game/resources/animated/hero/hero_run/adventurer-run-03.png new file mode 100644 index 0000000000000000000000000000000000000000..a512930ec81d583aac03630d3d9fa7e4441facf0 GIT binary patch literal 1140 zcmV-)1dIELP)1MxxaIAe!uTM zzu)hk3keb=NRS}G!4Ze)?CX!3sXBg4-fRm>0g++M1mLC1pB{Mcl=wn>I)Z^9UBBGI zUQ+>p^jM;@)+PhY&&|g5QZ*HF@!fLS>sba6J$I-0+w+fXD=DUbWDI*v1;!jBqr*;& zIYt1PI5H$jrI`0br%$5sLD5u5U@;;rg$5!kYjSC^9_Q4w zGUuF{rhjBi8OMvJLaLAFu%24HQvZx>k7nVVn#P!8@ZSK}&nP1^6x`{Vd#JUo0b%#3GR zK9X+%;NLkf)<5oX_W9b_!ZXPLIKOjY%PZxla;pINp*18|m@AX{E(%vNqaaOcvZ{mK9}w$~T|`no#+XlQC7(A|zZ7m6_9 zURY2Bsevj&#+xqSUGgy#SfC)&v}LaGk)P3Y2~TG$h400_-0tpn9Hw#r-dUIh;O?<1 zjsTYDDj1wtWoB}mfN!4Ww@>dY233mPyX3=?o-NOY{POLIVIF??x-!?3o286BovnB} zTk$VP6r1nTReYDO0#OkP_sf7{e9c7P=x;iu=t3>6^A~wc>>(_)8 zz-o{I{L2wiYTu-KBS^Q4P$VkqbY2FqY0tchn+q1u=%1KgO4iAhUKi#s#4JdqvkxXd7vEkZItmPxtFh)^gLw=>m+ zw4JNth4dX}0btgxaWpf7ERzXuFf3|w4FcfL-v{INtI3H}WC;1Ke8CCB5~k!;CD?4e zp7e|i0bt2U<=b2LR1pCh2nj`_089pgq^Bf{GX07YY}?HNbb38#&@ENpucCi zQFK;OkRfFZ71w4?@@~On+s%dc?-Yy1 z`1Xg>40N>vpx#jF==SLVf300J^-wJZd2Vl`UiVlzfcW&pJeOCl=)T4VCPT9fbhRT@ zNkpc@NL3Pmj)@8>D^kq=sN2ajuf5QUudx9DUt9Xlh z?yMoav~2W+mzJ3f%^Gd9vJ}ME;sxNnBRx2saeW}Yh49icQkBH3CxQe94>Pd4mcZa) z1FBFJb&j0$`>Cs_#AS0(>2fn!H^=cqZG3)yA1yy#Gp?Hq&ElUMCK1=%r zKmS&+Z_}^elYYO^PHGx1heP+(G#R!t3)5Wc-vhwji!;cI!v1aDna-ze0EE9;#8=Zq z>-d)i$5V`q80&(|;XqatWJRIgn<=YH{d;(%whjRKdXRd&oLQI#U_TikUrm!?D^#XI zlA0!54u>u)iebw_{MyoK*dlX5`T)5)K|Nk%Mac{PVNa#0>M%Xoqsb(jA+lKkc~%j^rZI@lm$F@rfQ>Na>?*zpvkQ^!t$MIr8R(3%RFx86E@SaeE1cCv<==-&0&& zTV;E@kE?5|ATQz>9x-4ebHRe+uzdGBcIqdhd|Tw}hxo{qL&0Dhkhv#V^0gq9X> zeK%#=kLA1Hm9O8)l#&bBAd?B;q1rmu=TI9*n(t3Wdmv*<%Pp#z#D@l^k_LilEvSA}I@rx;6mSp7EP#?1~ox}!gh5%4i z)qqhpY^J_Lva)3N8%w2VcMJV;f_v7Ds+#`>$(1D_Zo6IoBO1F~m&iE`m{cl7=gwYJ zJ}m)ROC$uqj`CZ%W&toW70f#ah{xl4cXhcbpO%2!N~Iyc?(-mWU{F<+ms_f+blOb$ zv;^dF|9LGN|cm1>ORI9C4Y#K!wN{fNG!D1aGh@w+aL>K80h!xa1s4jIV2s%|JMjeDA zq9U_D)FnHlr7Wye7NMzSo31tPuDY(T!|0?HR5QCn!hT?x-}}wm_kQ2`{pQW%L7Fsa z(xgd~Ce43`uzJEv2ludk-C8-@7g0w=uHpp1S9ikDxHj{l{Tq?d2u-){;x8`+Kpj>o z+u)S|UqYV^KUhnI)b1?-kc0g(-uDmSEm}cqXBYnRQj|P}U`GHYPXUk^tda#ujQ6kb z7Ol{)>aeQ&XWK@wM97+AyKV=1Kg_XPJG*}I8^LsGU9YZ|0Ny1lb>C1_75NSYfRXVC zpNrqfHN}}UHpM9ZGDUz7_{&S#f2xg|hKtlLeZl!pTj6oN;W$iZWIP@h0L|SU`Y+$1 zNVIyFi?ed&*fkdb7f$-|xHP-9vx}v#>S^%{+^Z{S@e2wzR~vrWO)tOaeLiCGxCHbd zLCa8ccLyGqi@tD}x4umPEOQr9()x(La2SAXhbpu`+)Lm-;1hXO`whimy0l{P_?-4k zfPgL{$8HyZT;?v+`s9z{LA%#{u3hhcxT?W$9LajwMV8Gb`odxC85sgJK{Fy|iw(YN z!@2t?efeWNTUCO`<-+4~&4@LO>5LqH`Eqts{B+f+^KIf|Xb^z@%f~cl76ctC?s%ps za5_!JVd=E#{j?d`z*tEUNd+@!AMsj0Co`ydVv_5RlXF*Jxh!~B-d(u{Nl9{%DR z9_qy-=82HwJ1PlIW$~ct3IGMus~13l-6pchFg=GQLb@W7GTyN$XL_qL)XUeHwvrvc z^E@eYSR&+G0&avPFoB|ITNhRRVJ8F2cfYA3 Date: Sat, 14 May 2022 21:35:29 +0300 Subject: [PATCH 07/44] create Hero 2.0 --- core/CMakeLists.txt | 2 +- .../condition/KeyReleasedCondition.cpp | 15 ++++ .../condition/KeyReleasedCondition.hpp | 18 ++++ .../condition/LastStateCondition.cpp | 13 +++ .../condition/LastStateCondition.hpp | 20 +++++ core/event/management/controller/Idle.cpp | 6 ++ core/event/management/controller/Idle.hpp | 20 +++++ core/event/management/controller/Jump.cpp | 15 ++++ core/event/management/controller/Jump.hpp | 25 ++++++ core/event/management/controller/Run.cpp | 21 +++++ core/event/management/controller/Run.hpp | 29 +++++++ .../controller/statemachine/StateMachine.cpp | 5 ++ .../controller/statemachine/StateMachine.hpp | 3 + core/loader/LevelLoaderFromFile.cpp | 45 +++++----- core/loader/LevelLoaderFromFile.hpp | 4 + game/mobs/hero/Hero.cpp | 86 +++++++++++++++++++ game/mobs/hero/Hero.hpp | 23 +++++ 17 files changed, 327 insertions(+), 23 deletions(-) create mode 100644 core/event/management/condition/KeyReleasedCondition.cpp create mode 100644 core/event/management/condition/KeyReleasedCondition.hpp create mode 100644 core/event/management/condition/LastStateCondition.cpp create mode 100644 core/event/management/condition/LastStateCondition.hpp create mode 100644 core/event/management/controller/Idle.cpp create mode 100644 core/event/management/controller/Idle.hpp create mode 100644 core/event/management/controller/Jump.cpp create mode 100644 core/event/management/controller/Jump.hpp create mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/Run.hpp create mode 100644 game/mobs/hero/Hero.cpp create mode 100644 game/mobs/hero/Hero.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b1ae6b4..a8995e7 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/condition/KeyReleasedCondition.cpp b/core/event/management/condition/KeyReleasedCondition.cpp new file mode 100644 index 0000000..fd9df64 --- /dev/null +++ b/core/event/management/condition/KeyReleasedCondition.cpp @@ -0,0 +1,15 @@ +#include "KeyReleasedCondition.hpp" +#include +#include +std::unordered_set mad::core::KeyReleasedCondition::triggers() { + return {mad::core::Event::Type::KeyReleased}; +} +bool mad::core::KeyReleasedCondition::is_triggered_by(const mad::core::Event &event) { + const auto &keystroke = const_cast_to(event); + return keystroke.key_id == m_key_id; +} + +mad::core::KeyReleasedCondition::KeyReleasedCondition(const int m_key_id) : m_key_id(m_key_id){ +} +void mad::core::KeyReleasedCondition::on_start() { +} diff --git a/core/event/management/condition/KeyReleasedCondition.hpp b/core/event/management/condition/KeyReleasedCondition.hpp new file mode 100644 index 0000000..ec846c9 --- /dev/null +++ b/core/event/management/condition/KeyReleasedCondition.hpp @@ -0,0 +1,18 @@ +#ifndef MAD_KEYRELEASEDCONDITION_HPP +#define MAD_KEYRELEASEDCONDITION_HPP + +#include "Condition.hpp" +namespace mad::core { + struct KeyReleasedCondition : Condition { + public: + explicit KeyReleasedCondition(int m_key_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + const int m_key_id; + }; +}// namespace mad::core + +#endif//MAD_KEYRELEASEDCONDITION_HPP diff --git a/core/event/management/condition/LastStateCondition.cpp b/core/event/management/condition/LastStateCondition.cpp new file mode 100644 index 0000000..a2fb453 --- /dev/null +++ b/core/event/management/condition/LastStateCondition.cpp @@ -0,0 +1,13 @@ +#include "LastStateCondition.hpp" + +bool mad::core::LastStateCondition::is_triggered_by(const mad::core::Event &event) { + return m_to_state_id == m_machine->get_previous_state_id(); +} +std::unordered_set mad::core::LastStateCondition::triggers() { + return {mad::core::Event::Type::KeyPressed, mad::core::Event::Type::Collision, mad::core::Event::Type::KeyHeld, mad::core::Event::Type::KeyReleased, mad::core::Event::Type::LevelPause, mad::core::Event::Type::Menu, mad::core::Event::Type::Movement, mad::core::Event::Type::Runner, mad::core::Event::Type::Visual, mad::core::Event::Type::WindowClose}; +} +void mad::core::LastStateCondition::on_start() { +} +mad::core::LastStateCondition::LastStateCondition(std::shared_ptr m_machine, mad::core::StateMachine::StateId m_to_state_id) : m_machine(m_machine), m_to_state_id(m_to_state_id){ + +} diff --git a/core/event/management/condition/LastStateCondition.hpp b/core/event/management/condition/LastStateCondition.hpp new file mode 100644 index 0000000..89ec58e --- /dev/null +++ b/core/event/management/condition/LastStateCondition.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_LASTSTATECONDITION_HPP +#define MAD_LASTSTATECONDITION_HPP + +#include "Condition.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" +namespace mad::core { + struct LastStateCondition : Condition { + public: + LastStateCondition(std::shared_ptr m_machine, StateMachine::StateId m_to_state_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + std::shared_ptr m_machine; + StateMachine::StateId m_to_state_id; + }; +}// namespace mad::core + +#endif//MAD_LASTSTATECONDITION_HPP diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp new file mode 100644 index 0000000..f3ef8dd --- /dev/null +++ b/core/event/management/controller/Idle.cpp @@ -0,0 +1,6 @@ +#include "Idle.hpp" +mad::core::Idle::Idle() { +} +void mad::core::Idle::control() { + +} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp new file mode 100644 index 0000000..e7ea1ff --- /dev/null +++ b/core/event/management/controller/Idle.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_IDLE_HPP +#define MAD_IDLE_HPP +#include "Controller.hpp" + +namespace mad::core { + + class Idle : public Controller { + public: + explicit Idle(); + + void control() override; + + private: + + }; + +} + + +#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp new file mode 100644 index 0000000..9e5dd5a --- /dev/null +++ b/core/event/management/controller/Jump.cpp @@ -0,0 +1,15 @@ +#include "Jump.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +} +void mad::core::Jump::control() { + + auto impulse = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); + }); + }; + + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); +} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp new file mode 100644 index 0000000..25d5cf1 --- /dev/null +++ b/core/event/management/controller/Jump.hpp @@ -0,0 +1,25 @@ +#ifndef MAD_JUMP_HPP +#define MAD_JUMP_HPP + +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" +namespace mad::core { + + class Jump : public Controller { + public: + + explicit Jump(std::shared_ptr world, Entity::Id entity_id); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + + }; + +} + +#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp new file mode 100644 index 0000000..3fe6107 --- /dev/null +++ b/core/event/management/controller/Run.cpp @@ -0,0 +1,21 @@ +#include "Run.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +} +void mad::core::Run::control() { + + auto force = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); + }); + }; + //SPDLOG_DEBUG("controller 2"); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); + } + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp new file mode 100644 index 0000000..00c03e5 --- /dev/null +++ b/core/event/management/controller/Run.hpp @@ -0,0 +1,29 @@ +#ifndef MAD_RUN_HPP +#define MAD_RUN_HPP +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Run : public Controller { + public: + enum class Direction { + Right, + Left, + }; + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + Direction dir; + + }; + +} + +#endif//MAD_RUN_HPP diff --git a/core/event/management/controller/statemachine/StateMachine.cpp b/core/event/management/controller/statemachine/StateMachine.cpp index b986148..ab5f66c 100644 --- a/core/event/management/controller/statemachine/StateMachine.cpp +++ b/core/event/management/controller/statemachine/StateMachine.cpp @@ -13,6 +13,7 @@ void mad::core::Transition::handle(const mad::core::Event &event) { if (!is_active || m_state_machine->has_made_transition) return; if (m_condition->is_triggered_by(event)) { m_state_machine->has_made_transition = true; + m_state_machine->m_previous_state_id = m_state_machine->m_current_state_id; m_state_machine->m_current_state_id = next_state; SPDLOG_DEBUG("current state {}", m_state_machine->m_current_state_id); for (auto &i : m_state_machine->m_transitions[current_state]) { @@ -41,6 +42,7 @@ mad::core::StateMachine::StateId mad::core::StateMachine::add_state(const std::s } void mad::core::StateMachine::set_initial_state(mad::core::StateMachine::StateId state_id) { m_current_state_id = state_id; + m_previous_state_id = state_id; for (auto &i : m_transitions[state_id]) { i->is_active = true; } @@ -52,3 +54,6 @@ void mad::core::StateMachine::add_transition(mad::core::StateMachine::StateId st } mad::core::StateMachine::StateMachine(std::shared_ptr m_dispatcher) : m_dispatcher(std::move(m_dispatcher)){ } +mad::core::StateMachine::StateId mad::core::StateMachine::get_previous_state_id() { + return m_previous_state_id; +} diff --git a/core/event/management/controller/statemachine/StateMachine.hpp b/core/event/management/controller/statemachine/StateMachine.hpp index 733e029..05e4791 100644 --- a/core/event/management/controller/statemachine/StateMachine.hpp +++ b/core/event/management/controller/statemachine/StateMachine.hpp @@ -21,9 +21,12 @@ namespace mad::core { void add_transition(StateId state_id_from, StateId state_id_to, std::shared_ptr transition_condition); void set_initial_state(StateId state_id); void control() override; + StateId get_previous_state_id(); + private: StateId m_current_state_id = -1; + StateId m_previous_state_id = -1; std::vector> m_states; std::vector>> m_transitions; std::shared_ptr m_dispatcher; diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 4b19898..9276a96 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -1,9 +1,10 @@ #include "LevelLoaderFromFile.hpp" -#include "event/management/condition/KeyDownCondition.hpp" -#include "event/management/condition/KeyPressedCondition.hpp" -#include "event/management/condition/TimerCondition.hpp" -#include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/statemachine/StateMachine.hpp" +#include <../../game/mobs/hero/Hero.hpp> +#include +#include +#include +#include +#include #include @@ -18,7 +19,7 @@ namespace mad::core { std::unique_ptr LevelLoaderFromFile::load(std::shared_ptr global_dispatcher, std::shared_ptr system_listener) { - auto level_dispatcher = std::make_shared(); + level_dispatcher = std::make_shared(); auto world = std::make_shared(*level_dispatcher); @@ -26,17 +27,22 @@ namespace mad::core { m_config_json["camera"]["position"]["y"]}; auto camera = std::make_shared(camera_position, world); + controllers = {std::make_shared( + camera)}; + + Entity::Id hero_id = create_world(world); camera->turn_on(*level_dispatcher, hero_id); level_dispatcher->registry(camera); - level_dispatcher->registry(std::make_shared(world, hero_id)); + //level_dispatcher->registry(std::make_shared(world, hero_id)); + /* std::vector> controllers { std::make_shared(camera) };*/ - ///State Machine + /*///State Machine struct C1 : mad::core::Controller { void control() override { //SPDLOG_DEBUG("controller 1"); @@ -56,7 +62,7 @@ namespace mad::core { machine->set_initial_state(0); std::vector> controllers{machine, std::make_shared( - camera)}; + camera)};*/ auto level_runner = std::make_unique( system_listener, @@ -65,8 +71,7 @@ namespace mad::core { global_dispatcher, level_dispatcher, world, - controllers - ); + controllers); level_dispatcher->registry(std::make_shared(*level_runner)); level_dispatcher->registry(std::make_shared(*level_runner)); @@ -82,7 +87,7 @@ namespace mad::core { Entity::Id hero_id = 0; std::string map_line; while (std::getline(m_level_map, map_line)) { - for (char object: map_line) { + for (char object : map_line) { switch (m_objects[object]) { case Objects::UnstableBlock: { create_block(world, @@ -99,9 +104,8 @@ namespace mad::core { break; } case Objects::Hero: { - hero_id = create_hero(world, - {current_position_x, - current_position_y}); + Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); + hero_id = hero.get_hero_id(); break; } case Objects::Enemy1: { @@ -137,16 +141,14 @@ namespace mad::core { {{ImageStorage::TypeAction::Idle, std::make_shared(source, block_size, block_size, - StaticImage::TransformType::Tile) - }})); + StaticImage::TransformType::Tile)}})); Entity::Id square_id = world->create_physical_entity( 0, position, 0, image_storage, - is_stable - ); + is_stable); } Entity::Id LevelLoaderFromFile::create_hero(std::shared_ptr world, Vec2d position) { @@ -185,10 +187,9 @@ namespace mad::core { position, 0, image_storage, - false, false - ); + false, false); return hero_id; } -} \ No newline at end of file +}// namespace mad::core \ No newline at end of file diff --git a/core/loader/LevelLoaderFromFile.hpp b/core/loader/LevelLoaderFromFile.hpp index e12e665..46d2f52 100644 --- a/core/loader/LevelLoaderFromFile.hpp +++ b/core/loader/LevelLoaderFromFile.hpp @@ -115,6 +115,10 @@ namespace mad::core { std::ifstream m_level_map; + std::vector> controllers; + + std::shared_ptr level_dispatcher; + std::unordered_map m_objects = { {'.', Objects::Empty}, {'#', Objects::StableBlock}, diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp new file mode 100644 index 0000000..8407ce7 --- /dev/null +++ b/game/mobs/hero/Hero.cpp @@ -0,0 +1,86 @@ +#include "Hero.hpp" +#include "event/management/condition/KeyDownCondition.hpp" +#include "event/management/condition/KeyPressedCondition.hpp" +#include "event/management/condition/KeyReleasedCondition.hpp" +#include "event/management/condition/LastStateCondition.hpp" +#include "event/management/condition/TimerCondition.hpp" +#include "event/management/condition/TrueCondition.hpp" +#include "event/management/controller/Idle.hpp" +#include "event/management/controller/Jump.hpp" +#include "event/management/controller/Run.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" +mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ + std::filesystem::path source(m_config_json["animated_resources"]); + source /= m_config_json["hero"]["source"]; + + std::shared_ptr image_storage; + + image_storage = std::make_shared( + std::unordered_map>( + {{ImageStorage::TypeAction::Idle, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], + m_config_json["hero"]["animated"]["actions"]["idle"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"]) + }, + {ImageStorage::TypeAction::Run, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], + m_config_json["hero"]["animated"]["actions"]["run"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }} + ) + ); + + hero_id = world->create_physical_entity( + 0, + position, + 0, + image_storage, + false, false + ); + + + ///State Machine + struct C1 : mad::core::Controller { + void control() override { + //SPDLOG_DEBUG("controller 1"); + }; + }; + struct C2 : mad::core::Controller { + void control() override { + //SPDLOG_DEBUG("controller 2"); + }; + }; + auto machine = std::make_shared( + std::shared_ptr(level_dispatcher)); + machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(2, 0, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(1, 2, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(2, 1, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(3, 0, std::make_shared(machine, 0)); + machine->add_transition(3, 1, std::make_shared(machine, 1)); + machine->add_transition(3, 2, std::make_shared(machine, 2)); + machine->set_initial_state(0); + controllers.push_back(machine); +} +mad::core::Entity::Id mad::core::Hero::get_hero_id() const { + return hero_id; +} diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp new file mode 100644 index 0000000..d8795df --- /dev/null +++ b/game/mobs/hero/Hero.hpp @@ -0,0 +1,23 @@ +#ifndef MAD_HERO_HPP +#define MAD_HERO_HPP + +#include "loader/LevelLoaderFromFile.hpp" +#include "world/LocalWorld.hpp" +#include +#include "world/entity/PhysicalEntity.hpp" +#include +namespace mad::core { + class Hero { + public: + Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers); + Entity::Id get_hero_id() const; + + private: + std::shared_ptr m_world; + Entity::Id hero_id; + std::shared_ptr level_dispatcher; + int last_pressed_key; + }; +}// namespace mad::core + +#endif//MAD_HERO_HPP From 6ddb7fb9f297477ea378f91f5e943c89ddc199e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 22:04:45 +0300 Subject: [PATCH 08/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 6 ++++-- core/event/management/controller/Idle.hpp | 7 +++++-- core/event/management/controller/Run.cpp | 6 +++++- core/event/management/controller/Run.hpp | 6 +++--- core/world/LocalWorld.cpp | 3 +++ core/world/LocalWorld.hpp | 2 ++ game/mobs/hero/Hero.cpp | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp index f3ef8dd..282c2ba 100644 --- a/core/event/management/controller/Idle.cpp +++ b/core/event/management/controller/Idle.cpp @@ -1,6 +1,8 @@ #include "Idle.hpp" -mad::core::Idle::Idle() { +mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } -void mad::core::Idle::control() { +void mad::core::Idle::control() { + m_entity->set_action(ImageStorage::TypeAction::Idle); } diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp index e7ea1ff..fa94200 100644 --- a/core/event/management/controller/Idle.hpp +++ b/core/event/management/controller/Idle.hpp @@ -1,17 +1,20 @@ #ifndef MAD_IDLE_HPP #define MAD_IDLE_HPP #include "Controller.hpp" +#include "world/LocalWorld.hpp" namespace mad::core { class Idle : public Controller { public: - explicit Idle(); + explicit Idle(std::shared_ptr world, Entity::Id entity_id); void control() override; private: - + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity* m_entity; }; } diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp index 3fe6107..c8cfd7b 100644 --- a/core/event/management/controller/Run.cpp +++ b/core/event/management/controller/Run.cpp @@ -1,6 +1,8 @@ #include "Run.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +#include +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } void mad::core::Run::control() { @@ -11,6 +13,7 @@ void mad::core::Run::control() { }); }; //SPDLOG_DEBUG("controller 2"); + m_entity->set_action(ImageStorage::TypeAction::Run); if(dir == Direction::Right){ m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); } @@ -18,4 +21,5 @@ void mad::core::Run::control() { m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); } + } diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp index 00c03e5..07ed05c 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Run.hpp @@ -12,15 +12,15 @@ namespace mad::core { Right, Left, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); void control() override; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id m_entity_id; - std::shared_ptr key; Direction dir; + PhysicalEntity* m_entity; }; diff --git a/core/world/LocalWorld.cpp b/core/world/LocalWorld.cpp index b65987c..d104bdc 100644 --- a/core/world/LocalWorld.cpp +++ b/core/world/LocalWorld.cpp @@ -93,3 +93,6 @@ mad::core::Entity::Id mad::core::LocalWorld::create_physical_entity(int z_ind, m mad::core::Entity &mad::core::LocalWorld::get_entity(mad::core::Entity::Id id) noexcept { return m_storage.get_entity(id); } +mad::core::EntityStorage &mad::core::LocalWorld::get_storage() { + return m_storage; +} diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 14c38a8..4f4d4c6 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -34,6 +34,8 @@ namespace mad::core { Entity::Id create_physical_entity(int z_ind, Vec2d initial_position, float initial_rotation, std::shared_ptr image_storage, bool is_fixed = false, bool is_rotated = true) override; + EntityStorage& get_storage(); + private: std::shared_ptr>> m_step_events_queue; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 8407ce7..379854a 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -62,7 +62,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); machine->add_state(std::make_shared(world, hero_id)); From b9f34fa8ca974ef8c3dbe1a780c168d731bdc40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:01:08 +0300 Subject: [PATCH 09/44] set animations in statemachine --- core/CMakeLists.txt | 2 +- core/event/management/controller/Fall.cpp | 6 ++ core/event/management/controller/Fall.hpp | 17 +++ core/event/management/controller/FlyUp.cpp | 6 ++ core/event/management/controller/FlyUp.hpp | 18 ++++ .../management/controller/GroundMovement.cpp | 7 ++ .../management/controller/GroundMovement.hpp | 17 +++ core/event/management/controller/Idle.cpp | 8 -- core/event/management/controller/Idle.hpp | 23 ---- .../controller/{Jump.cpp => JumpImpulse.cpp} | 8 +- .../controller/{Jump.hpp => JumpImpulse.hpp} | 10 +- core/event/management/controller/Movement.cpp | 27 +++++ .../controller/{Run.hpp => Movement.hpp} | 18 ++-- core/event/management/controller/Run.cpp | 25 ----- .../event/management/controller/StartJump.cpp | 6 ++ .../event/management/controller/StartJump.hpp | 17 +++ core/visual/image/storage/ImageStorage.hpp | 5 +- core/world/LocalWorld.cpp | 3 + core/world/LocalWorld.hpp | 2 +- core/world/entity/PhysicalEntity.cpp | 10 +- core/world/entity/PhysicalEntity.hpp | 1 + game/mobs/hero/Hero.cpp | 98 ++++++++++++++++-- game/mobs/hero/Hero.hpp | 1 + .../hero/hero_fall/adventurer-fall-00.png | Bin 0 -> 1004 bytes .../hero/hero_fall/adventurer-fall-01.png | Bin 0 -> 999 bytes .../hero/hero_fly_up/adventurer-jump-03.png | Bin 0 -> 1019 bytes .../hero/hero_idle/adventurer-idle-00.png | Bin 0 -> 1134 bytes .../hero/hero_idle/adventurer-idle-01.png | Bin 0 -> 1127 bytes .../hero/hero_idle/adventurer-idle-02.png | Bin 0 -> 1206 bytes .../hero/hero_idle/adventurer-idle-03.png | Bin 0 -> 1110 bytes .../hero/hero_jump/adventurer-jump-00.png | Bin 0 -> 1095 bytes .../hero/hero_jump/adventurer-jump-01.png | Bin 0 -> 1049 bytes .../hero/hero_jump/adventurer-jump-02.png | Bin 0 -> 1094 bytes .../hero/hero_jump/adventurer-jump-03.png | Bin 0 -> 1019 bytes .../hero/hero_run/adventurer-run-00.png | Bin 0 -> 1073 bytes .../hero/hero_run/adventurer-run-01.png | Bin 0 -> 1043 bytes .../hero/hero_run/adventurer-run-02.png | Bin 0 -> 963 bytes .../hero/hero_run/adventurer-run-03.png | Bin 0 -> 1140 bytes .../hero/hero_run/adventurer-run-04.png | Bin 0 -> 1075 bytes .../hero/hero_run/adventurer-run-05.png | Bin 0 -> 859 bytes game/resources/levels/level_01/config.json | 53 ++++++++-- game/resources/levels/level_01/map | 2 +- 42 files changed, 292 insertions(+), 98 deletions(-) create mode 100644 core/event/management/controller/Fall.cpp create mode 100644 core/event/management/controller/Fall.hpp create mode 100644 core/event/management/controller/FlyUp.cpp create mode 100644 core/event/management/controller/FlyUp.hpp create mode 100644 core/event/management/controller/GroundMovement.cpp create mode 100644 core/event/management/controller/GroundMovement.hpp delete mode 100644 core/event/management/controller/Idle.cpp delete mode 100644 core/event/management/controller/Idle.hpp rename core/event/management/controller/{Jump.cpp => JumpImpulse.cpp} (65%) rename core/event/management/controller/{Jump.hpp => JumpImpulse.hpp} (57%) create mode 100644 core/event/management/controller/Movement.cpp rename core/event/management/controller/{Run.hpp => Movement.hpp} (50%) delete mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/StartJump.cpp create mode 100644 core/event/management/controller/StartJump.hpp create mode 100644 game/resources/animated/hero/hero_fall/adventurer-fall-00.png create mode 100644 game/resources/animated/hero/hero_fall/adventurer-fall-01.png create mode 100644 game/resources/animated/hero/hero_fly_up/adventurer-jump-03.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-00.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-01.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-02.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-03.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-00.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-01.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-02.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-03.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-00.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-01.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-02.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-03.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-04.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-05.png diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index a8995e7..e5e0a8a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Fall.cpp b/core/event/management/controller/Fall.cpp new file mode 100644 index 0000000..ed817e6 --- /dev/null +++ b/core/event/management/controller/Fall.cpp @@ -0,0 +1,6 @@ +#include "Fall.hpp" + +mad::core::Fall::Fall(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Fall; + Idle_animation = ImageStorage::TypeAction::Fall; +} diff --git a/core/event/management/controller/Fall.hpp b/core/event/management/controller/Fall.hpp new file mode 100644 index 0000000..4e8274d --- /dev/null +++ b/core/event/management/controller/Fall.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_FALL_HPP +#define MAD_FALL_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Fall : public Movement { + public: + Fall(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_FALL_HPP diff --git a/core/event/management/controller/FlyUp.cpp b/core/event/management/controller/FlyUp.cpp new file mode 100644 index 0000000..969d7e2 --- /dev/null +++ b/core/event/management/controller/FlyUp.cpp @@ -0,0 +1,6 @@ +#include "FlyUp.hpp" + +mad::core::FlyUp::FlyUp(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Fly_up; + Idle_animation = ImageStorage::TypeAction::Fly_up; +} diff --git a/core/event/management/controller/FlyUp.hpp b/core/event/management/controller/FlyUp.hpp new file mode 100644 index 0000000..e87bc4a --- /dev/null +++ b/core/event/management/controller/FlyUp.hpp @@ -0,0 +1,18 @@ +#ifndef MAD_FLYUP_HPP +#define MAD_FLYUP_HPP + + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class FlyUp : public Movement { + public: + FlyUp(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_FLYUP_HPP diff --git a/core/event/management/controller/GroundMovement.cpp b/core/event/management/controller/GroundMovement.cpp new file mode 100644 index 0000000..b8e127e --- /dev/null +++ b/core/event/management/controller/GroundMovement.cpp @@ -0,0 +1,7 @@ + +#include "GroundMovement.hpp" + +mad::core::GroundMovement::GroundMovement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Run; + Idle_animation = ImageStorage::TypeAction::Idle; +} diff --git a/core/event/management/controller/GroundMovement.hpp b/core/event/management/controller/GroundMovement.hpp new file mode 100644 index 0000000..339fe34 --- /dev/null +++ b/core/event/management/controller/GroundMovement.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_GROUNDMOVEMENT_HPP +#define MAD_GROUNDMOVEMENT_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class GroundMovement : public Movement { + public: + GroundMovement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_GROUNDMOVEMENT_HPP diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp deleted file mode 100644 index 282c2ba..0000000 --- a/core/event/management/controller/Idle.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Idle.hpp" -mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} - -void mad::core::Idle::control() { - m_entity->set_action(ImageStorage::TypeAction::Idle); -} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp deleted file mode 100644 index fa94200..0000000 --- a/core/event/management/controller/Idle.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAD_IDLE_HPP -#define MAD_IDLE_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" - -namespace mad::core { - - class Idle : public Controller { - public: - explicit Idle(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - PhysicalEntity* m_entity; - }; - -} - - -#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/JumpImpulse.cpp similarity index 65% rename from core/event/management/controller/Jump.cpp rename to core/event/management/controller/JumpImpulse.cpp index 9e5dd5a..6ffc28d 100644 --- a/core/event/management/controller/Jump.cpp +++ b/core/event/management/controller/JumpImpulse.cpp @@ -1,8 +1,8 @@ -#include "Jump.hpp" +#include "JumpImpulse.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +mad::core::JumpImpulse::JumpImpulse(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { } -void mad::core::Jump::control() { +void mad::core::JumpImpulse::control() { auto impulse = [](mad::core::Vec2d dir) { return mad::core::LambdaIntent( @@ -11,5 +11,5 @@ void mad::core::Jump::control() { }); }; - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -2000000.0f})); } diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/JumpImpulse.hpp similarity index 57% rename from core/event/management/controller/Jump.hpp rename to core/event/management/controller/JumpImpulse.hpp index 25d5cf1..5e69a29 100644 --- a/core/event/management/controller/Jump.hpp +++ b/core/event/management/controller/JumpImpulse.hpp @@ -1,15 +1,15 @@ -#ifndef MAD_JUMP_HPP -#define MAD_JUMP_HPP +#ifndef MAD_JUMPIMPULSE_HPP +#define MAD_JUMPIMPULSE_HPP #include "Controller.hpp" #include "world/LocalWorld.hpp" #include "world/World.hpp" namespace mad::core { - class Jump : public Controller { + class JumpImpulse : public Controller { public: - explicit Jump(std::shared_ptr world, Entity::Id entity_id); + explicit JumpImpulse(std::shared_ptr world, Entity::Id entity_id); void control() override; @@ -22,4 +22,4 @@ namespace mad::core { } -#endif//MAD_JUMP_HPP +#endif//MAD_JUMPIMPULSE_HPP diff --git a/core/event/management/controller/Movement.cpp b/core/event/management/controller/Movement.cpp new file mode 100644 index 0000000..a580c78 --- /dev/null +++ b/core/event/management/controller/Movement.cpp @@ -0,0 +1,27 @@ +#include "Movement.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Movement::Movement(std::shared_ptr world, Entity::Id entity_id, mad::core::Movement::Direction dir, float velocity) : m_world(world), m_entity_id(entity_id), dir(dir), velocity(velocity){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); +} +void mad::core::Movement::control() { + auto set_horizontal_velocity = [](float vel) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).set_linear_horizontal_velocity(vel, event_dispatcher); + }); + }; + if(dir == Direction::Right || dir == Direction::Left){ + m_entity->set_action(Move_animation); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(velocity)); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(-velocity)); + } + } + else if(dir == Direction::Idle){ + m_entity->set_action(Idle_animation); + } + + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Movement.hpp similarity index 50% rename from core/event/management/controller/Run.hpp rename to core/event/management/controller/Movement.hpp index 07ed05c..2bac02d 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Movement.hpp @@ -1,18 +1,21 @@ -#ifndef MAD_RUN_HPP -#define MAD_RUN_HPP +#ifndef MAD_MOVEMENT_HPP +#define MAD_MOVEMENT_HPP + + #include "Controller.hpp" #include "world/LocalWorld.hpp" #include "world/World.hpp" namespace mad::core { - class Run : public Controller { + class Movement : public Controller { public: enum class Direction { Right, Left, + Idle, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Movement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); void control() override; @@ -21,9 +24,12 @@ namespace mad::core { Entity::Id m_entity_id; Direction dir; PhysicalEntity* m_entity; - + float velocity; + protected: + ImageStorage::TypeAction Move_animation; + ImageStorage::TypeAction Idle_animation; }; } -#endif//MAD_RUN_HPP +#endif//MAD_MOVEMENT_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp deleted file mode 100644 index c8cfd7b..0000000 --- a/core/event/management/controller/Run.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Run.hpp" -#include "world/intent/LambdaIntent.hpp" -#include -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} -void mad::core::Run::control() { - - auto force = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); - }); - }; - //SPDLOG_DEBUG("controller 2"); - m_entity->set_action(ImageStorage::TypeAction::Run); - if(dir == Direction::Right){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); - } - else if(dir == Direction::Left){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); - } - - -} diff --git a/core/event/management/controller/StartJump.cpp b/core/event/management/controller/StartJump.cpp new file mode 100644 index 0000000..c124a52 --- /dev/null +++ b/core/event/management/controller/StartJump.cpp @@ -0,0 +1,6 @@ +#include "StartJump.hpp" + +mad::core::StartJump::StartJump(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Jump; + Idle_animation = ImageStorage::TypeAction::Jump; +} diff --git a/core/event/management/controller/StartJump.hpp b/core/event/management/controller/StartJump.hpp new file mode 100644 index 0000000..ea4df13 --- /dev/null +++ b/core/event/management/controller/StartJump.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_STARTJUMP_HPP +#define MAD_STARTJUMP_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class StartJump : public Movement { + public: + StartJump(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_STARTJUMP_HPP diff --git a/core/visual/image/storage/ImageStorage.hpp b/core/visual/image/storage/ImageStorage.hpp index 5699096..d866bd0 100644 --- a/core/visual/image/storage/ImageStorage.hpp +++ b/core/visual/image/storage/ImageStorage.hpp @@ -13,7 +13,10 @@ namespace mad::core { enum class TypeAction { Idle, Run, - Attack + Attack, + Jump, + Fly_up, + Fall, }; explicit ImageStorage(std::unordered_map> actions); diff --git a/core/world/LocalWorld.cpp b/core/world/LocalWorld.cpp index d104bdc..efa14c6 100644 --- a/core/world/LocalWorld.cpp +++ b/core/world/LocalWorld.cpp @@ -54,6 +54,9 @@ void mad::core::LocalWorld::produce(mad::core::EventDispatcher &dispatcher) { for (Entity::Id entity_id : m_storage.extract(TrueFilter())) { if (auto physical_entity = cast_to_or_null(m_storage.get_entity(entity_id)); physical_entity != nullptr) { physical_entity->synchronize_position_with_viewable(); + if(abs(physical_entity->get_linear_velocity().get_y()) > 0.01){ + //SPDLOG_DEBUG("vel {}", physical_entity->get_linear_velocity().get_y()); + } } } diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 4f4d4c6..4cb88c3 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -22,7 +22,7 @@ namespace mad::core { class LocalWorld : public World { public: - explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 30.0f}); + explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 60.0f}); bool manipulate(const Filter &filter, const Intent &intent) override; diff --git a/core/world/entity/PhysicalEntity.cpp b/core/world/entity/PhysicalEntity.cpp index 9b58177..6f94482 100644 --- a/core/world/entity/PhysicalEntity.cpp +++ b/core/world/entity/PhysicalEntity.cpp @@ -37,8 +37,10 @@ mad::core::PhysicalEntity::PhysicalEntity(std::int32_t id, int z_ind, Vec2d init b2FixtureDef fixtureDef; fixtureDef.shape = &dynamicBox; fixtureDef.density = 1.0f; - fixtureDef.friction = 0.3f; - fixtureDef.restitution = 0.2f; + fixtureDef.friction = 0.0f; + fixtureDef.restitution = 0.0f; + body->SetLinearDamping(0.0000000001); + body->SetAngularDamping(0); body->CreateFixture(&fixtureDef); body->SetTransform(body->GetPosition(), initial_rotation); @@ -69,6 +71,10 @@ void mad::core::PhysicalEntity::apply_force_to_center(mad::core::Vec2d force, ma void mad::core::PhysicalEntity::set_linear_velocity(mad::core::Vec2d velocity, mad::core::EventDispatcher &dispatcher) { body->SetLinearVelocity(velocity); } +void mad::core::PhysicalEntity::set_linear_horizontal_velocity(float velocity, mad::core::EventDispatcher &dispatcher) { + body->SetLinearVelocity({velocity, body->GetLinearVelocity().y}); +} + void mad::core::PhysicalEntity::apply_angular_impulse(float impulse, mad::core::EventDispatcher &dispatcher, bool awake) { body->ApplyAngularImpulse(impulse, awake); } diff --git a/core/world/entity/PhysicalEntity.hpp b/core/world/entity/PhysicalEntity.hpp index fff81c2..6c3e0fd 100644 --- a/core/world/entity/PhysicalEntity.hpp +++ b/core/world/entity/PhysicalEntity.hpp @@ -45,6 +45,7 @@ namespace mad::core { void apply_angular_impulse(float impulse, EventDispatcher &dispatcher, bool awake = true); void apply_torque(float torque, EventDispatcher &dispatcher, bool awake = true); void set_linear_velocity(Vec2d velocity, EventDispatcher &dispatcher); + void set_linear_horizontal_velocity(float velocity, EventDispatcher &dispatcher); void set_angular_velocity(float velocity, EventDispatcher &dispatcher); void set_linear_damping(float linear_damping, EventDispatcher &dispatcher); void set_angular_damping(float angular_damping, EventDispatcher &dispatcher); diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 379854a..dcee27d 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,9 +5,12 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Idle.hpp" -#include "event/management/controller/Jump.hpp" -#include "event/management/controller/Run.hpp" +#include "event/management/controller/Fall.hpp" +#include "event/management/controller/FlyUp.hpp" +#include "event/management/controller/GroundMovement.hpp" +#include "event/management/controller/JumpImpulse.hpp" +#include "event/management/controller/Movement.hpp" +#include "event/management/controller/StartJump.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -36,6 +39,36 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }, + {ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fly_up, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fall, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -62,10 +95,21 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -75,9 +119,43 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(3, 0, std::make_shared(machine, 0)); - machine->add_transition(3, 1, std::make_shared(machine, 1)); - machine->add_transition(3, 2, std::make_shared(machine, 2)); + + machine->add_transition(3, 5, std::make_shared()); + machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); + + float t = 1; + + machine->add_transition(4, 8, std::make_shared(t)); + machine->add_transition(5, 8, std::make_shared(t)); + machine->add_transition(6, 8, std::make_shared(t)); + + machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(7, 11, std::make_shared(t)); + machine->add_transition(8, 11, std::make_shared(t)); + machine->add_transition(9, 11, std::make_shared(t)); + + machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(10, 0, std::make_shared(t)); + machine->add_transition(11, 0, std::make_shared(t)); + machine->add_transition(12, 0, std::make_shared(t)); + + + + + + + machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index d8795df..70c3953 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,6 +17,7 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; + float horizontal_velocity = 81; }; }// namespace mad::core diff --git a/game/resources/animated/hero/hero_fall/adventurer-fall-00.png b/game/resources/animated/hero/hero_fall/adventurer-fall-00.png new file mode 100644 index 0000000000000000000000000000000000000000..3a4b30fb90d8d77f591fa2c00b728f6fdcaa5c5b GIT binary patch literal 1004 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 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-00.png b/game/resources/animated/hero/hero_idle/adventurer-idle-00.png new file mode 100644 index 0000000000000000000000000000000000000000..3bd528e863cf02b31c7cd6cc923034015a745f60 GIT binary patch literal 1134 zcmV-!1d;oRP)XYxd z%)~`q3?`ZwGQ&ccn#forX7!Td>ckZaLiyKW|4~Z0K3wjV%Cb%FX*7mUa?{h_J?H#> z-*e9IoO5BDZMNBFn|}eR7@dB2<}{55_p2LisYFsLmv;d0=u2-2_gN~uMotB8iwUFd#mtzN=4xA) zAxbo+g>+vGbF8_FbMFNJ_`}`Dp+!`H!Qd#nZ=9zuAmR2Mp)Vj&_4x7sX0ihuZma}A z$(*4MShLx9a6Utg)5*Zu9{kVxwD+HkajLRTeXR(|E^Pb#ampt>J@mb*^nS`@JPv@r zvJTJ$6dThc6Yl6_IuWN@cB;yJgmB;qrsra`{xV_+dU9X0QUB|k*GWC~jN$u@w_i0I z0w8Ecs%59TAwYu~rxVbE*QvGJ`B^IpJx@#}d$^;Mh4kjLVR2!C$#|T)4=w|mApNPm z@Ey~0F#s~zWi##z*z$~oJ36_YP4R$3E|`tbjbV=d8ezxl?-Eq{nQ|luS+!(uKm8m* zrJuzG?FMkL@u&a^8e0|;OW(%h*rh7-5ddS90hacZLeD#!+Du(|lL~to;NkgK-e)E{ z#_-Km9@%Gpg>Sis<<%9G`3RHoI4wOt&;kUNexl)!#L(yJQYN<^G*r1gTBAvA_iF3t z0${h-CoE64oFhvs={wrJ2O9pWlgSaX`l!~0+!^(5FYgyK$$rlOLRKFS*ZTpec6$g} zeWZ`QfI~V=Q0X_}dNZbWE&ZGTjKF52zfoZ?GnUo#T+Dc?+#YfR-9#oX6|@n7kaI*2 z=t|Fds=Rw~W^w>DFh<4t4h7m$1IP_@OIPeQs@_HfTNbjAOiHXTuh>sPW7nFE-ogod zF{iJ*m4bGs+!B*n73>)8MIik0cH;PBL{h7&EXyPkg@>hXt1B;+dIyGt`W61oK9es+ zmhBr&`e3P`iJ8geM7uTrJ@R*ItoNSe`>FF!5iVq}O{LwI*Apm$kezE;wPO9&yT4pw z%XzUgBwWZ+JkEGBMfxruP2h($07*qoM6N<$f|lkf AqW}N^ literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-01.png b/game/resources/animated/hero/hero_idle/adventurer-idle-01.png new file mode 100644 index 0000000000000000000000000000000000000000..230c1cb30f47fc1ae3db9e1f34429b345a4926dd GIT binary patch literal 1127 zcmV-t1ep7YP)ESc;_C9 zN~YPOF@}(l7a8lA02vurp5=gLRm^pN?Vjl0Cv3cj&Psl!Yu-+WQxzf z_?nL9Z2+i?D%)EE8o+#ft|W(Nn#kTxpH?ATq)a-;z~v|a*Qal20iTyEp=)$BZ$oh^ zj1GrUoC<(O2{NI~tbv+3nM^vTRmc|hcKQGa_`JqlT~rO-!m((WCbE*wNjjP4hwOaW z`!M0?l(8O;PH`o4%@~&oris{O3vR_G0kkyPH9*^ysvsPlLUAe_{4B^|R}USJx*6>1 zF-VDqkX$|AyPMXgYHesF!cF&i=8iqZWOe?G-hAU=k#79NRT}y}7XFS1samZ~)c}Ok zhw!hVQqWL)cSsAncVOXtrc#(FG~FvdPv=EukP7`~6b zdql(|h>M6$0-)AiL(H{;|HBIac&e(5%Xj)aeT#N`OaBZ)i0A|gQQ3WzQ1~LFc9j8_ zg8`R=-(G%=Q1~J<@mT=UnH3T40f8-wPGwg@4HS`Zx_mfYzM_5m4ZrG0z? zfTgh1yHZtwlV`YzKENoH5Ld90WHhmRW%xKx)vpNQ-!ibUMA zljWT+0T2pbH0!zurioNqZGWgf5!r)ddKIV3N9}qvAYaY0-+X{wYAsY3QoT$Q3C~Xy z%`0DjPikit>SY!eqRhl+i!Ok%Q+xiMEedR;%G}hiWYbvy8i?Uo*eC!?>+-@q&4JxQ z{0kwXlepA(lDoY3QU#oe>lt&aNcVZSL@c8b={src5dqUgVu=K)A3{dj%uQYAQd~n( z6jZhNM@mr?&cs#xTgs`-S1Vy(cj3AENarrBR;vc+M06jTq9_1lvso#4`Fo*$h4orG ztX8WKoxcm=L_D^?4suPIn6G&ugcI@KvBthyE2^rp)w+?oTdhc{s`7*_iMKq<+s}#X zv!Db-?6*=HK%2bGefBa&hJuU?1#wCl+T>*boMkzoEj*Nfh@+|sfPmLSt!=}+(~=YI zstCe~=vd8Wr5eYbMY0M@nKYS9mBe33h%6-%BvQ+~`pE@DcIw+vGPyNlzLFCgA>l-p t5(y@gDVG1_?{6}h!e+4ue^34w_#H}Ld7*XQd&mF)002ovPDHLkV1mdw8z%q& literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-02.png b/game/resources/animated/hero/hero_idle/adventurer-idle-02.png new file mode 100644 index 0000000000000000000000000000000000000000..2668b590bc2ab2ffead9465e8f2538ae88cd34c8 GIT binary patch literal 1206 zcmV;n1WEgeP)t%mk;?vU!GyH0*Y1*|JHBF2?Ep!3V(Y$=@}%tAyU6o77fqMR6#M z-0+|{6abAhR6>SP1BIJqqKk1YTQMmjn21F-;Z!UVKy{^61GE<+*?4>tC=P|AUk}h%cZAyKo%Gcm z(MgGhkXpUiR?m*g0`2;+mwV2OOt-wmc){8poqX?Tl5X%+KNTIH3-1vjr`C?j0suUV z$0)rodwgb<{pHmJPxZsgrnUL6e#Ko-`lmLGLdebp`wr1|(M?6~cbd0$4^zPaW&PLm z`Tgb9`uM`=4I-~J>b_5W^sa~y#AIad6Dy6}(mHGR08r#Cq}XoP=P!)j(8n%W=I6Dc z&|}zevwNEk(^*lLB%2Bb@aHd4`spPAitTp&=Q{HvQ^5cL(dA`YPJV1O1V8{0fJW~v zEkS1FmjRsqK60B*Fyy(+h*hOK-$r-7jk|BX!;t4PbF)6Cf&sF#vb3jPe3gOG6~i$Y zDlKo*VZyN`a?KWCEfWp1^Nd&_+v85c zXJP~97h`zkVzzC07JwDMzD!%br$||w)WjRI;j9?SNTD@Pdsvoxyj6l!5&)Uiudz_` zCZ(Vu`5W8|30E;DG199bLsI)vYWB5ZMO4kK6J@Fg6 z2tb+4+^jEUjT0F2ou|}wfU6zt0Q%Digj|RT5?4Fgd936K?29n~D)3{Q4d{CF_vNuG zr=@dpPePnhp8p1hi16rP=;E2yC;N{X_gD0Bri0&($Q*oKHS4-OJt(QjqR_f0!@ z;+YSVkXX0tilT5Q4MYrEY#tnhb%EB@*FAEL*=#oIHU+|u-@=SXzc>9Ioqr19M9Onb z?6rhZRh2yRgG}X_kyKS>uO&=LW{eLG?h@)(IFX{9EX`)Ovr}H+Noxkf*9REBK7d1t zvQu6Fz>yIba^$W@T5fg#cS$itmIvk?rg*ws0cj+%5{pTNwoOU0Y*U6b9*(5NUs{OF zheCuR3p9UuNtb=`{Rq+cs{Vf|E;d8LiOh#WjE5sEM3??jXFMFiVloNulm7+&0QQ2K U4h?yP-v9sr07*qoM6N<$f=IDF&Hw-a literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-03.png b/game/resources/animated/hero/hero_idle/adventurer-idle-03.png new file mode 100644 index 0000000000000000000000000000000000000000..53207e8a2f1ed323478a1e16c27559eff02c46ba GIT binary patch literal 1110 zcmV-c1gZOpP)BW*kqGUHreDqK&gh)Q%4Wc(RPn0?Mv$^rB>Slz@cWE!eOWhbOWU%kSjcK7uN1{}-fQQ} z6T1jSqQ-bA66IX*qS3Av6$`PcW;~ir0qE+m3qU-Owi1d&(OeowKAK>xZ;;;mJ&g4Y z8lq$)Wv`w-@i4nP++ut(%pac9EWGh3)9%6=z4G#r4Yu*)=V={!S9*;|Ikk3oxB&=d zj?#3a@2~HBJe*8Q_!|Lt(@lL;ijrIB3K^_WDaQrcilC!UKo7@>ZH=>#PVZUL)N55RCwrCh{{yq}c>prmRT<%d3NsQOI7}+H z$`*^w5HTB{XL%_?-@q|~p;2b+I$_ldK;OV1!O$qnONEQG=fTIBxV%PpOXa0nc4~+F z`|)cY>a4Y5xOIoI%F9a;dVakIJ5&IYnVcb{H50?3TKJI$UU>6UV-7Nel;vT#zaPgP zb|QLQ)LCnJGb<^I~ZP+YC=agV*wD@zwQ*yafRP28j0k9CgVzi4Qia1mY$xIGFq?VLYF%?tp z<}_B(>vU3_(AlAr)ccxgQZ0sIv33C1){Q4N20*=gm-yOd?DNICJr`Q&~=?U%lctbXF<_*oqe_xzM34bKG`ERu5=;w zR+9kOqponb-NfYh1e46vuxfYUac ziD~?J=z~qAO)-9yX!;Qo1F=N|uA&lbf!(FJEO1%(3%bzpVPRc_KIk1@%>I&_+?=^N zbN+MAoS6$*vSi7UB}DrKD$J1^)>(^GZCt4JQ83kG^uPM?^ETds90k@u_&!t4u=}u zY5U0dZRv5B(lhW20D8X8V80jN*a-1>Oy0}izeQO_<`Rpds92N1@r112ZWk{dc@%(9 zUnu|{cPWvX2ztH_u;N_>$}(cpawybo0-$DxT>^66-ip`fPk-a}`O}%nw5vdwkke;} zc%o(#@4rzCz@LR*;eY#MSs%0F_4(2Bb&j6xqqnJ@+PXq|o7&T&RFI>}(NIepTb{N6 zoa`QZ9%JNNe69z`8NEr^F7W>mqPa@Y>J~WiAEebS_*LYItJivz%&(+t47Ic|5i!`T zyQFt&l%d)u(_@uAR|psePi?J984je@?!v8dI`$Qa{Q9FRLQp3Jkln-m#10-#+XsK^ z<8gwNOxp+;2EgBffDejXVlKJBd#B$q9fN5hLoIDg$0HQjb@}d67n+$)og+;x?L<3I z0jv|Xgv6WD681X?ycq;s3{>sEp5!s$H=ofWcP4Cb)7c=81PhhgOP%%p2Eh246O5lZ zK{$~FV7B8pvmM8Ql;9;yAB?8*Ik#{J@6;#(!=S|FS~c#}EC7TPNd~Q3fRr$&W}&XC zK^V8k8Q`+4_Uwa{nEzZMri6s=#8=stS9#KZ3wwrr=Qa-$p&$fqvf;p60-)Gg!Iz&L zW8liyY%VM^6N>38O1dNhhQaKTh-;l6vZ=HjS0ag1vyfZ!3;>g%AP;L6X2Zj>%-u{Z zJ|WJX?^4n^P2aULJ5lh*fz+x4ll~E0q{@o^PXVX`!hi)B^##;vcQ@9fTP&F-LB@VsOQ2bl-F`DEv94J)>-t-*T*#Y;8>n;$_S>RVE(9sH-c1Y0 zvmhdo2>WeO)zhjMV$(EfOD3dq>42 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-01.png b/game/resources/animated/hero/hero_jump/adventurer-jump-01.png new file mode 100644 index 0000000000000000000000000000000000000000..b20e0343c77fa6ecb46aa2cfeccfa0f8699f6427 GIT binary patch literal 1049 zcmV+!1m^pRP)izazx1zV>AS_=w^KI)u_p$@kw8d z8Z_}?I+1`ebIQV8e1SL@rB)%5O*>i`mI9@=rF306K6KO;>(f0?+D~$mbI&>Vch2|z z&iVa*P@+VM5+zEMC{d!s{{^AS(D4qpG+PZKmCP{mZ6MeG!RZqm+`C8S&rQVQqFmbn zK+E&5DOrD;5-WhS+Da;!k!Gub;~nl?e6Y$cYPpWjx2G9fSCZsURGO5T6H6@Wh-qXgeND}8}r zZjLVyWZXNQYpXYN zp_$%3me*qJEYsvrV*>yS;Sej!*${k`5H-sd<{}XQ9)00(_QS6;I8L>Qmp_^2op;~X zyA6FpW_tTrO(nS7TrP(i8wvy%jb_o_^OTGao&hKjv&r?AcADC{Mbpu4j@+v+fa(?k zNZ-;8YTvsEfY&#M|Cb+xf9gjXlXJ5A>1@J_51wIS!_5T@q;+k*r7rgY~MT|%O%1c6w%=$Of{ zjk4|8SQ1U9nKIV{Sz$J-iMIXiB64#cFJtnKS9FQdC*;;z!MoQt2EbzQcT8L6-nY-g zLO29-zp?$1Hw8eoZ4Y05dJ^xYi&QzBdbXmwM9CF{n<6d`4p8Z;W7mdc?N%C_)r7J6 zF#s0BAsVbER-@Nst@{{>wFPnRvk@gBSa+?p8Hqwad9!~USPc3}Br?>P1<_<0CO-#Y zKM(~>z>UBKYTd__)mplY40UzMts!;OZnWAchr_bi7(EWbtLML0mJC5>W?zoS^EV^% z9)`mbP1FAIjizb*n?OD2I$9^MT!A89J<{nY#^dcA(u$rM zrAKKi%7s|0R$0Zm?6$;dyd7e%%_IPJ8`HQfh*&H}w~yB&|KhI)(S z=kKnv+myyB)?|-E5K3i~dq=sDXe5F!I7fUvB>>^H-BmC?8&BXg8`R(S{|bKrE6Hcb TLPIqs00000NkvXXu0mjfd%y9w literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-02.png b/game/resources/animated/hero/hero_jump/adventurer-jump-02.png new file mode 100644 index 0000000000000000000000000000000000000000..ba27779940e0644fb74d1bfdf8d863c973b2036d GIT binary patch literal 1094 zcmV-M1iAZ(P)9&_Hb*pLGr17@BNpIHcLz6VIq9Z$3eaQFaa_%|z ze1G5b`+d(j7b>Wrf(k154lQ`Zg1OY=G(7-If~C8q^Ti*J8+XY(D$?y9!1J5 zf5M|Xf+o2|nxC8J!%t4Iy?s-mzy01W034=W8mA>0$qB*jRfIp|Geg0(M4}S~F|!># zw1@6veDE2*(0nvC1ZWLy6FraJQ#NOnoX}Sz(Ch>t6kJ<)Y6-1m%=+HLBxa&?J^2DQ zkB8w)*|Pa85u)0vMC^)=r$#j+(TT$QNOXd;Bj-!Tc6RqN5*Z@cy4jqajg`%5iIC97 zdH@Fc?quigB_h!Yygo0_elSe9v$teya_Xu87>Nu~R~Il>&vt#V#OzH07w_(EQKL|imLx2|t`pb&Rl8hwYaG`g16x#W7Bag}WvKO9D zXdvo&lVuTlCSCTzS|S8s%dvhlGCd9tKLM-+4{-ChUjcA3*KT@f4|*mooOVaqeA0zn z=-$uFf`;Ga1z>&fL5$Ddp?Tjy0OpPzBD~=i9#2jIknpV$2L}3YnAehw_+4J}=F({1cM#WbSPG}q?KhtdfR_5@EjZPzQ0r8wb*cc2*;@J3*XzYF3@M8#t+a~0QR8r|3Qp6sRo`fuhN`M%->-@xMM&No0CSm) zsBt>Y8izxCb2N_8|=8zN{kOn~on7XZ4h|G!G>w#F9m zyRHkD&BmBZ}hywXp0V{x${B9%;Xm)|A;j+`08tteno6-d7{sy3UM%AF&ss)~SN6v{_-7K$M~ zBdKJP%X9P0XS2dE3`>JAhV+bFo}0&|REz0!hF8ygFMIk5D)_hY2che3yBE_uw*UYD M07*qoM6N<$f+g)C)c^nh literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-03.png b/game/resources/animated/hero/hero_jump/adventurer-jump-03.png new file mode 100644 index 0000000000000000000000000000000000000000..0458013c8dae7ecf137a009f0de9d2dc5fb7c074 GIT binary patch literal 1019 zcmVHJ^vVQpW(c}v>cx7okus_yS(ar3JEV;Dv^i{T*}CJ!)paNe35`SSfONF=l! zfW7aWCmQKi<8np@U@|#OD7;U}X4ATOYG%Z2X%Oj!JjvU?Z<()*PbP=)cmj$ZKEwCO zbgZ90WQm~5tDH#>bK#RtJ|3JQ?FmtyS|@kT(RcSbI!3=B?FrEp8z36#=0K~dYCWb} znYc1@oeQ6J^7;5-(w?Gf;@xf^;Nxl-P9-+XO^*CP`o^R#Zo`aB$NI?@msJx0-@G>s zZyp99=nnv}IC~9%k5(%| zgQ|^Wi_4m7RHD*^+h!)0-)J$@{$l{#TTFA$vBS`han%o-j`eRjr2tVj(s%Sl!ls8? z9zDk729a5B#A>w?A0Dk%hKi~;dwL}+9OfpLR|{pKnwQei-9=`-#B9N-StrZ#=2b~? zx$NZg`Tuuny)<;We7U8Nc4q@OAE2qmBNLi?=++(Sd^S3k&`4O#U%FF5pJ=u>7Tc)aNMsJ!I0LfnUS0%aqGb{ z%WG@GE7tgSbb{u_5^jrG>~K0r7fWJ~-MHU~n*FoC{mNd&ZfX=OYb7rJG^NG|Uw;8M p_r>7Qc&+H`sH2WL>Zs%K#Gfd5Tp^4i<(B{e002ovPDHLkV1llc@^t_J literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-00.png b/game/resources/animated/hero/hero_run/adventurer-run-00.png new file mode 100644 index 0000000000000000000000000000000000000000..e3d7cc057f4e6efed4564cae0c022f961089639c GIT binary patch literal 1073 zcmV-11kU@3P)-L~*N`~w~w_wx-vWOaAj0Tr1#<;j-qKOzD_ka(^N1x1$ z&X}lV2_{Q)VF4#B!HhU@z*x40Ez6)V7<6!9m(sy)IX>LAw!&0yZ+Wrbm)@Rp`uqOA z=llEh^b~T)A%`4t$iX_qMiZX+;2^tqRmjw_h`u0vsvm&8jUQWz>&!g0^&zql;pC6) zJX`%F0Q#&><(?`Da5p?{d1Lcz%I`np*6j&d72L-8!K(nMMJiVYh6s(`VsSAd|K;Nk z#fA!bZGVu^@-%(Xt5gNIq0j2cxzuMX*lg|-ExsH?$kr~SC)Ak_N2Quh8qsEH@Zyge1)v9?%~&S7b$(z zgDb2ub|=g$m4ZV-fv>2HLqWkcQ7F2)&s*Zk%Gd93!(jks7Ilifssy-RI{?7G-8=dI z{b2xJetZwSWbWnAcQ>hPX%I!v9kIk|tB|z>oVj5NC^^=_NT{8O;Y-Q&k6q|7#XP{7 z8v~-LzuywKtvxceI7g|sP!@aDq=523fN@PrTeo#{DU;zT$^(Jqx=dk$V4#(ATw%W^(;IwIr58P~L=fN@Qupt)7J zVa z&){|!1JJt?GzVSgOUZ*>pZuj0=e-HB!?;aTo3(>5fvnv}T2D=<^+p1T@=Bopo)kCZ zZhFslXT-N5_mQ9Po0leC*Ma4lZ`x47VEEdbS*=-l{*;_B-_4(N6HDpRT34nkj4wxdQmg3?G zuQ`7Cx4w*dv*L)7pD#BB0=!dE#14OcTC$J0T>_xg<)E#*&lVAo1tBrRNPR16%lye? zzd3gWpVJ9hIKOOfcBi7qc}+tqiYWB^Y5KM^ZNBC7?{-s~ymkki*EB{KBDfrRgtR%k r!#@Ou!00000NkvXXu0mjf3}y^* literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-01.png b/game/resources/animated/hero/hero_run/adventurer-run-01.png new file mode 100644 index 0000000000000000000000000000000000000000..96d832012e63466c4cfc2b9e5b864f7af21b1e72 GIT binary patch literal 1043 zcmV+u1nm2XP)2%@jT z9`t2H%IuT4maPSmLF4|wS~9H8Qm|=8m&G(IH~o{`n_eH%dw08vy4<7%$rmo1^SkHX z-|ut&p96K(Raaeg)m0Z_JDlG5>J!tMU()g-sDuD`sqfQ@{wcW+>&Z3v{V<(}+X2uP zG@kE>nE-!g9#mYhTLyBb_W*#IzPCcGt(Eb~DLN0gql6WHnMk076#$b8dr3nTV|^mU z+FH>TG&}E1SE4NeIn#T9VxhFjo=DCyJ~?Hl-KeG@cY98fiNDPoN1O2aJZAdd3cY$O ziR2tgSmE@yw}^M0qVtsq@vc)gR3)nFtToi#O-o=mK99_9Uy$swMq@xR!|yF~{mxyk zOuokc8`qd^D%an~AD!Ot{rPJ%;)4%AugJG+kfH8wJ6+Iqe6noDn)ceZk?9Gds>)B# z9Rgraq=n$+Apnj)+W~KS07zV%p?jc5gkRkV_g__wS<7A%e6ma`mm`(S5mi+HqN+-< zZxF^lV^5@o`AnME*WZmyPjH+L0AfvhsT2aL08-F(;ge-EmCM;S3&OHBQ*H@Msm9fE zIaEfbC)|brQ~@MkD3HnL?R->K9|4@bB34(k;ApjlY?4sVSpZU(&Jjg*8v;-TkQH6G z(@qH1$DiNdX#SBL24Fsu1|Waw9E&UE??UgEq2%E~SL3x>E4%PX5~*Cy^huH^7{;ao z^O-d7y#M7U`_+qI5d7^jQtLri0k{U~zkS=8-B7FFtY-218-a3{`a8{M((DI}xnEty zQPaJa)vW^YuYndO6JwjoEM$}Dr8OaY+^x-9vT2O3wE-|XcmaTB#|+jiOG2iB{_nLe N002ovPDHLkV1oY={2u@S literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-02.png b/game/resources/animated/hero/hero_run/adventurer-run-02.png new file mode 100644 index 0000000000000000000000000000000000000000..2e3b74df0890213dc31ab88d93038a14e31daed2 GIT binary patch literal 963 zcmV;!13dhRP) z<(}{RpYNRWoqM57nKEU{lqpl@u0xdC;is?fXM5W=nQu#|ap7<|0qB19h@pNhg@?92 zhYqv?$mLW<41M)GiFksO-<+YRqa6TsQN_E%CjsUobA|_YLs6prAH){Z65#sG4e4vz z%$2|x0InJr!BK^&$?GJO3At`3>rgTwIebl<^{cw5>h}D$5lk2IaC^1hKK{fml&NX` zUYVNKGm~#OLcwd~%idlI;Hz!cZ3{_NY_humsM(#A4YlJ8olG%bjodPG8-;0lI@&q- zfu9#Y`-DUH{=&e`J#cZ*a2y2-xut2M(rT4wCq{MK-mN?IxxV<39iD>52lo*Hyvg5~ zB*vA%7`>rE&i4qQi}Niokm(g%xN0blg16s+?ru_=CILKdw{G{NbY)*Sm!a;pZc+32K|^sAEaX^cCx9*_7hq0QzKCGR&n{-O z&-29Oc=Ot|JHGvjN{dB=qfx9C6#^g}jp~6u`~2GkLw;IQVVr&aIQ#kuZ(8QZ`&;q2 z-FVz?>@8ah8dTFOyMJQkU$x=PTaW7PU}X!>?0+E}$feWbmE#{9_G7w`!BgiXK!@*X z-8OvUD8G&=0C;cxLAA}wWAA^@@QI`JzkAqFOrZdBA36{_`W^@Yg>T6taF67vAJ={pH@W?%q$#{aRDn-pij#6yD z@;7+Nz3ouqa7oPiQL)T?#UuuA+70S{AfS@n&4fe+Rv^+Y2DKI2|md)8fP7KvDWF lSsnQ=t7}Gb2L|)5<{u@>Infw4#AN^g002ovPDHLkV1mT5)A0ZR literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-03.png b/game/resources/animated/hero/hero_run/adventurer-run-03.png new file mode 100644 index 0000000000000000000000000000000000000000..a512930ec81d583aac03630d3d9fa7e4441facf0 GIT binary patch literal 1140 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 Date: Sat, 14 May 2022 21:35:29 +0300 Subject: [PATCH 10/44] create Hero 2.0 --- core/CMakeLists.txt | 2 +- core/event/management/controller/Idle.cpp | 6 ++ core/event/management/controller/Idle.hpp | 20 +++++ core/event/management/controller/Jump.cpp | 15 ++++ core/event/management/controller/Jump.hpp | 25 ++++++ core/event/management/controller/Run.cpp | 21 +++++ core/event/management/controller/Run.hpp | 29 +++++++ core/loader/LevelLoaderFromFile.cpp | 37 +++++---- game/mobs/hero/Hero.cpp | 98 +++-------------------- game/mobs/hero/Hero.hpp | 1 - 10 files changed, 145 insertions(+), 109 deletions(-) create mode 100644 core/event/management/controller/Idle.cpp create mode 100644 core/event/management/controller/Idle.hpp create mode 100644 core/event/management/controller/Jump.cpp create mode 100644 core/event/management/controller/Jump.hpp create mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/Run.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index e5e0a8a..a8995e7 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp new file mode 100644 index 0000000..f3ef8dd --- /dev/null +++ b/core/event/management/controller/Idle.cpp @@ -0,0 +1,6 @@ +#include "Idle.hpp" +mad::core::Idle::Idle() { +} +void mad::core::Idle::control() { + +} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp new file mode 100644 index 0000000..e7ea1ff --- /dev/null +++ b/core/event/management/controller/Idle.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_IDLE_HPP +#define MAD_IDLE_HPP +#include "Controller.hpp" + +namespace mad::core { + + class Idle : public Controller { + public: + explicit Idle(); + + void control() override; + + private: + + }; + +} + + +#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp new file mode 100644 index 0000000..9e5dd5a --- /dev/null +++ b/core/event/management/controller/Jump.cpp @@ -0,0 +1,15 @@ +#include "Jump.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +} +void mad::core::Jump::control() { + + auto impulse = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); + }); + }; + + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); +} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp new file mode 100644 index 0000000..25d5cf1 --- /dev/null +++ b/core/event/management/controller/Jump.hpp @@ -0,0 +1,25 @@ +#ifndef MAD_JUMP_HPP +#define MAD_JUMP_HPP + +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" +namespace mad::core { + + class Jump : public Controller { + public: + + explicit Jump(std::shared_ptr world, Entity::Id entity_id); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + + }; + +} + +#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp new file mode 100644 index 0000000..3fe6107 --- /dev/null +++ b/core/event/management/controller/Run.cpp @@ -0,0 +1,21 @@ +#include "Run.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +} +void mad::core::Run::control() { + + auto force = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); + }); + }; + //SPDLOG_DEBUG("controller 2"); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); + } + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp new file mode 100644 index 0000000..00c03e5 --- /dev/null +++ b/core/event/management/controller/Run.hpp @@ -0,0 +1,29 @@ +#ifndef MAD_RUN_HPP +#define MAD_RUN_HPP +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Run : public Controller { + public: + enum class Direction { + Right, + Left, + }; + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + Direction dir; + + }; + +} + +#endif//MAD_RUN_HPP diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 9276a96..0b1443d 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -10,7 +10,8 @@ namespace mad::core { - LevelLoaderFromFile::LevelLoaderFromFile(const std::filesystem::path &path) : m_level_directory(path) { + LevelLoaderFromFile::LevelLoaderFromFile(const std::filesystem::path &path) : m_level_directory(path), + m_level_map(path / "map") { std::ifstream input_config(path / "config.json"); CHECK_THROW(input_config, FileDoesNotExist, "Config file does not exist"); CHECK_THROW(m_level_map, FileDoesNotExist, "Map file does not exist"); @@ -162,25 +163,23 @@ namespace mad::core { image_storage = std::make_shared( std::unordered_map>( {{ImageStorage::TypeAction::Idle, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], - m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"]) - }, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], + + m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"])}, {ImageStorage::TypeAction::Run, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], - m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) - }} - ) - ); + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], + + m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"])}})); hero_id = world->create_physical_entity( 0, diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index dcee27d..8407ce7 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,12 +5,9 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Fall.hpp" -#include "event/management/controller/FlyUp.hpp" -#include "event/management/controller/GroundMovement.hpp" -#include "event/management/controller/JumpImpulse.hpp" -#include "event/management/controller/Movement.hpp" -#include "event/management/controller/StartJump.hpp" +#include "event/management/controller/Idle.hpp" +#include "event/management/controller/Jump.hpp" +#include "event/management/controller/Run.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -39,36 +36,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) - }, - {ImageStorage::TypeAction::Jump, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], - m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) - }, - {ImageStorage::TypeAction::Fly_up, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) - }, - {ImageStorage::TypeAction::Fall, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], - m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -95,21 +62,10 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - - + machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); + machine->add_state(std::make_shared(world, hero_id)); machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -119,43 +75,9 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - - machine->add_transition(3, 5, std::make_shared()); - machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - - float t = 1; - - machine->add_transition(4, 8, std::make_shared(t)); - machine->add_transition(5, 8, std::make_shared(t)); - machine->add_transition(6, 8, std::make_shared(t)); - - machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); - - machine->add_transition(7, 11, std::make_shared(t)); - machine->add_transition(8, 11, std::make_shared(t)); - machine->add_transition(9, 11, std::make_shared(t)); - - machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); - - machine->add_transition(10, 0, std::make_shared(t)); - machine->add_transition(11, 0, std::make_shared(t)); - machine->add_transition(12, 0, std::make_shared(t)); - - - - - - - + machine->add_transition(3, 0, std::make_shared(machine, 0)); + machine->add_transition(3, 1, std::make_shared(machine, 1)); + machine->add_transition(3, 2, std::make_shared(machine, 2)); machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index 70c3953..d8795df 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,7 +17,6 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; - float horizontal_velocity = 81; }; }// namespace mad::core From 773fbdaed9aea4d114cf69a85322de00f598d38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 22:04:45 +0300 Subject: [PATCH 11/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 6 ++++-- core/event/management/controller/Idle.hpp | 7 +++++-- core/event/management/controller/Run.cpp | 6 +++++- core/event/management/controller/Run.hpp | 6 +++--- game/mobs/hero/Hero.cpp | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp index f3ef8dd..282c2ba 100644 --- a/core/event/management/controller/Idle.cpp +++ b/core/event/management/controller/Idle.cpp @@ -1,6 +1,8 @@ #include "Idle.hpp" -mad::core::Idle::Idle() { +mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } -void mad::core::Idle::control() { +void mad::core::Idle::control() { + m_entity->set_action(ImageStorage::TypeAction::Idle); } diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp index e7ea1ff..fa94200 100644 --- a/core/event/management/controller/Idle.hpp +++ b/core/event/management/controller/Idle.hpp @@ -1,17 +1,20 @@ #ifndef MAD_IDLE_HPP #define MAD_IDLE_HPP #include "Controller.hpp" +#include "world/LocalWorld.hpp" namespace mad::core { class Idle : public Controller { public: - explicit Idle(); + explicit Idle(std::shared_ptr world, Entity::Id entity_id); void control() override; private: - + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity* m_entity; }; } diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp index 3fe6107..c8cfd7b 100644 --- a/core/event/management/controller/Run.cpp +++ b/core/event/management/controller/Run.cpp @@ -1,6 +1,8 @@ #include "Run.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +#include +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } void mad::core::Run::control() { @@ -11,6 +13,7 @@ void mad::core::Run::control() { }); }; //SPDLOG_DEBUG("controller 2"); + m_entity->set_action(ImageStorage::TypeAction::Run); if(dir == Direction::Right){ m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); } @@ -18,4 +21,5 @@ void mad::core::Run::control() { m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); } + } diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp index 00c03e5..07ed05c 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Run.hpp @@ -12,15 +12,15 @@ namespace mad::core { Right, Left, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); void control() override; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id m_entity_id; - std::shared_ptr key; Direction dir; + PhysicalEntity* m_entity; }; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 8407ce7..379854a 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -62,7 +62,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); machine->add_state(std::make_shared(world, hero_id)); From 4aeac709efb4bb27fce4208b8cd1ba8ec7482a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:01:08 +0300 Subject: [PATCH 12/44] set animations in statemachine --- core/CMakeLists.txt | 2 +- core/event/management/controller/Idle.cpp | 8 -- core/event/management/controller/Idle.hpp | 23 ------ core/event/management/controller/Jump.cpp | 15 ---- core/event/management/controller/Jump.hpp | 25 ------ core/event/management/controller/Run.cpp | 25 ------ core/event/management/controller/Run.hpp | 29 ------- game/mobs/hero/Hero.cpp | 98 ++++++++++++++++++++--- game/mobs/hero/Hero.hpp | 1 + 9 files changed, 90 insertions(+), 136 deletions(-) delete mode 100644 core/event/management/controller/Idle.cpp delete mode 100644 core/event/management/controller/Idle.hpp delete mode 100644 core/event/management/controller/Jump.cpp delete mode 100644 core/event/management/controller/Jump.hpp delete mode 100644 core/event/management/controller/Run.cpp delete mode 100644 core/event/management/controller/Run.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index a8995e7..e5e0a8a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp deleted file mode 100644 index 282c2ba..0000000 --- a/core/event/management/controller/Idle.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Idle.hpp" -mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} - -void mad::core::Idle::control() { - m_entity->set_action(ImageStorage::TypeAction::Idle); -} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp deleted file mode 100644 index fa94200..0000000 --- a/core/event/management/controller/Idle.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAD_IDLE_HPP -#define MAD_IDLE_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" - -namespace mad::core { - - class Idle : public Controller { - public: - explicit Idle(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - PhysicalEntity* m_entity; - }; - -} - - -#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp deleted file mode 100644 index 9e5dd5a..0000000 --- a/core/event/management/controller/Jump.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Jump.hpp" -#include "world/intent/LambdaIntent.hpp" -mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { -} -void mad::core::Jump::control() { - - auto impulse = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); - }); - }; - - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); -} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp deleted file mode 100644 index 25d5cf1..0000000 --- a/core/event/management/controller/Jump.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAD_JUMP_HPP -#define MAD_JUMP_HPP - -#include "Controller.hpp" -#include "world/LocalWorld.hpp" -#include "world/World.hpp" -namespace mad::core { - - class Jump : public Controller { - public: - - explicit Jump(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - std::shared_ptr key; - - }; - -} - -#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp deleted file mode 100644 index c8cfd7b..0000000 --- a/core/event/management/controller/Run.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Run.hpp" -#include "world/intent/LambdaIntent.hpp" -#include -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} -void mad::core::Run::control() { - - auto force = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); - }); - }; - //SPDLOG_DEBUG("controller 2"); - m_entity->set_action(ImageStorage::TypeAction::Run); - if(dir == Direction::Right){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); - } - else if(dir == Direction::Left){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); - } - - -} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp deleted file mode 100644 index 07ed05c..0000000 --- a/core/event/management/controller/Run.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MAD_RUN_HPP -#define MAD_RUN_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" -#include "world/World.hpp" - -namespace mad::core { - - class Run : public Controller { - public: - enum class Direction { - Right, - Left, - }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - Direction dir; - PhysicalEntity* m_entity; - - }; - -} - -#endif//MAD_RUN_HPP diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 379854a..dcee27d 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,9 +5,12 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Idle.hpp" -#include "event/management/controller/Jump.hpp" -#include "event/management/controller/Run.hpp" +#include "event/management/controller/Fall.hpp" +#include "event/management/controller/FlyUp.hpp" +#include "event/management/controller/GroundMovement.hpp" +#include "event/management/controller/JumpImpulse.hpp" +#include "event/management/controller/Movement.hpp" +#include "event/management/controller/StartJump.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -36,6 +39,36 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }, + {ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fly_up, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fall, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -62,10 +95,21 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -75,9 +119,43 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(3, 0, std::make_shared(machine, 0)); - machine->add_transition(3, 1, std::make_shared(machine, 1)); - machine->add_transition(3, 2, std::make_shared(machine, 2)); + + machine->add_transition(3, 5, std::make_shared()); + machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); + + float t = 1; + + machine->add_transition(4, 8, std::make_shared(t)); + machine->add_transition(5, 8, std::make_shared(t)); + machine->add_transition(6, 8, std::make_shared(t)); + + machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(7, 11, std::make_shared(t)); + machine->add_transition(8, 11, std::make_shared(t)); + machine->add_transition(9, 11, std::make_shared(t)); + + machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(10, 0, std::make_shared(t)); + machine->add_transition(11, 0, std::make_shared(t)); + machine->add_transition(12, 0, std::make_shared(t)); + + + + + + + machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index d8795df..70c3953 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,6 +17,7 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; + float horizontal_velocity = 81; }; }// namespace mad::core From 42a92ea1a00f701f0c66db9b741d5656cad7e2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:51:00 +0300 Subject: [PATCH 13/44] ? --- core/event/management/controller/Movement.cpp | 2 ++ .../image/animated/RenderableAnimatedSeveralFiles.cpp | 2 +- core/world/entity/PhysicalEntity.cpp | 2 +- game/mobs/hero/Hero.cpp | 7 +------ game/resources/levels/level_01/config.json | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Movement.cpp b/core/event/management/controller/Movement.cpp index a580c78..53d6cea 100644 --- a/core/event/management/controller/Movement.cpp +++ b/core/event/management/controller/Movement.cpp @@ -13,9 +13,11 @@ void mad::core::Movement::control() { if(dir == Direction::Right || dir == Direction::Left){ m_entity->set_action(Move_animation); if(dir == Direction::Right){ + m_entity->flip_over(Image::Orientation::Right); m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(velocity)); } else if(dir == Direction::Left){ + m_entity->flip_over(Image::Orientation::Left); m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(-velocity)); } } diff --git a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp index f53e098..7f63794 100644 --- a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp +++ b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp @@ -22,7 +22,7 @@ namespace mad::core { m_textures.push_back(texture); } - std::reverse(m_textures.begin(), m_textures.end()); + //std::reverse(m_textures.begin(), m_textures.end()); auto [texture_width, texture_height] = m_textures[0].getSize(); diff --git a/core/world/entity/PhysicalEntity.cpp b/core/world/entity/PhysicalEntity.cpp index 6f94482..478df92 100644 --- a/core/world/entity/PhysicalEntity.cpp +++ b/core/world/entity/PhysicalEntity.cpp @@ -37,7 +37,7 @@ mad::core::PhysicalEntity::PhysicalEntity(std::int32_t id, int z_ind, Vec2d init b2FixtureDef fixtureDef; fixtureDef.shape = &dynamicBox; fixtureDef.density = 1.0f; - fixtureDef.friction = 0.0f; + fixtureDef.friction = 50.0f; fixtureDef.restitution = 0.0f; body->SetLinearDamping(0.0000000001); body->SetAngularDamping(0); diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index dcee27d..dc26bfb 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -23,7 +23,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {{ImageStorage::TypeAction::Idle, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], - m_config_json["hero"]["animated"]["actions"]["idle"]["count_files"], m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], @@ -33,7 +32,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {ImageStorage::TypeAction::Run, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], - m_config_json["hero"]["animated"]["actions"]["run"]["count_files"], m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], @@ -43,7 +41,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {ImageStorage::TypeAction::Jump, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], - m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], @@ -53,7 +50,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {ImageStorage::TypeAction::Fly_up, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], @@ -63,7 +59,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {ImageStorage::TypeAction::Fall, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], - m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], @@ -126,7 +121,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - float t = 1; + float t = 2; machine->add_transition(4, 8, std::make_shared(t)); machine->add_transition(5, 8, std::make_shared(t)); diff --git a/game/resources/levels/level_01/config.json b/game/resources/levels/level_01/config.json index 29f0003..31d26c9 100644 --- a/game/resources/levels/level_01/config.json +++ b/game/resources/levels/level_01/config.json @@ -44,7 +44,7 @@ "type": "several_files", "width_scale": 1, "height_scale": 1, - "delta_time": 250, + "delta_time": 500, "size_width": 100, "size_height": 74, "count_files": 4 From 9492389c643de521bc0a210db1bcbe9e3a9ac912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 21:35:29 +0300 Subject: [PATCH 14/44] create Hero 2.0 --- core/CMakeLists.txt | 2 +- .../condition/KeyReleasedCondition.cpp | 15 ++++ .../condition/KeyReleasedCondition.hpp | 18 ++++ .../condition/LastStateCondition.cpp | 13 +++ .../condition/LastStateCondition.hpp | 20 +++++ core/event/management/controller/Idle.cpp | 6 ++ core/event/management/controller/Idle.hpp | 20 +++++ core/event/management/controller/Jump.cpp | 15 ++++ core/event/management/controller/Jump.hpp | 25 ++++++ core/event/management/controller/Run.cpp | 21 +++++ core/event/management/controller/Run.hpp | 29 +++++++ .../controller/statemachine/StateMachine.cpp | 5 ++ .../controller/statemachine/StateMachine.hpp | 3 + core/loader/LevelLoaderFromFile.cpp | 45 +++++----- core/loader/LevelLoaderFromFile.hpp | 4 + game/mobs/hero/Hero.cpp | 86 +++++++++++++++++++ game/mobs/hero/Hero.hpp | 23 +++++ 17 files changed, 327 insertions(+), 23 deletions(-) create mode 100644 core/event/management/condition/KeyReleasedCondition.cpp create mode 100644 core/event/management/condition/KeyReleasedCondition.hpp create mode 100644 core/event/management/condition/LastStateCondition.cpp create mode 100644 core/event/management/condition/LastStateCondition.hpp create mode 100644 core/event/management/controller/Idle.cpp create mode 100644 core/event/management/controller/Idle.hpp create mode 100644 core/event/management/controller/Jump.cpp create mode 100644 core/event/management/controller/Jump.hpp create mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/Run.hpp create mode 100644 game/mobs/hero/Hero.cpp create mode 100644 game/mobs/hero/Hero.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b1ae6b4..a8995e7 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/condition/KeyReleasedCondition.cpp b/core/event/management/condition/KeyReleasedCondition.cpp new file mode 100644 index 0000000..fd9df64 --- /dev/null +++ b/core/event/management/condition/KeyReleasedCondition.cpp @@ -0,0 +1,15 @@ +#include "KeyReleasedCondition.hpp" +#include +#include +std::unordered_set mad::core::KeyReleasedCondition::triggers() { + return {mad::core::Event::Type::KeyReleased}; +} +bool mad::core::KeyReleasedCondition::is_triggered_by(const mad::core::Event &event) { + const auto &keystroke = const_cast_to(event); + return keystroke.key_id == m_key_id; +} + +mad::core::KeyReleasedCondition::KeyReleasedCondition(const int m_key_id) : m_key_id(m_key_id){ +} +void mad::core::KeyReleasedCondition::on_start() { +} diff --git a/core/event/management/condition/KeyReleasedCondition.hpp b/core/event/management/condition/KeyReleasedCondition.hpp new file mode 100644 index 0000000..ec846c9 --- /dev/null +++ b/core/event/management/condition/KeyReleasedCondition.hpp @@ -0,0 +1,18 @@ +#ifndef MAD_KEYRELEASEDCONDITION_HPP +#define MAD_KEYRELEASEDCONDITION_HPP + +#include "Condition.hpp" +namespace mad::core { + struct KeyReleasedCondition : Condition { + public: + explicit KeyReleasedCondition(int m_key_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + const int m_key_id; + }; +}// namespace mad::core + +#endif//MAD_KEYRELEASEDCONDITION_HPP diff --git a/core/event/management/condition/LastStateCondition.cpp b/core/event/management/condition/LastStateCondition.cpp new file mode 100644 index 0000000..a2fb453 --- /dev/null +++ b/core/event/management/condition/LastStateCondition.cpp @@ -0,0 +1,13 @@ +#include "LastStateCondition.hpp" + +bool mad::core::LastStateCondition::is_triggered_by(const mad::core::Event &event) { + return m_to_state_id == m_machine->get_previous_state_id(); +} +std::unordered_set mad::core::LastStateCondition::triggers() { + return {mad::core::Event::Type::KeyPressed, mad::core::Event::Type::Collision, mad::core::Event::Type::KeyHeld, mad::core::Event::Type::KeyReleased, mad::core::Event::Type::LevelPause, mad::core::Event::Type::Menu, mad::core::Event::Type::Movement, mad::core::Event::Type::Runner, mad::core::Event::Type::Visual, mad::core::Event::Type::WindowClose}; +} +void mad::core::LastStateCondition::on_start() { +} +mad::core::LastStateCondition::LastStateCondition(std::shared_ptr m_machine, mad::core::StateMachine::StateId m_to_state_id) : m_machine(m_machine), m_to_state_id(m_to_state_id){ + +} diff --git a/core/event/management/condition/LastStateCondition.hpp b/core/event/management/condition/LastStateCondition.hpp new file mode 100644 index 0000000..89ec58e --- /dev/null +++ b/core/event/management/condition/LastStateCondition.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_LASTSTATECONDITION_HPP +#define MAD_LASTSTATECONDITION_HPP + +#include "Condition.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" +namespace mad::core { + struct LastStateCondition : Condition { + public: + LastStateCondition(std::shared_ptr m_machine, StateMachine::StateId m_to_state_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + std::shared_ptr m_machine; + StateMachine::StateId m_to_state_id; + }; +}// namespace mad::core + +#endif//MAD_LASTSTATECONDITION_HPP diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp new file mode 100644 index 0000000..f3ef8dd --- /dev/null +++ b/core/event/management/controller/Idle.cpp @@ -0,0 +1,6 @@ +#include "Idle.hpp" +mad::core::Idle::Idle() { +} +void mad::core::Idle::control() { + +} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp new file mode 100644 index 0000000..e7ea1ff --- /dev/null +++ b/core/event/management/controller/Idle.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_IDLE_HPP +#define MAD_IDLE_HPP +#include "Controller.hpp" + +namespace mad::core { + + class Idle : public Controller { + public: + explicit Idle(); + + void control() override; + + private: + + }; + +} + + +#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp new file mode 100644 index 0000000..9e5dd5a --- /dev/null +++ b/core/event/management/controller/Jump.cpp @@ -0,0 +1,15 @@ +#include "Jump.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +} +void mad::core::Jump::control() { + + auto impulse = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); + }); + }; + + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); +} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp new file mode 100644 index 0000000..25d5cf1 --- /dev/null +++ b/core/event/management/controller/Jump.hpp @@ -0,0 +1,25 @@ +#ifndef MAD_JUMP_HPP +#define MAD_JUMP_HPP + +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" +namespace mad::core { + + class Jump : public Controller { + public: + + explicit Jump(std::shared_ptr world, Entity::Id entity_id); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + + }; + +} + +#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp new file mode 100644 index 0000000..3fe6107 --- /dev/null +++ b/core/event/management/controller/Run.cpp @@ -0,0 +1,21 @@ +#include "Run.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +} +void mad::core::Run::control() { + + auto force = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); + }); + }; + //SPDLOG_DEBUG("controller 2"); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); + } + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp new file mode 100644 index 0000000..00c03e5 --- /dev/null +++ b/core/event/management/controller/Run.hpp @@ -0,0 +1,29 @@ +#ifndef MAD_RUN_HPP +#define MAD_RUN_HPP +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Run : public Controller { + public: + enum class Direction { + Right, + Left, + }; + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + Direction dir; + + }; + +} + +#endif//MAD_RUN_HPP diff --git a/core/event/management/controller/statemachine/StateMachine.cpp b/core/event/management/controller/statemachine/StateMachine.cpp index b986148..ab5f66c 100644 --- a/core/event/management/controller/statemachine/StateMachine.cpp +++ b/core/event/management/controller/statemachine/StateMachine.cpp @@ -13,6 +13,7 @@ void mad::core::Transition::handle(const mad::core::Event &event) { if (!is_active || m_state_machine->has_made_transition) return; if (m_condition->is_triggered_by(event)) { m_state_machine->has_made_transition = true; + m_state_machine->m_previous_state_id = m_state_machine->m_current_state_id; m_state_machine->m_current_state_id = next_state; SPDLOG_DEBUG("current state {}", m_state_machine->m_current_state_id); for (auto &i : m_state_machine->m_transitions[current_state]) { @@ -41,6 +42,7 @@ mad::core::StateMachine::StateId mad::core::StateMachine::add_state(const std::s } void mad::core::StateMachine::set_initial_state(mad::core::StateMachine::StateId state_id) { m_current_state_id = state_id; + m_previous_state_id = state_id; for (auto &i : m_transitions[state_id]) { i->is_active = true; } @@ -52,3 +54,6 @@ void mad::core::StateMachine::add_transition(mad::core::StateMachine::StateId st } mad::core::StateMachine::StateMachine(std::shared_ptr m_dispatcher) : m_dispatcher(std::move(m_dispatcher)){ } +mad::core::StateMachine::StateId mad::core::StateMachine::get_previous_state_id() { + return m_previous_state_id; +} diff --git a/core/event/management/controller/statemachine/StateMachine.hpp b/core/event/management/controller/statemachine/StateMachine.hpp index 733e029..05e4791 100644 --- a/core/event/management/controller/statemachine/StateMachine.hpp +++ b/core/event/management/controller/statemachine/StateMachine.hpp @@ -21,9 +21,12 @@ namespace mad::core { void add_transition(StateId state_id_from, StateId state_id_to, std::shared_ptr transition_condition); void set_initial_state(StateId state_id); void control() override; + StateId get_previous_state_id(); + private: StateId m_current_state_id = -1; + StateId m_previous_state_id = -1; std::vector> m_states; std::vector>> m_transitions; std::shared_ptr m_dispatcher; diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 4b19898..9276a96 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -1,9 +1,10 @@ #include "LevelLoaderFromFile.hpp" -#include "event/management/condition/KeyDownCondition.hpp" -#include "event/management/condition/KeyPressedCondition.hpp" -#include "event/management/condition/TimerCondition.hpp" -#include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/statemachine/StateMachine.hpp" +#include <../../game/mobs/hero/Hero.hpp> +#include +#include +#include +#include +#include #include @@ -18,7 +19,7 @@ namespace mad::core { std::unique_ptr LevelLoaderFromFile::load(std::shared_ptr global_dispatcher, std::shared_ptr system_listener) { - auto level_dispatcher = std::make_shared(); + level_dispatcher = std::make_shared(); auto world = std::make_shared(*level_dispatcher); @@ -26,17 +27,22 @@ namespace mad::core { m_config_json["camera"]["position"]["y"]}; auto camera = std::make_shared(camera_position, world); + controllers = {std::make_shared( + camera)}; + + Entity::Id hero_id = create_world(world); camera->turn_on(*level_dispatcher, hero_id); level_dispatcher->registry(camera); - level_dispatcher->registry(std::make_shared(world, hero_id)); + //level_dispatcher->registry(std::make_shared(world, hero_id)); + /* std::vector> controllers { std::make_shared(camera) };*/ - ///State Machine + /*///State Machine struct C1 : mad::core::Controller { void control() override { //SPDLOG_DEBUG("controller 1"); @@ -56,7 +62,7 @@ namespace mad::core { machine->set_initial_state(0); std::vector> controllers{machine, std::make_shared( - camera)}; + camera)};*/ auto level_runner = std::make_unique( system_listener, @@ -65,8 +71,7 @@ namespace mad::core { global_dispatcher, level_dispatcher, world, - controllers - ); + controllers); level_dispatcher->registry(std::make_shared(*level_runner)); level_dispatcher->registry(std::make_shared(*level_runner)); @@ -82,7 +87,7 @@ namespace mad::core { Entity::Id hero_id = 0; std::string map_line; while (std::getline(m_level_map, map_line)) { - for (char object: map_line) { + for (char object : map_line) { switch (m_objects[object]) { case Objects::UnstableBlock: { create_block(world, @@ -99,9 +104,8 @@ namespace mad::core { break; } case Objects::Hero: { - hero_id = create_hero(world, - {current_position_x, - current_position_y}); + Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); + hero_id = hero.get_hero_id(); break; } case Objects::Enemy1: { @@ -137,16 +141,14 @@ namespace mad::core { {{ImageStorage::TypeAction::Idle, std::make_shared(source, block_size, block_size, - StaticImage::TransformType::Tile) - }})); + StaticImage::TransformType::Tile)}})); Entity::Id square_id = world->create_physical_entity( 0, position, 0, image_storage, - is_stable - ); + is_stable); } Entity::Id LevelLoaderFromFile::create_hero(std::shared_ptr world, Vec2d position) { @@ -185,10 +187,9 @@ namespace mad::core { position, 0, image_storage, - false, false - ); + false, false); return hero_id; } -} \ No newline at end of file +}// namespace mad::core \ No newline at end of file diff --git a/core/loader/LevelLoaderFromFile.hpp b/core/loader/LevelLoaderFromFile.hpp index e12e665..46d2f52 100644 --- a/core/loader/LevelLoaderFromFile.hpp +++ b/core/loader/LevelLoaderFromFile.hpp @@ -115,6 +115,10 @@ namespace mad::core { std::ifstream m_level_map; + std::vector> controllers; + + std::shared_ptr level_dispatcher; + std::unordered_map m_objects = { {'.', Objects::Empty}, {'#', Objects::StableBlock}, diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp new file mode 100644 index 0000000..8407ce7 --- /dev/null +++ b/game/mobs/hero/Hero.cpp @@ -0,0 +1,86 @@ +#include "Hero.hpp" +#include "event/management/condition/KeyDownCondition.hpp" +#include "event/management/condition/KeyPressedCondition.hpp" +#include "event/management/condition/KeyReleasedCondition.hpp" +#include "event/management/condition/LastStateCondition.hpp" +#include "event/management/condition/TimerCondition.hpp" +#include "event/management/condition/TrueCondition.hpp" +#include "event/management/controller/Idle.hpp" +#include "event/management/controller/Jump.hpp" +#include "event/management/controller/Run.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" +mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ + std::filesystem::path source(m_config_json["animated_resources"]); + source /= m_config_json["hero"]["source"]; + + std::shared_ptr image_storage; + + image_storage = std::make_shared( + std::unordered_map>( + {{ImageStorage::TypeAction::Idle, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], + m_config_json["hero"]["animated"]["actions"]["idle"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"]) + }, + {ImageStorage::TypeAction::Run, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], + m_config_json["hero"]["animated"]["actions"]["run"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }} + ) + ); + + hero_id = world->create_physical_entity( + 0, + position, + 0, + image_storage, + false, false + ); + + + ///State Machine + struct C1 : mad::core::Controller { + void control() override { + //SPDLOG_DEBUG("controller 1"); + }; + }; + struct C2 : mad::core::Controller { + void control() override { + //SPDLOG_DEBUG("controller 2"); + }; + }; + auto machine = std::make_shared( + std::shared_ptr(level_dispatcher)); + machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(2, 0, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(1, 2, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(2, 1, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(3, 0, std::make_shared(machine, 0)); + machine->add_transition(3, 1, std::make_shared(machine, 1)); + machine->add_transition(3, 2, std::make_shared(machine, 2)); + machine->set_initial_state(0); + controllers.push_back(machine); +} +mad::core::Entity::Id mad::core::Hero::get_hero_id() const { + return hero_id; +} diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp new file mode 100644 index 0000000..d8795df --- /dev/null +++ b/game/mobs/hero/Hero.hpp @@ -0,0 +1,23 @@ +#ifndef MAD_HERO_HPP +#define MAD_HERO_HPP + +#include "loader/LevelLoaderFromFile.hpp" +#include "world/LocalWorld.hpp" +#include +#include "world/entity/PhysicalEntity.hpp" +#include +namespace mad::core { + class Hero { + public: + Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers); + Entity::Id get_hero_id() const; + + private: + std::shared_ptr m_world; + Entity::Id hero_id; + std::shared_ptr level_dispatcher; + int last_pressed_key; + }; +}// namespace mad::core + +#endif//MAD_HERO_HPP From 6def163dfb2e0e70958d0deaeba16cabb98745bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 22:04:45 +0300 Subject: [PATCH 15/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 6 ++++-- core/event/management/controller/Idle.hpp | 7 +++++-- core/event/management/controller/Run.cpp | 6 +++++- core/event/management/controller/Run.hpp | 6 +++--- core/world/LocalWorld.cpp | 3 +++ core/world/LocalWorld.hpp | 2 ++ game/mobs/hero/Hero.cpp | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp index f3ef8dd..282c2ba 100644 --- a/core/event/management/controller/Idle.cpp +++ b/core/event/management/controller/Idle.cpp @@ -1,6 +1,8 @@ #include "Idle.hpp" -mad::core::Idle::Idle() { +mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } -void mad::core::Idle::control() { +void mad::core::Idle::control() { + m_entity->set_action(ImageStorage::TypeAction::Idle); } diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp index e7ea1ff..fa94200 100644 --- a/core/event/management/controller/Idle.hpp +++ b/core/event/management/controller/Idle.hpp @@ -1,17 +1,20 @@ #ifndef MAD_IDLE_HPP #define MAD_IDLE_HPP #include "Controller.hpp" +#include "world/LocalWorld.hpp" namespace mad::core { class Idle : public Controller { public: - explicit Idle(); + explicit Idle(std::shared_ptr world, Entity::Id entity_id); void control() override; private: - + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity* m_entity; }; } diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp index 3fe6107..c8cfd7b 100644 --- a/core/event/management/controller/Run.cpp +++ b/core/event/management/controller/Run.cpp @@ -1,6 +1,8 @@ #include "Run.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +#include +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } void mad::core::Run::control() { @@ -11,6 +13,7 @@ void mad::core::Run::control() { }); }; //SPDLOG_DEBUG("controller 2"); + m_entity->set_action(ImageStorage::TypeAction::Run); if(dir == Direction::Right){ m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); } @@ -18,4 +21,5 @@ void mad::core::Run::control() { m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); } + } diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp index 00c03e5..07ed05c 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Run.hpp @@ -12,15 +12,15 @@ namespace mad::core { Right, Left, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); void control() override; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id m_entity_id; - std::shared_ptr key; Direction dir; + PhysicalEntity* m_entity; }; diff --git a/core/world/LocalWorld.cpp b/core/world/LocalWorld.cpp index b65987c..d104bdc 100644 --- a/core/world/LocalWorld.cpp +++ b/core/world/LocalWorld.cpp @@ -93,3 +93,6 @@ mad::core::Entity::Id mad::core::LocalWorld::create_physical_entity(int z_ind, m mad::core::Entity &mad::core::LocalWorld::get_entity(mad::core::Entity::Id id) noexcept { return m_storage.get_entity(id); } +mad::core::EntityStorage &mad::core::LocalWorld::get_storage() { + return m_storage; +} diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 14c38a8..4f4d4c6 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -34,6 +34,8 @@ namespace mad::core { Entity::Id create_physical_entity(int z_ind, Vec2d initial_position, float initial_rotation, std::shared_ptr image_storage, bool is_fixed = false, bool is_rotated = true) override; + EntityStorage& get_storage(); + private: std::shared_ptr>> m_step_events_queue; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 8407ce7..379854a 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -62,7 +62,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); machine->add_state(std::make_shared(world, hero_id)); From c5bcc881abad5e5eb08649ee414d002aee6affb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:01:08 +0300 Subject: [PATCH 16/44] set animations in statemachine --- core/CMakeLists.txt | 2 +- core/event/management/controller/Fall.cpp | 6 ++ core/event/management/controller/Fall.hpp | 17 +++ core/event/management/controller/FlyUp.cpp | 6 ++ core/event/management/controller/FlyUp.hpp | 18 ++++ .../management/controller/GroundMovement.cpp | 7 ++ .../management/controller/GroundMovement.hpp | 17 +++ core/event/management/controller/Idle.cpp | 8 -- core/event/management/controller/Idle.hpp | 23 ---- .../controller/{Jump.cpp => JumpImpulse.cpp} | 8 +- .../controller/{Jump.hpp => JumpImpulse.hpp} | 10 +- core/event/management/controller/Movement.cpp | 27 +++++ .../controller/{Run.hpp => Movement.hpp} | 18 ++-- core/event/management/controller/Run.cpp | 25 ----- .../event/management/controller/StartJump.cpp | 6 ++ .../event/management/controller/StartJump.hpp | 17 +++ core/visual/image/storage/ImageStorage.hpp | 5 +- core/world/LocalWorld.cpp | 3 + core/world/LocalWorld.hpp | 2 +- core/world/entity/PhysicalEntity.cpp | 10 +- core/world/entity/PhysicalEntity.hpp | 1 + game/mobs/hero/Hero.cpp | 98 ++++++++++++++++-- game/mobs/hero/Hero.hpp | 1 + .../hero/hero_fall/adventurer-fall-00.png | Bin 0 -> 1004 bytes .../hero/hero_fall/adventurer-fall-01.png | Bin 0 -> 999 bytes .../hero/hero_fly_up/adventurer-jump-03.png | Bin 0 -> 1019 bytes .../hero/hero_idle/adventurer-idle-00.png | Bin 0 -> 1134 bytes .../hero/hero_idle/adventurer-idle-01.png | Bin 0 -> 1127 bytes .../hero/hero_idle/adventurer-idle-02.png | Bin 0 -> 1206 bytes .../hero/hero_idle/adventurer-idle-03.png | Bin 0 -> 1110 bytes .../hero/hero_jump/adventurer-jump-00.png | Bin 0 -> 1095 bytes .../hero/hero_jump/adventurer-jump-01.png | Bin 0 -> 1049 bytes .../hero/hero_jump/adventurer-jump-02.png | Bin 0 -> 1094 bytes .../hero/hero_jump/adventurer-jump-03.png | Bin 0 -> 1019 bytes .../hero/hero_run/adventurer-run-00.png | Bin 0 -> 1073 bytes .../hero/hero_run/adventurer-run-01.png | Bin 0 -> 1043 bytes .../hero/hero_run/adventurer-run-02.png | Bin 0 -> 963 bytes .../hero/hero_run/adventurer-run-03.png | Bin 0 -> 1140 bytes .../hero/hero_run/adventurer-run-04.png | Bin 0 -> 1075 bytes .../hero/hero_run/adventurer-run-05.png | Bin 0 -> 859 bytes game/resources/levels/level_01/config.json | 53 ++++++++-- game/resources/levels/level_01/map | 2 +- 42 files changed, 292 insertions(+), 98 deletions(-) create mode 100644 core/event/management/controller/Fall.cpp create mode 100644 core/event/management/controller/Fall.hpp create mode 100644 core/event/management/controller/FlyUp.cpp create mode 100644 core/event/management/controller/FlyUp.hpp create mode 100644 core/event/management/controller/GroundMovement.cpp create mode 100644 core/event/management/controller/GroundMovement.hpp delete mode 100644 core/event/management/controller/Idle.cpp delete mode 100644 core/event/management/controller/Idle.hpp rename core/event/management/controller/{Jump.cpp => JumpImpulse.cpp} (65%) rename core/event/management/controller/{Jump.hpp => JumpImpulse.hpp} (57%) create mode 100644 core/event/management/controller/Movement.cpp rename core/event/management/controller/{Run.hpp => Movement.hpp} (50%) delete mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/StartJump.cpp create mode 100644 core/event/management/controller/StartJump.hpp create mode 100644 game/resources/animated/hero/hero_fall/adventurer-fall-00.png create mode 100644 game/resources/animated/hero/hero_fall/adventurer-fall-01.png create mode 100644 game/resources/animated/hero/hero_fly_up/adventurer-jump-03.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-00.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-01.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-02.png create mode 100644 game/resources/animated/hero/hero_idle/adventurer-idle-03.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-00.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-01.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-02.png create mode 100644 game/resources/animated/hero/hero_jump/adventurer-jump-03.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-00.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-01.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-02.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-03.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-04.png create mode 100644 game/resources/animated/hero/hero_run/adventurer-run-05.png diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index a8995e7..e5e0a8a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Fall.cpp b/core/event/management/controller/Fall.cpp new file mode 100644 index 0000000..ed817e6 --- /dev/null +++ b/core/event/management/controller/Fall.cpp @@ -0,0 +1,6 @@ +#include "Fall.hpp" + +mad::core::Fall::Fall(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Fall; + Idle_animation = ImageStorage::TypeAction::Fall; +} diff --git a/core/event/management/controller/Fall.hpp b/core/event/management/controller/Fall.hpp new file mode 100644 index 0000000..4e8274d --- /dev/null +++ b/core/event/management/controller/Fall.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_FALL_HPP +#define MAD_FALL_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Fall : public Movement { + public: + Fall(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_FALL_HPP diff --git a/core/event/management/controller/FlyUp.cpp b/core/event/management/controller/FlyUp.cpp new file mode 100644 index 0000000..969d7e2 --- /dev/null +++ b/core/event/management/controller/FlyUp.cpp @@ -0,0 +1,6 @@ +#include "FlyUp.hpp" + +mad::core::FlyUp::FlyUp(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Fly_up; + Idle_animation = ImageStorage::TypeAction::Fly_up; +} diff --git a/core/event/management/controller/FlyUp.hpp b/core/event/management/controller/FlyUp.hpp new file mode 100644 index 0000000..e87bc4a --- /dev/null +++ b/core/event/management/controller/FlyUp.hpp @@ -0,0 +1,18 @@ +#ifndef MAD_FLYUP_HPP +#define MAD_FLYUP_HPP + + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class FlyUp : public Movement { + public: + FlyUp(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_FLYUP_HPP diff --git a/core/event/management/controller/GroundMovement.cpp b/core/event/management/controller/GroundMovement.cpp new file mode 100644 index 0000000..b8e127e --- /dev/null +++ b/core/event/management/controller/GroundMovement.cpp @@ -0,0 +1,7 @@ + +#include "GroundMovement.hpp" + +mad::core::GroundMovement::GroundMovement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Run; + Idle_animation = ImageStorage::TypeAction::Idle; +} diff --git a/core/event/management/controller/GroundMovement.hpp b/core/event/management/controller/GroundMovement.hpp new file mode 100644 index 0000000..339fe34 --- /dev/null +++ b/core/event/management/controller/GroundMovement.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_GROUNDMOVEMENT_HPP +#define MAD_GROUNDMOVEMENT_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class GroundMovement : public Movement { + public: + GroundMovement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_GROUNDMOVEMENT_HPP diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp deleted file mode 100644 index 282c2ba..0000000 --- a/core/event/management/controller/Idle.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Idle.hpp" -mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} - -void mad::core::Idle::control() { - m_entity->set_action(ImageStorage::TypeAction::Idle); -} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp deleted file mode 100644 index fa94200..0000000 --- a/core/event/management/controller/Idle.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAD_IDLE_HPP -#define MAD_IDLE_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" - -namespace mad::core { - - class Idle : public Controller { - public: - explicit Idle(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - PhysicalEntity* m_entity; - }; - -} - - -#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/JumpImpulse.cpp similarity index 65% rename from core/event/management/controller/Jump.cpp rename to core/event/management/controller/JumpImpulse.cpp index 9e5dd5a..6ffc28d 100644 --- a/core/event/management/controller/Jump.cpp +++ b/core/event/management/controller/JumpImpulse.cpp @@ -1,8 +1,8 @@ -#include "Jump.hpp" +#include "JumpImpulse.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +mad::core::JumpImpulse::JumpImpulse(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { } -void mad::core::Jump::control() { +void mad::core::JumpImpulse::control() { auto impulse = [](mad::core::Vec2d dir) { return mad::core::LambdaIntent( @@ -11,5 +11,5 @@ void mad::core::Jump::control() { }); }; - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -2000000.0f})); } diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/JumpImpulse.hpp similarity index 57% rename from core/event/management/controller/Jump.hpp rename to core/event/management/controller/JumpImpulse.hpp index 25d5cf1..5e69a29 100644 --- a/core/event/management/controller/Jump.hpp +++ b/core/event/management/controller/JumpImpulse.hpp @@ -1,15 +1,15 @@ -#ifndef MAD_JUMP_HPP -#define MAD_JUMP_HPP +#ifndef MAD_JUMPIMPULSE_HPP +#define MAD_JUMPIMPULSE_HPP #include "Controller.hpp" #include "world/LocalWorld.hpp" #include "world/World.hpp" namespace mad::core { - class Jump : public Controller { + class JumpImpulse : public Controller { public: - explicit Jump(std::shared_ptr world, Entity::Id entity_id); + explicit JumpImpulse(std::shared_ptr world, Entity::Id entity_id); void control() override; @@ -22,4 +22,4 @@ namespace mad::core { } -#endif//MAD_JUMP_HPP +#endif//MAD_JUMPIMPULSE_HPP diff --git a/core/event/management/controller/Movement.cpp b/core/event/management/controller/Movement.cpp new file mode 100644 index 0000000..a580c78 --- /dev/null +++ b/core/event/management/controller/Movement.cpp @@ -0,0 +1,27 @@ +#include "Movement.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Movement::Movement(std::shared_ptr world, Entity::Id entity_id, mad::core::Movement::Direction dir, float velocity) : m_world(world), m_entity_id(entity_id), dir(dir), velocity(velocity){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); +} +void mad::core::Movement::control() { + auto set_horizontal_velocity = [](float vel) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).set_linear_horizontal_velocity(vel, event_dispatcher); + }); + }; + if(dir == Direction::Right || dir == Direction::Left){ + m_entity->set_action(Move_animation); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(velocity)); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(-velocity)); + } + } + else if(dir == Direction::Idle){ + m_entity->set_action(Idle_animation); + } + + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Movement.hpp similarity index 50% rename from core/event/management/controller/Run.hpp rename to core/event/management/controller/Movement.hpp index 07ed05c..2bac02d 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Movement.hpp @@ -1,18 +1,21 @@ -#ifndef MAD_RUN_HPP -#define MAD_RUN_HPP +#ifndef MAD_MOVEMENT_HPP +#define MAD_MOVEMENT_HPP + + #include "Controller.hpp" #include "world/LocalWorld.hpp" #include "world/World.hpp" namespace mad::core { - class Run : public Controller { + class Movement : public Controller { public: enum class Direction { Right, Left, + Idle, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Movement(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); void control() override; @@ -21,9 +24,12 @@ namespace mad::core { Entity::Id m_entity_id; Direction dir; PhysicalEntity* m_entity; - + float velocity; + protected: + ImageStorage::TypeAction Move_animation; + ImageStorage::TypeAction Idle_animation; }; } -#endif//MAD_RUN_HPP +#endif//MAD_MOVEMENT_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp deleted file mode 100644 index c8cfd7b..0000000 --- a/core/event/management/controller/Run.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Run.hpp" -#include "world/intent/LambdaIntent.hpp" -#include -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} -void mad::core::Run::control() { - - auto force = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); - }); - }; - //SPDLOG_DEBUG("controller 2"); - m_entity->set_action(ImageStorage::TypeAction::Run); - if(dir == Direction::Right){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); - } - else if(dir == Direction::Left){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); - } - - -} diff --git a/core/event/management/controller/StartJump.cpp b/core/event/management/controller/StartJump.cpp new file mode 100644 index 0000000..c124a52 --- /dev/null +++ b/core/event/management/controller/StartJump.cpp @@ -0,0 +1,6 @@ +#include "StartJump.hpp" + +mad::core::StartJump::StartJump(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity) : Movement(world, entity_id, dir, velocity) { + Move_animation = ImageStorage::TypeAction::Jump; + Idle_animation = ImageStorage::TypeAction::Jump; +} diff --git a/core/event/management/controller/StartJump.hpp b/core/event/management/controller/StartJump.hpp new file mode 100644 index 0000000..ea4df13 --- /dev/null +++ b/core/event/management/controller/StartJump.hpp @@ -0,0 +1,17 @@ +#ifndef MAD_STARTJUMP_HPP +#define MAD_STARTJUMP_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class StartJump : public Movement { + public: + StartJump(std::shared_ptr world, Entity::Id entity_id, Direction dir, float velocity = 0); + }; + +} + +#endif//MAD_STARTJUMP_HPP diff --git a/core/visual/image/storage/ImageStorage.hpp b/core/visual/image/storage/ImageStorage.hpp index 5699096..d866bd0 100644 --- a/core/visual/image/storage/ImageStorage.hpp +++ b/core/visual/image/storage/ImageStorage.hpp @@ -13,7 +13,10 @@ namespace mad::core { enum class TypeAction { Idle, Run, - Attack + Attack, + Jump, + Fly_up, + Fall, }; explicit ImageStorage(std::unordered_map> actions); diff --git a/core/world/LocalWorld.cpp b/core/world/LocalWorld.cpp index d104bdc..efa14c6 100644 --- a/core/world/LocalWorld.cpp +++ b/core/world/LocalWorld.cpp @@ -54,6 +54,9 @@ void mad::core::LocalWorld::produce(mad::core::EventDispatcher &dispatcher) { for (Entity::Id entity_id : m_storage.extract(TrueFilter())) { if (auto physical_entity = cast_to_or_null(m_storage.get_entity(entity_id)); physical_entity != nullptr) { physical_entity->synchronize_position_with_viewable(); + if(abs(physical_entity->get_linear_velocity().get_y()) > 0.01){ + //SPDLOG_DEBUG("vel {}", physical_entity->get_linear_velocity().get_y()); + } } } diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 4f4d4c6..4cb88c3 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -22,7 +22,7 @@ namespace mad::core { class LocalWorld : public World { public: - explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 30.0f}); + explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 60.0f}); bool manipulate(const Filter &filter, const Intent &intent) override; diff --git a/core/world/entity/PhysicalEntity.cpp b/core/world/entity/PhysicalEntity.cpp index 9b58177..6f94482 100644 --- a/core/world/entity/PhysicalEntity.cpp +++ b/core/world/entity/PhysicalEntity.cpp @@ -37,8 +37,10 @@ mad::core::PhysicalEntity::PhysicalEntity(std::int32_t id, int z_ind, Vec2d init b2FixtureDef fixtureDef; fixtureDef.shape = &dynamicBox; fixtureDef.density = 1.0f; - fixtureDef.friction = 0.3f; - fixtureDef.restitution = 0.2f; + fixtureDef.friction = 0.0f; + fixtureDef.restitution = 0.0f; + body->SetLinearDamping(0.0000000001); + body->SetAngularDamping(0); body->CreateFixture(&fixtureDef); body->SetTransform(body->GetPosition(), initial_rotation); @@ -69,6 +71,10 @@ void mad::core::PhysicalEntity::apply_force_to_center(mad::core::Vec2d force, ma void mad::core::PhysicalEntity::set_linear_velocity(mad::core::Vec2d velocity, mad::core::EventDispatcher &dispatcher) { body->SetLinearVelocity(velocity); } +void mad::core::PhysicalEntity::set_linear_horizontal_velocity(float velocity, mad::core::EventDispatcher &dispatcher) { + body->SetLinearVelocity({velocity, body->GetLinearVelocity().y}); +} + void mad::core::PhysicalEntity::apply_angular_impulse(float impulse, mad::core::EventDispatcher &dispatcher, bool awake) { body->ApplyAngularImpulse(impulse, awake); } diff --git a/core/world/entity/PhysicalEntity.hpp b/core/world/entity/PhysicalEntity.hpp index fff81c2..6c3e0fd 100644 --- a/core/world/entity/PhysicalEntity.hpp +++ b/core/world/entity/PhysicalEntity.hpp @@ -45,6 +45,7 @@ namespace mad::core { void apply_angular_impulse(float impulse, EventDispatcher &dispatcher, bool awake = true); void apply_torque(float torque, EventDispatcher &dispatcher, bool awake = true); void set_linear_velocity(Vec2d velocity, EventDispatcher &dispatcher); + void set_linear_horizontal_velocity(float velocity, EventDispatcher &dispatcher); void set_angular_velocity(float velocity, EventDispatcher &dispatcher); void set_linear_damping(float linear_damping, EventDispatcher &dispatcher); void set_angular_damping(float angular_damping, EventDispatcher &dispatcher); diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 379854a..dcee27d 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,9 +5,12 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Idle.hpp" -#include "event/management/controller/Jump.hpp" -#include "event/management/controller/Run.hpp" +#include "event/management/controller/Fall.hpp" +#include "event/management/controller/FlyUp.hpp" +#include "event/management/controller/GroundMovement.hpp" +#include "event/management/controller/JumpImpulse.hpp" +#include "event/management/controller/Movement.hpp" +#include "event/management/controller/StartJump.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -36,6 +39,36 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }, + {ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fly_up, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fall, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -62,10 +95,21 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -75,9 +119,43 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(3, 0, std::make_shared(machine, 0)); - machine->add_transition(3, 1, std::make_shared(machine, 1)); - machine->add_transition(3, 2, std::make_shared(machine, 2)); + + machine->add_transition(3, 5, std::make_shared()); + machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); + + float t = 1; + + machine->add_transition(4, 8, std::make_shared(t)); + machine->add_transition(5, 8, std::make_shared(t)); + machine->add_transition(6, 8, std::make_shared(t)); + + machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(7, 11, std::make_shared(t)); + machine->add_transition(8, 11, std::make_shared(t)); + machine->add_transition(9, 11, std::make_shared(t)); + + machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(10, 0, std::make_shared(t)); + machine->add_transition(11, 0, std::make_shared(t)); + machine->add_transition(12, 0, std::make_shared(t)); + + + + + + + machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index d8795df..70c3953 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,6 +17,7 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; + float horizontal_velocity = 81; }; }// namespace mad::core diff --git a/game/resources/animated/hero/hero_fall/adventurer-fall-00.png b/game/resources/animated/hero/hero_fall/adventurer-fall-00.png new file mode 100644 index 0000000000000000000000000000000000000000..3a4b30fb90d8d77f591fa2c00b728f6fdcaa5c5b GIT binary patch literal 1004 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 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-00.png b/game/resources/animated/hero/hero_idle/adventurer-idle-00.png new file mode 100644 index 0000000000000000000000000000000000000000..3bd528e863cf02b31c7cd6cc923034015a745f60 GIT binary patch literal 1134 zcmV-!1d;oRP)XYxd z%)~`q3?`ZwGQ&ccn#forX7!Td>ckZaLiyKW|4~Z0K3wjV%Cb%FX*7mUa?{h_J?H#> z-*e9IoO5BDZMNBFn|}eR7@dB2<}{55_p2LisYFsLmv;d0=u2-2_gN~uMotB8iwUFd#mtzN=4xA) zAxbo+g>+vGbF8_FbMFNJ_`}`Dp+!`H!Qd#nZ=9zuAmR2Mp)Vj&_4x7sX0ihuZma}A z$(*4MShLx9a6Utg)5*Zu9{kVxwD+HkajLRTeXR(|E^Pb#ampt>J@mb*^nS`@JPv@r zvJTJ$6dThc6Yl6_IuWN@cB;yJgmB;qrsra`{xV_+dU9X0QUB|k*GWC~jN$u@w_i0I z0w8Ecs%59TAwYu~rxVbE*QvGJ`B^IpJx@#}d$^;Mh4kjLVR2!C$#|T)4=w|mApNPm z@Ey~0F#s~zWi##z*z$~oJ36_YP4R$3E|`tbjbV=d8ezxl?-Eq{nQ|luS+!(uKm8m* zrJuzG?FMkL@u&a^8e0|;OW(%h*rh7-5ddS90hacZLeD#!+Du(|lL~to;NkgK-e)E{ z#_-Km9@%Gpg>Sis<<%9G`3RHoI4wOt&;kUNexl)!#L(yJQYN<^G*r1gTBAvA_iF3t z0${h-CoE64oFhvs={wrJ2O9pWlgSaX`l!~0+!^(5FYgyK$$rlOLRKFS*ZTpec6$g} zeWZ`QfI~V=Q0X_}dNZbWE&ZGTjKF52zfoZ?GnUo#T+Dc?+#YfR-9#oX6|@n7kaI*2 z=t|Fds=Rw~W^w>DFh<4t4h7m$1IP_@OIPeQs@_HfTNbjAOiHXTuh>sPW7nFE-ogod zF{iJ*m4bGs+!B*n73>)8MIik0cH;PBL{h7&EXyPkg@>hXt1B;+dIyGt`W61oK9es+ zmhBr&`e3P`iJ8geM7uTrJ@R*ItoNSe`>FF!5iVq}O{LwI*Apm$kezE;wPO9&yT4pw z%XzUgBwWZ+JkEGBMfxruP2h($07*qoM6N<$f|lkf AqW}N^ literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-01.png b/game/resources/animated/hero/hero_idle/adventurer-idle-01.png new file mode 100644 index 0000000000000000000000000000000000000000..230c1cb30f47fc1ae3db9e1f34429b345a4926dd GIT binary patch literal 1127 zcmV-t1ep7YP)ESc;_C9 zN~YPOF@}(l7a8lA02vurp5=gLRm^pN?Vjl0Cv3cj&Psl!Yu-+WQxzf z_?nL9Z2+i?D%)EE8o+#ft|W(Nn#kTxpH?ATq)a-;z~v|a*Qal20iTyEp=)$BZ$oh^ zj1GrUoC<(O2{NI~tbv+3nM^vTRmc|hcKQGa_`JqlT~rO-!m((WCbE*wNjjP4hwOaW z`!M0?l(8O;PH`o4%@~&oris{O3vR_G0kkyPH9*^ysvsPlLUAe_{4B^|R}USJx*6>1 zF-VDqkX$|AyPMXgYHesF!cF&i=8iqZWOe?G-hAU=k#79NRT}y}7XFS1samZ~)c}Ok zhw!hVQqWL)cSsAncVOXtrc#(FG~FvdPv=EukP7`~6b zdql(|h>M6$0-)AiL(H{;|HBIac&e(5%Xj)aeT#N`OaBZ)i0A|gQQ3WzQ1~LFc9j8_ zg8`R=-(G%=Q1~J<@mT=UnH3T40f8-wPGwg@4HS`Zx_mfYzM_5m4ZrG0z? zfTgh1yHZtwlV`YzKENoH5Ld90WHhmRW%xKx)vpNQ-!ibUMA zljWT+0T2pbH0!zurioNqZGWgf5!r)ddKIV3N9}qvAYaY0-+X{wYAsY3QoT$Q3C~Xy z%`0DjPikit>SY!eqRhl+i!Ok%Q+xiMEedR;%G}hiWYbvy8i?Uo*eC!?>+-@q&4JxQ z{0kwXlepA(lDoY3QU#oe>lt&aNcVZSL@c8b={src5dqUgVu=K)A3{dj%uQYAQd~n( z6jZhNM@mr?&cs#xTgs`-S1Vy(cj3AENarrBR;vc+M06jTq9_1lvso#4`Fo*$h4orG ztX8WKoxcm=L_D^?4suPIn6G&ugcI@KvBthyE2^rp)w+?oTdhc{s`7*_iMKq<+s}#X zv!Db-?6*=HK%2bGefBa&hJuU?1#wCl+T>*boMkzoEj*Nfh@+|sfPmLSt!=}+(~=YI zstCe~=vd8Wr5eYbMY0M@nKYS9mBe33h%6-%BvQ+~`pE@DcIw+vGPyNlzLFCgA>l-p t5(y@gDVG1_?{6}h!e+4ue^34w_#H}Ld7*XQd&mF)002ovPDHLkV1mdw8z%q& literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-02.png b/game/resources/animated/hero/hero_idle/adventurer-idle-02.png new file mode 100644 index 0000000000000000000000000000000000000000..2668b590bc2ab2ffead9465e8f2538ae88cd34c8 GIT binary patch literal 1206 zcmV;n1WEgeP)t%mk;?vU!GyH0*Y1*|JHBF2?Ep!3V(Y$=@}%tAyU6o77fqMR6#M z-0+|{6abAhR6>SP1BIJqqKk1YTQMmjn21F-;Z!UVKy{^61GE<+*?4>tC=P|AUk}h%cZAyKo%Gcm z(MgGhkXpUiR?m*g0`2;+mwV2OOt-wmc){8poqX?Tl5X%+KNTIH3-1vjr`C?j0suUV z$0)rodwgb<{pHmJPxZsgrnUL6e#Ko-`lmLGLdebp`wr1|(M?6~cbd0$4^zPaW&PLm z`Tgb9`uM`=4I-~J>b_5W^sa~y#AIad6Dy6}(mHGR08r#Cq}XoP=P!)j(8n%W=I6Dc z&|}zevwNEk(^*lLB%2Bb@aHd4`spPAitTp&=Q{HvQ^5cL(dA`YPJV1O1V8{0fJW~v zEkS1FmjRsqK60B*Fyy(+h*hOK-$r-7jk|BX!;t4PbF)6Cf&sF#vb3jPe3gOG6~i$Y zDlKo*VZyN`a?KWCEfWp1^Nd&_+v85c zXJP~97h`zkVzzC07JwDMzD!%br$||w)WjRI;j9?SNTD@Pdsvoxyj6l!5&)Uiudz_` zCZ(Vu`5W8|30E;DG199bLsI)vYWB5ZMO4kK6J@Fg6 z2tb+4+^jEUjT0F2ou|}wfU6zt0Q%Digj|RT5?4Fgd936K?29n~D)3{Q4d{CF_vNuG zr=@dpPePnhp8p1hi16rP=;E2yC;N{X_gD0Bri0&($Q*oKHS4-OJt(QjqR_f0!@ z;+YSVkXX0tilT5Q4MYrEY#tnhb%EB@*FAEL*=#oIHU+|u-@=SXzc>9Ioqr19M9Onb z?6rhZRh2yRgG}X_kyKS>uO&=LW{eLG?h@)(IFX{9EX`)Ovr}H+Noxkf*9REBK7d1t zvQu6Fz>yIba^$W@T5fg#cS$itmIvk?rg*ws0cj+%5{pTNwoOU0Y*U6b9*(5NUs{OF zheCuR3p9UuNtb=`{Rq+cs{Vf|E;d8LiOh#WjE5sEM3??jXFMFiVloNulm7+&0QQ2K U4h?yP-v9sr07*qoM6N<$f=IDF&Hw-a literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_idle/adventurer-idle-03.png b/game/resources/animated/hero/hero_idle/adventurer-idle-03.png new file mode 100644 index 0000000000000000000000000000000000000000..53207e8a2f1ed323478a1e16c27559eff02c46ba GIT binary patch literal 1110 zcmV-c1gZOpP)BW*kqGUHreDqK&gh)Q%4Wc(RPn0?Mv$^rB>Slz@cWE!eOWhbOWU%kSjcK7uN1{}-fQQ} z6T1jSqQ-bA66IX*qS3Av6$`PcW;~ir0qE+m3qU-Owi1d&(OeowKAK>xZ;;;mJ&g4Y z8lq$)Wv`w-@i4nP++ut(%pac9EWGh3)9%6=z4G#r4Yu*)=V={!S9*;|Ikk3oxB&=d zj?#3a@2~HBJe*8Q_!|Lt(@lL;ijrIB3K^_WDaQrcilC!UKo7@>ZH=>#PVZUL)N55RCwrCh{{yq}c>prmRT<%d3NsQOI7}+H z$`*^w5HTB{XL%_?-@q|~p;2b+I$_ldK;OV1!O$qnONEQG=fTIBxV%PpOXa0nc4~+F z`|)cY>a4Y5xOIoI%F9a;dVakIJ5&IYnVcb{H50?3TKJI$UU>6UV-7Nel;vT#zaPgP zb|QLQ)LCnJGb<^I~ZP+YC=agV*wD@zwQ*yafRP28j0k9CgVzi4Qia1mY$xIGFq?VLYF%?tp z<}_B(>vU3_(AlAr)ccxgQZ0sIv33C1){Q4N20*=gm-yOd?DNICJr`Q&~=?U%lctbXF<_*oqe_xzM34bKG`ERu5=;w zR+9kOqponb-NfYh1e46vuxfYUac ziD~?J=z~qAO)-9yX!;Qo1F=N|uA&lbf!(FJEO1%(3%bzpVPRc_KIk1@%>I&_+?=^N zbN+MAoS6$*vSi7UB}DrKD$J1^)>(^GZCt4JQ83kG^uPM?^ETds90k@u_&!t4u=}u zY5U0dZRv5B(lhW20D8X8V80jN*a-1>Oy0}izeQO_<`Rpds92N1@r112ZWk{dc@%(9 zUnu|{cPWvX2ztH_u;N_>$}(cpawybo0-$DxT>^66-ip`fPk-a}`O}%nw5vdwkke;} zc%o(#@4rzCz@LR*;eY#MSs%0F_4(2Bb&j6xqqnJ@+PXq|o7&T&RFI>}(NIepTb{N6 zoa`QZ9%JNNe69z`8NEr^F7W>mqPa@Y>J~WiAEebS_*LYItJivz%&(+t47Ic|5i!`T zyQFt&l%d)u(_@uAR|psePi?J984je@?!v8dI`$Qa{Q9FRLQp3Jkln-m#10-#+XsK^ z<8gwNOxp+;2EgBffDejXVlKJBd#B$q9fN5hLoIDg$0HQjb@}d67n+$)og+;x?L<3I z0jv|Xgv6WD681X?ycq;s3{>sEp5!s$H=ofWcP4Cb)7c=81PhhgOP%%p2Eh246O5lZ zK{$~FV7B8pvmM8Ql;9;yAB?8*Ik#{J@6;#(!=S|FS~c#}EC7TPNd~Q3fRr$&W}&XC zK^V8k8Q`+4_Uwa{nEzZMri6s=#8=stS9#KZ3wwrr=Qa-$p&$fqvf;p60-)Gg!Iz&L zW8liyY%VM^6N>38O1dNhhQaKTh-;l6vZ=HjS0ag1vyfZ!3;>g%AP;L6X2Zj>%-u{Z zJ|WJX?^4n^P2aULJ5lh*fz+x4ll~E0q{@o^PXVX`!hi)B^##;vcQ@9fTP&F-LB@VsOQ2bl-F`DEv94J)>-t-*T*#Y;8>n;$_S>RVE(9sH-c1Y0 zvmhdo2>WeO)zhjMV$(EfOD3dq>42 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-01.png b/game/resources/animated/hero/hero_jump/adventurer-jump-01.png new file mode 100644 index 0000000000000000000000000000000000000000..b20e0343c77fa6ecb46aa2cfeccfa0f8699f6427 GIT binary patch literal 1049 zcmV+!1m^pRP)izazx1zV>AS_=w^KI)u_p$@kw8d z8Z_}?I+1`ebIQV8e1SL@rB)%5O*>i`mI9@=rF306K6KO;>(f0?+D~$mbI&>Vch2|z z&iVa*P@+VM5+zEMC{d!s{{^AS(D4qpG+PZKmCP{mZ6MeG!RZqm+`C8S&rQVQqFmbn zK+E&5DOrD;5-WhS+Da;!k!Gub;~nl?e6Y$cYPpWjx2G9fSCZsURGO5T6H6@Wh-qXgeND}8}r zZjLVyWZXNQYpXYN zp_$%3me*qJEYsvrV*>yS;Sej!*${k`5H-sd<{}XQ9)00(_QS6;I8L>Qmp_^2op;~X zyA6FpW_tTrO(nS7TrP(i8wvy%jb_o_^OTGao&hKjv&r?AcADC{Mbpu4j@+v+fa(?k zNZ-;8YTvsEfY&#M|Cb+xf9gjXlXJ5A>1@J_51wIS!_5T@q;+k*r7rgY~MT|%O%1c6w%=$Of{ zjk4|8SQ1U9nKIV{Sz$J-iMIXiB64#cFJtnKS9FQdC*;;z!MoQt2EbzQcT8L6-nY-g zLO29-zp?$1Hw8eoZ4Y05dJ^xYi&QzBdbXmwM9CF{n<6d`4p8Z;W7mdc?N%C_)r7J6 zF#s0BAsVbER-@Nst@{{>wFPnRvk@gBSa+?p8Hqwad9!~USPc3}Br?>P1<_<0CO-#Y zKM(~>z>UBKYTd__)mplY40UzMts!;OZnWAchr_bi7(EWbtLML0mJC5>W?zoS^EV^% z9)`mbP1FAIjizb*n?OD2I$9^MT!A89J<{nY#^dcA(u$rM zrAKKi%7s|0R$0Zm?6$;dyd7e%%_IPJ8`HQfh*&H}w~yB&|KhI)(S z=kKnv+myyB)?|-E5K3i~dq=sDXe5F!I7fUvB>>^H-BmC?8&BXg8`R(S{|bKrE6Hcb TLPIqs00000NkvXXu0mjfd%y9w literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-02.png b/game/resources/animated/hero/hero_jump/adventurer-jump-02.png new file mode 100644 index 0000000000000000000000000000000000000000..ba27779940e0644fb74d1bfdf8d863c973b2036d GIT binary patch literal 1094 zcmV-M1iAZ(P)9&_Hb*pLGr17@BNpIHcLz6VIq9Z$3eaQFaa_%|z ze1G5b`+d(j7b>Wrf(k154lQ`Zg1OY=G(7-If~C8q^Ti*J8+XY(D$?y9!1J5 zf5M|Xf+o2|nxC8J!%t4Iy?s-mzy01W034=W8mA>0$qB*jRfIp|Geg0(M4}S~F|!># zw1@6veDE2*(0nvC1ZWLy6FraJQ#NOnoX}Sz(Ch>t6kJ<)Y6-1m%=+HLBxa&?J^2DQ zkB8w)*|Pa85u)0vMC^)=r$#j+(TT$QNOXd;Bj-!Tc6RqN5*Z@cy4jqajg`%5iIC97 zdH@Fc?quigB_h!Yygo0_elSe9v$teya_Xu87>Nu~R~Il>&vt#V#OzH07w_(EQKL|imLx2|t`pb&Rl8hwYaG`g16x#W7Bag}WvKO9D zXdvo&lVuTlCSCTzS|S8s%dvhlGCd9tKLM-+4{-ChUjcA3*KT@f4|*mooOVaqeA0zn z=-$uFf`;Ga1z>&fL5$Ddp?Tjy0OpPzBD~=i9#2jIknpV$2L}3YnAehw_+4J}=F({1cM#WbSPG}q?KhtdfR_5@EjZPzQ0r8wb*cc2*;@J3*XzYF3@M8#t+a~0QR8r|3Qp6sRo`fuhN`M%->-@xMM&No0CSm) zsBt>Y8izxCb2N_8|=8zN{kOn~on7XZ4h|G!G>w#F9m zyRHkD&BmBZ}hywXp0V{x${B9%;Xm)|A;j+`08tteno6-d7{sy3UM%AF&ss)~SN6v{_-7K$M~ zBdKJP%X9P0XS2dE3`>JAhV+bFo}0&|REz0!hF8ygFMIk5D)_hY2che3yBE_uw*UYD M07*qoM6N<$f+g)C)c^nh literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_jump/adventurer-jump-03.png b/game/resources/animated/hero/hero_jump/adventurer-jump-03.png new file mode 100644 index 0000000000000000000000000000000000000000..0458013c8dae7ecf137a009f0de9d2dc5fb7c074 GIT binary patch literal 1019 zcmVHJ^vVQpW(c}v>cx7okus_yS(ar3JEV;Dv^i{T*}CJ!)paNe35`SSfONF=l! zfW7aWCmQKi<8np@U@|#OD7;U}X4ATOYG%Z2X%Oj!JjvU?Z<()*PbP=)cmj$ZKEwCO zbgZ90WQm~5tDH#>bK#RtJ|3JQ?FmtyS|@kT(RcSbI!3=B?FrEp8z36#=0K~dYCWb} znYc1@oeQ6J^7;5-(w?Gf;@xf^;Nxl-P9-+XO^*CP`o^R#Zo`aB$NI?@msJx0-@G>s zZyp99=nnv}IC~9%k5(%| zgQ|^Wi_4m7RHD*^+h!)0-)J$@{$l{#TTFA$vBS`han%o-j`eRjr2tVj(s%Sl!ls8? z9zDk729a5B#A>w?A0Dk%hKi~;dwL}+9OfpLR|{pKnwQei-9=`-#B9N-StrZ#=2b~? zx$NZg`Tuuny)<;We7U8Nc4q@OAE2qmBNLi?=++(Sd^S3k&`4O#U%FF5pJ=u>7Tc)aNMsJ!I0LfnUS0%aqGb{ z%WG@GE7tgSbb{u_5^jrG>~K0r7fWJ~-MHU~n*FoC{mNd&ZfX=OYb7rJG^NG|Uw;8M p_r>7Qc&+H`sH2WL>Zs%K#Gfd5Tp^4i<(B{e002ovPDHLkV1llc@^t_J literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-00.png b/game/resources/animated/hero/hero_run/adventurer-run-00.png new file mode 100644 index 0000000000000000000000000000000000000000..e3d7cc057f4e6efed4564cae0c022f961089639c GIT binary patch literal 1073 zcmV-11kU@3P)-L~*N`~w~w_wx-vWOaAj0Tr1#<;j-qKOzD_ka(^N1x1$ z&X}lV2_{Q)VF4#B!HhU@z*x40Ez6)V7<6!9m(sy)IX>LAw!&0yZ+Wrbm)@Rp`uqOA z=llEh^b~T)A%`4t$iX_qMiZX+;2^tqRmjw_h`u0vsvm&8jUQWz>&!g0^&zql;pC6) zJX`%F0Q#&><(?`Da5p?{d1Lcz%I`np*6j&d72L-8!K(nMMJiVYh6s(`VsSAd|K;Nk z#fA!bZGVu^@-%(Xt5gNIq0j2cxzuMX*lg|-ExsH?$kr~SC)Ak_N2Quh8qsEH@Zyge1)v9?%~&S7b$(z zgDb2ub|=g$m4ZV-fv>2HLqWkcQ7F2)&s*Zk%Gd93!(jks7Ilifssy-RI{?7G-8=dI z{b2xJetZwSWbWnAcQ>hPX%I!v9kIk|tB|z>oVj5NC^^=_NT{8O;Y-Q&k6q|7#XP{7 z8v~-LzuywKtvxceI7g|sP!@aDq=523fN@PrTeo#{DU;zT$^(Jqx=dk$V4#(ATw%W^(;IwIr58P~L=fN@Qupt)7J zVa z&){|!1JJt?GzVSgOUZ*>pZuj0=e-HB!?;aTo3(>5fvnv}T2D=<^+p1T@=Bopo)kCZ zZhFslXT-N5_mQ9Po0leC*Ma4lZ`x47VEEdbS*=-l{*;_B-_4(N6HDpRT34nkj4wxdQmg3?G zuQ`7Cx4w*dv*L)7pD#BB0=!dE#14OcTC$J0T>_xg<)E#*&lVAo1tBrRNPR16%lye? zzd3gWpVJ9hIKOOfcBi7qc}+tqiYWB^Y5KM^ZNBC7?{-s~ymkki*EB{KBDfrRgtR%k r!#@Ou!00000NkvXXu0mjf3}y^* literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-01.png b/game/resources/animated/hero/hero_run/adventurer-run-01.png new file mode 100644 index 0000000000000000000000000000000000000000..96d832012e63466c4cfc2b9e5b864f7af21b1e72 GIT binary patch literal 1043 zcmV+u1nm2XP)2%@jT z9`t2H%IuT4maPSmLF4|wS~9H8Qm|=8m&G(IH~o{`n_eH%dw08vy4<7%$rmo1^SkHX z-|ut&p96K(Raaeg)m0Z_JDlG5>J!tMU()g-sDuD`sqfQ@{wcW+>&Z3v{V<(}+X2uP zG@kE>nE-!g9#mYhTLyBb_W*#IzPCcGt(Eb~DLN0gql6WHnMk076#$b8dr3nTV|^mU z+FH>TG&}E1SE4NeIn#T9VxhFjo=DCyJ~?Hl-KeG@cY98fiNDPoN1O2aJZAdd3cY$O ziR2tgSmE@yw}^M0qVtsq@vc)gR3)nFtToi#O-o=mK99_9Uy$swMq@xR!|yF~{mxyk zOuokc8`qd^D%an~AD!Ot{rPJ%;)4%AugJG+kfH8wJ6+Iqe6noDn)ceZk?9Gds>)B# z9Rgraq=n$+Apnj)+W~KS07zV%p?jc5gkRkV_g__wS<7A%e6ma`mm`(S5mi+HqN+-< zZxF^lV^5@o`AnME*WZmyPjH+L0AfvhsT2aL08-F(;ge-EmCM;S3&OHBQ*H@Msm9fE zIaEfbC)|brQ~@MkD3HnL?R->K9|4@bB34(k;ApjlY?4sVSpZU(&Jjg*8v;-TkQH6G z(@qH1$DiNdX#SBL24Fsu1|Waw9E&UE??UgEq2%E~SL3x>E4%PX5~*Cy^huH^7{;ao z^O-d7y#M7U`_+qI5d7^jQtLri0k{U~zkS=8-B7FFtY-218-a3{`a8{M((DI}xnEty zQPaJa)vW^YuYndO6JwjoEM$}Dr8OaY+^x-9vT2O3wE-|XcmaTB#|+jiOG2iB{_nLe N002ovPDHLkV1oY={2u@S literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-02.png b/game/resources/animated/hero/hero_run/adventurer-run-02.png new file mode 100644 index 0000000000000000000000000000000000000000..2e3b74df0890213dc31ab88d93038a14e31daed2 GIT binary patch literal 963 zcmV;!13dhRP) z<(}{RpYNRWoqM57nKEU{lqpl@u0xdC;is?fXM5W=nQu#|ap7<|0qB19h@pNhg@?92 zhYqv?$mLW<41M)GiFksO-<+YRqa6TsQN_E%CjsUobA|_YLs6prAH){Z65#sG4e4vz z%$2|x0InJr!BK^&$?GJO3At`3>rgTwIebl<^{cw5>h}D$5lk2IaC^1hKK{fml&NX` zUYVNKGm~#OLcwd~%idlI;Hz!cZ3{_NY_humsM(#A4YlJ8olG%bjodPG8-;0lI@&q- zfu9#Y`-DUH{=&e`J#cZ*a2y2-xut2M(rT4wCq{MK-mN?IxxV<39iD>52lo*Hyvg5~ zB*vA%7`>rE&i4qQi}Niokm(g%xN0blg16s+?ru_=CILKdw{G{NbY)*Sm!a;pZc+32K|^sAEaX^cCx9*_7hq0QzKCGR&n{-O z&-29Oc=Ot|JHGvjN{dB=qfx9C6#^g}jp~6u`~2GkLw;IQVVr&aIQ#kuZ(8QZ`&;q2 z-FVz?>@8ah8dTFOyMJQkU$x=PTaW7PU}X!>?0+E}$feWbmE#{9_G7w`!BgiXK!@*X z-8OvUD8G&=0C;cxLAA}wWAA^@@QI`JzkAqFOrZdBA36{_`W^@Yg>T6taF67vAJ={pH@W?%q$#{aRDn-pij#6yD z@;7+Nz3ouqa7oPiQL)T?#UuuA+70S{AfS@n&4fe+Rv^+Y2DKI2|md)8fP7KvDWF lSsnQ=t7}Gb2L|)5<{u@>Infw4#AN^g002ovPDHLkV1mT5)A0ZR literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_run/adventurer-run-03.png b/game/resources/animated/hero/hero_run/adventurer-run-03.png new file mode 100644 index 0000000000000000000000000000000000000000..a512930ec81d583aac03630d3d9fa7e4441facf0 GIT binary patch literal 1140 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 Date: Sat, 14 May 2022 21:35:29 +0300 Subject: [PATCH 17/44] create Hero 2.0 --- core/CMakeLists.txt | 2 +- core/event/management/controller/Idle.cpp | 6 ++ core/event/management/controller/Idle.hpp | 20 +++++ core/event/management/controller/Jump.cpp | 15 ++++ core/event/management/controller/Jump.hpp | 25 ++++++ core/event/management/controller/Run.cpp | 21 +++++ core/event/management/controller/Run.hpp | 29 +++++++ core/loader/LevelLoaderFromFile.cpp | 37 +++++---- game/mobs/hero/Hero.cpp | 98 +++-------------------- game/mobs/hero/Hero.hpp | 1 - 10 files changed, 145 insertions(+), 109 deletions(-) create mode 100644 core/event/management/controller/Idle.cpp create mode 100644 core/event/management/controller/Idle.hpp create mode 100644 core/event/management/controller/Jump.cpp create mode 100644 core/event/management/controller/Jump.hpp create mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/Run.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index e5e0a8a..a8995e7 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp new file mode 100644 index 0000000..f3ef8dd --- /dev/null +++ b/core/event/management/controller/Idle.cpp @@ -0,0 +1,6 @@ +#include "Idle.hpp" +mad::core::Idle::Idle() { +} +void mad::core::Idle::control() { + +} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp new file mode 100644 index 0000000..e7ea1ff --- /dev/null +++ b/core/event/management/controller/Idle.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_IDLE_HPP +#define MAD_IDLE_HPP +#include "Controller.hpp" + +namespace mad::core { + + class Idle : public Controller { + public: + explicit Idle(); + + void control() override; + + private: + + }; + +} + + +#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp new file mode 100644 index 0000000..9e5dd5a --- /dev/null +++ b/core/event/management/controller/Jump.cpp @@ -0,0 +1,15 @@ +#include "Jump.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +} +void mad::core::Jump::control() { + + auto impulse = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); + }); + }; + + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); +} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp new file mode 100644 index 0000000..25d5cf1 --- /dev/null +++ b/core/event/management/controller/Jump.hpp @@ -0,0 +1,25 @@ +#ifndef MAD_JUMP_HPP +#define MAD_JUMP_HPP + +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" +namespace mad::core { + + class Jump : public Controller { + public: + + explicit Jump(std::shared_ptr world, Entity::Id entity_id); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + + }; + +} + +#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp new file mode 100644 index 0000000..3fe6107 --- /dev/null +++ b/core/event/management/controller/Run.cpp @@ -0,0 +1,21 @@ +#include "Run.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +} +void mad::core::Run::control() { + + auto force = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); + }); + }; + //SPDLOG_DEBUG("controller 2"); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); + } + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp new file mode 100644 index 0000000..00c03e5 --- /dev/null +++ b/core/event/management/controller/Run.hpp @@ -0,0 +1,29 @@ +#ifndef MAD_RUN_HPP +#define MAD_RUN_HPP +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Run : public Controller { + public: + enum class Direction { + Right, + Left, + }; + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + Direction dir; + + }; + +} + +#endif//MAD_RUN_HPP diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 9276a96..0b1443d 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -10,7 +10,8 @@ namespace mad::core { - LevelLoaderFromFile::LevelLoaderFromFile(const std::filesystem::path &path) : m_level_directory(path) { + LevelLoaderFromFile::LevelLoaderFromFile(const std::filesystem::path &path) : m_level_directory(path), + m_level_map(path / "map") { std::ifstream input_config(path / "config.json"); CHECK_THROW(input_config, FileDoesNotExist, "Config file does not exist"); CHECK_THROW(m_level_map, FileDoesNotExist, "Map file does not exist"); @@ -162,25 +163,23 @@ namespace mad::core { image_storage = std::make_shared( std::unordered_map>( {{ImageStorage::TypeAction::Idle, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], - m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"]) - }, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], + + m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"])}, {ImageStorage::TypeAction::Run, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], - m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) - }} - ) - ); + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], + + m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"])}})); hero_id = world->create_physical_entity( 0, diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index dcee27d..8407ce7 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,12 +5,9 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Fall.hpp" -#include "event/management/controller/FlyUp.hpp" -#include "event/management/controller/GroundMovement.hpp" -#include "event/management/controller/JumpImpulse.hpp" -#include "event/management/controller/Movement.hpp" -#include "event/management/controller/StartJump.hpp" +#include "event/management/controller/Idle.hpp" +#include "event/management/controller/Jump.hpp" +#include "event/management/controller/Run.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -39,36 +36,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) - }, - {ImageStorage::TypeAction::Jump, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], - m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) - }, - {ImageStorage::TypeAction::Fly_up, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) - }, - {ImageStorage::TypeAction::Fall, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], - m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -95,21 +62,10 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - - + machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); + machine->add_state(std::make_shared(world, hero_id)); machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -119,43 +75,9 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - - machine->add_transition(3, 5, std::make_shared()); - machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - - float t = 1; - - machine->add_transition(4, 8, std::make_shared(t)); - machine->add_transition(5, 8, std::make_shared(t)); - machine->add_transition(6, 8, std::make_shared(t)); - - machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); - - machine->add_transition(7, 11, std::make_shared(t)); - machine->add_transition(8, 11, std::make_shared(t)); - machine->add_transition(9, 11, std::make_shared(t)); - - machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); - - machine->add_transition(10, 0, std::make_shared(t)); - machine->add_transition(11, 0, std::make_shared(t)); - machine->add_transition(12, 0, std::make_shared(t)); - - - - - - - + machine->add_transition(3, 0, std::make_shared(machine, 0)); + machine->add_transition(3, 1, std::make_shared(machine, 1)); + machine->add_transition(3, 2, std::make_shared(machine, 2)); machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index 70c3953..d8795df 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,7 +17,6 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; - float horizontal_velocity = 81; }; }// namespace mad::core From dbb1e769bf7e33ccc376aaf41321ecccaf6a1209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 22:04:45 +0300 Subject: [PATCH 18/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 6 ++++-- core/event/management/controller/Idle.hpp | 7 +++++-- core/event/management/controller/Run.cpp | 6 +++++- core/event/management/controller/Run.hpp | 6 +++--- game/mobs/hero/Hero.cpp | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp index f3ef8dd..282c2ba 100644 --- a/core/event/management/controller/Idle.cpp +++ b/core/event/management/controller/Idle.cpp @@ -1,6 +1,8 @@ #include "Idle.hpp" -mad::core::Idle::Idle() { +mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } -void mad::core::Idle::control() { +void mad::core::Idle::control() { + m_entity->set_action(ImageStorage::TypeAction::Idle); } diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp index e7ea1ff..fa94200 100644 --- a/core/event/management/controller/Idle.hpp +++ b/core/event/management/controller/Idle.hpp @@ -1,17 +1,20 @@ #ifndef MAD_IDLE_HPP #define MAD_IDLE_HPP #include "Controller.hpp" +#include "world/LocalWorld.hpp" namespace mad::core { class Idle : public Controller { public: - explicit Idle(); + explicit Idle(std::shared_ptr world, Entity::Id entity_id); void control() override; private: - + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity* m_entity; }; } diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp index 3fe6107..c8cfd7b 100644 --- a/core/event/management/controller/Run.cpp +++ b/core/event/management/controller/Run.cpp @@ -1,6 +1,8 @@ #include "Run.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +#include +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } void mad::core::Run::control() { @@ -11,6 +13,7 @@ void mad::core::Run::control() { }); }; //SPDLOG_DEBUG("controller 2"); + m_entity->set_action(ImageStorage::TypeAction::Run); if(dir == Direction::Right){ m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); } @@ -18,4 +21,5 @@ void mad::core::Run::control() { m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); } + } diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp index 00c03e5..07ed05c 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Run.hpp @@ -12,15 +12,15 @@ namespace mad::core { Right, Left, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); void control() override; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id m_entity_id; - std::shared_ptr key; Direction dir; + PhysicalEntity* m_entity; }; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 8407ce7..379854a 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -62,7 +62,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); machine->add_state(std::make_shared(world, hero_id)); From 863ee184a6ae73e1f6206660e4deaf2f10a64074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:01:08 +0300 Subject: [PATCH 19/44] set animations in statemachine --- core/CMakeLists.txt | 2 +- core/event/management/controller/Idle.cpp | 8 -- core/event/management/controller/Idle.hpp | 23 ------ core/event/management/controller/Jump.cpp | 15 ---- core/event/management/controller/Jump.hpp | 25 ------ core/event/management/controller/Run.cpp | 25 ------ core/event/management/controller/Run.hpp | 29 ------- game/mobs/hero/Hero.cpp | 98 ++++++++++++++++++++--- game/mobs/hero/Hero.hpp | 1 + 9 files changed, 90 insertions(+), 136 deletions(-) delete mode 100644 core/event/management/controller/Idle.cpp delete mode 100644 core/event/management/controller/Idle.hpp delete mode 100644 core/event/management/controller/Jump.cpp delete mode 100644 core/event/management/controller/Jump.hpp delete mode 100644 core/event/management/controller/Run.cpp delete mode 100644 core/event/management/controller/Run.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index a8995e7..e5e0a8a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp deleted file mode 100644 index 282c2ba..0000000 --- a/core/event/management/controller/Idle.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Idle.hpp" -mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} - -void mad::core::Idle::control() { - m_entity->set_action(ImageStorage::TypeAction::Idle); -} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp deleted file mode 100644 index fa94200..0000000 --- a/core/event/management/controller/Idle.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAD_IDLE_HPP -#define MAD_IDLE_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" - -namespace mad::core { - - class Idle : public Controller { - public: - explicit Idle(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - PhysicalEntity* m_entity; - }; - -} - - -#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp deleted file mode 100644 index 9e5dd5a..0000000 --- a/core/event/management/controller/Jump.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Jump.hpp" -#include "world/intent/LambdaIntent.hpp" -mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { -} -void mad::core::Jump::control() { - - auto impulse = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); - }); - }; - - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); -} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp deleted file mode 100644 index 25d5cf1..0000000 --- a/core/event/management/controller/Jump.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAD_JUMP_HPP -#define MAD_JUMP_HPP - -#include "Controller.hpp" -#include "world/LocalWorld.hpp" -#include "world/World.hpp" -namespace mad::core { - - class Jump : public Controller { - public: - - explicit Jump(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - std::shared_ptr key; - - }; - -} - -#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp deleted file mode 100644 index c8cfd7b..0000000 --- a/core/event/management/controller/Run.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Run.hpp" -#include "world/intent/LambdaIntent.hpp" -#include -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} -void mad::core::Run::control() { - - auto force = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); - }); - }; - //SPDLOG_DEBUG("controller 2"); - m_entity->set_action(ImageStorage::TypeAction::Run); - if(dir == Direction::Right){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); - } - else if(dir == Direction::Left){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); - } - - -} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp deleted file mode 100644 index 07ed05c..0000000 --- a/core/event/management/controller/Run.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MAD_RUN_HPP -#define MAD_RUN_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" -#include "world/World.hpp" - -namespace mad::core { - - class Run : public Controller { - public: - enum class Direction { - Right, - Left, - }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - Direction dir; - PhysicalEntity* m_entity; - - }; - -} - -#endif//MAD_RUN_HPP diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 379854a..dcee27d 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,9 +5,12 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Idle.hpp" -#include "event/management/controller/Jump.hpp" -#include "event/management/controller/Run.hpp" +#include "event/management/controller/Fall.hpp" +#include "event/management/controller/FlyUp.hpp" +#include "event/management/controller/GroundMovement.hpp" +#include "event/management/controller/JumpImpulse.hpp" +#include "event/management/controller/Movement.hpp" +#include "event/management/controller/StartJump.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -36,6 +39,36 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }, + {ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fly_up, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fall, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -62,10 +95,21 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -75,9 +119,43 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(3, 0, std::make_shared(machine, 0)); - machine->add_transition(3, 1, std::make_shared(machine, 1)); - machine->add_transition(3, 2, std::make_shared(machine, 2)); + + machine->add_transition(3, 5, std::make_shared()); + machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); + + float t = 1; + + machine->add_transition(4, 8, std::make_shared(t)); + machine->add_transition(5, 8, std::make_shared(t)); + machine->add_transition(6, 8, std::make_shared(t)); + + machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(7, 11, std::make_shared(t)); + machine->add_transition(8, 11, std::make_shared(t)); + machine->add_transition(9, 11, std::make_shared(t)); + + machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(10, 0, std::make_shared(t)); + machine->add_transition(11, 0, std::make_shared(t)); + machine->add_transition(12, 0, std::make_shared(t)); + + + + + + + machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index d8795df..70c3953 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,6 +17,7 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; + float horizontal_velocity = 81; }; }// namespace mad::core From 8d5043b742b2f7c91f9dd183860a69c69f276397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 21:35:29 +0300 Subject: [PATCH 20/44] create Hero 2.0 --- core/event/management/controller/Idle.cpp | 6 +++++ core/event/management/controller/Idle.hpp | 20 ++++++++++++++++ core/event/management/controller/Jump.cpp | 15 ++++++++++++ core/event/management/controller/Jump.hpp | 25 +++++++++++++++++++ core/event/management/controller/Run.cpp | 21 ++++++++++++++++ core/event/management/controller/Run.hpp | 29 +++++++++++++++++++++++ 6 files changed, 116 insertions(+) create mode 100644 core/event/management/controller/Idle.cpp create mode 100644 core/event/management/controller/Idle.hpp create mode 100644 core/event/management/controller/Jump.cpp create mode 100644 core/event/management/controller/Jump.hpp create mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/Run.hpp diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp new file mode 100644 index 0000000..f3ef8dd --- /dev/null +++ b/core/event/management/controller/Idle.cpp @@ -0,0 +1,6 @@ +#include "Idle.hpp" +mad::core::Idle::Idle() { +} +void mad::core::Idle::control() { + +} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp new file mode 100644 index 0000000..e7ea1ff --- /dev/null +++ b/core/event/management/controller/Idle.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_IDLE_HPP +#define MAD_IDLE_HPP +#include "Controller.hpp" + +namespace mad::core { + + class Idle : public Controller { + public: + explicit Idle(); + + void control() override; + + private: + + }; + +} + + +#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp new file mode 100644 index 0000000..9e5dd5a --- /dev/null +++ b/core/event/management/controller/Jump.cpp @@ -0,0 +1,15 @@ +#include "Jump.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +} +void mad::core::Jump::control() { + + auto impulse = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); + }); + }; + + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); +} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp new file mode 100644 index 0000000..25d5cf1 --- /dev/null +++ b/core/event/management/controller/Jump.hpp @@ -0,0 +1,25 @@ +#ifndef MAD_JUMP_HPP +#define MAD_JUMP_HPP + +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" +namespace mad::core { + + class Jump : public Controller { + public: + + explicit Jump(std::shared_ptr world, Entity::Id entity_id); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + + }; + +} + +#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp new file mode 100644 index 0000000..3fe6107 --- /dev/null +++ b/core/event/management/controller/Run.cpp @@ -0,0 +1,21 @@ +#include "Run.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +} +void mad::core::Run::control() { + + auto force = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); + }); + }; + //SPDLOG_DEBUG("controller 2"); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); + } + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp new file mode 100644 index 0000000..00c03e5 --- /dev/null +++ b/core/event/management/controller/Run.hpp @@ -0,0 +1,29 @@ +#ifndef MAD_RUN_HPP +#define MAD_RUN_HPP +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Run : public Controller { + public: + enum class Direction { + Right, + Left, + }; + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + Direction dir; + + }; + +} + +#endif//MAD_RUN_HPP From c5ed894daf7ff80ac8aa97e6ffd572ca79a1c05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 22:04:45 +0300 Subject: [PATCH 21/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 6 +- core/event/management/controller/Idle.hpp | 7 +- core/event/management/controller/Run.cpp | 6 +- core/event/management/controller/Run.hpp | 6 +- game/mobs/hero/Hero.cpp | 89 ++--------------------- 5 files changed, 24 insertions(+), 90 deletions(-) diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp index f3ef8dd..282c2ba 100644 --- a/core/event/management/controller/Idle.cpp +++ b/core/event/management/controller/Idle.cpp @@ -1,6 +1,8 @@ #include "Idle.hpp" -mad::core::Idle::Idle() { +mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } -void mad::core::Idle::control() { +void mad::core::Idle::control() { + m_entity->set_action(ImageStorage::TypeAction::Idle); } diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp index e7ea1ff..fa94200 100644 --- a/core/event/management/controller/Idle.hpp +++ b/core/event/management/controller/Idle.hpp @@ -1,17 +1,20 @@ #ifndef MAD_IDLE_HPP #define MAD_IDLE_HPP #include "Controller.hpp" +#include "world/LocalWorld.hpp" namespace mad::core { class Idle : public Controller { public: - explicit Idle(); + explicit Idle(std::shared_ptr world, Entity::Id entity_id); void control() override; private: - + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity* m_entity; }; } diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp index 3fe6107..c8cfd7b 100644 --- a/core/event/management/controller/Run.cpp +++ b/core/event/management/controller/Run.cpp @@ -1,6 +1,8 @@ #include "Run.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +#include +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } void mad::core::Run::control() { @@ -11,6 +13,7 @@ void mad::core::Run::control() { }); }; //SPDLOG_DEBUG("controller 2"); + m_entity->set_action(ImageStorage::TypeAction::Run); if(dir == Direction::Right){ m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); } @@ -18,4 +21,5 @@ void mad::core::Run::control() { m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); } + } diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp index 00c03e5..07ed05c 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Run.hpp @@ -12,15 +12,15 @@ namespace mad::core { Right, Left, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); void control() override; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id m_entity_id; - std::shared_ptr key; Direction dir; + PhysicalEntity* m_entity; }; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index dcee27d..c6ca448 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -39,36 +39,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) - }, - {ImageStorage::TypeAction::Jump, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], - m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) - }, - {ImageStorage::TypeAction::Fly_up, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) - }, - {ImageStorage::TypeAction::Fall, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], - m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], - m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -95,21 +65,10 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - - + machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); + machine->add_state(std::make_shared(world, hero_id)); machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -119,43 +78,9 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - - machine->add_transition(3, 5, std::make_shared()); - machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - - float t = 1; - - machine->add_transition(4, 8, std::make_shared(t)); - machine->add_transition(5, 8, std::make_shared(t)); - machine->add_transition(6, 8, std::make_shared(t)); - - machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); - - machine->add_transition(7, 11, std::make_shared(t)); - machine->add_transition(8, 11, std::make_shared(t)); - machine->add_transition(9, 11, std::make_shared(t)); - - machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); - - machine->add_transition(10, 0, std::make_shared(t)); - machine->add_transition(11, 0, std::make_shared(t)); - machine->add_transition(12, 0, std::make_shared(t)); - - - - - - - + machine->add_transition(3, 0, std::make_shared(machine, 0)); + machine->add_transition(3, 1, std::make_shared(machine, 1)); + machine->add_transition(3, 2, std::make_shared(machine, 2)); machine->set_initial_state(0); controllers.push_back(machine); } From b84ebde06f3d1344ffcda5f38ffebaff8eccf062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:01:08 +0300 Subject: [PATCH 22/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 8 --- core/event/management/controller/Idle.hpp | 23 --------- core/event/management/controller/Jump.cpp | 15 ------ core/event/management/controller/Jump.hpp | 25 ---------- core/event/management/controller/Run.cpp | 25 ---------- core/event/management/controller/Run.hpp | 29 ----------- game/mobs/hero/Hero.cpp | 59 ++++++++++++++++++++--- 7 files changed, 52 insertions(+), 132 deletions(-) delete mode 100644 core/event/management/controller/Idle.cpp delete mode 100644 core/event/management/controller/Idle.hpp delete mode 100644 core/event/management/controller/Jump.cpp delete mode 100644 core/event/management/controller/Jump.hpp delete mode 100644 core/event/management/controller/Run.cpp delete mode 100644 core/event/management/controller/Run.hpp diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp deleted file mode 100644 index 282c2ba..0000000 --- a/core/event/management/controller/Idle.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Idle.hpp" -mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} - -void mad::core::Idle::control() { - m_entity->set_action(ImageStorage::TypeAction::Idle); -} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp deleted file mode 100644 index fa94200..0000000 --- a/core/event/management/controller/Idle.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAD_IDLE_HPP -#define MAD_IDLE_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" - -namespace mad::core { - - class Idle : public Controller { - public: - explicit Idle(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - PhysicalEntity* m_entity; - }; - -} - - -#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp deleted file mode 100644 index 9e5dd5a..0000000 --- a/core/event/management/controller/Jump.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Jump.hpp" -#include "world/intent/LambdaIntent.hpp" -mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { -} -void mad::core::Jump::control() { - - auto impulse = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); - }); - }; - - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); -} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp deleted file mode 100644 index 25d5cf1..0000000 --- a/core/event/management/controller/Jump.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAD_JUMP_HPP -#define MAD_JUMP_HPP - -#include "Controller.hpp" -#include "world/LocalWorld.hpp" -#include "world/World.hpp" -namespace mad::core { - - class Jump : public Controller { - public: - - explicit Jump(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - std::shared_ptr key; - - }; - -} - -#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp deleted file mode 100644 index c8cfd7b..0000000 --- a/core/event/management/controller/Run.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Run.hpp" -#include "world/intent/LambdaIntent.hpp" -#include -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} -void mad::core::Run::control() { - - auto force = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); - }); - }; - //SPDLOG_DEBUG("controller 2"); - m_entity->set_action(ImageStorage::TypeAction::Run); - if(dir == Direction::Right){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); - } - else if(dir == Direction::Left){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); - } - - -} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp deleted file mode 100644 index 07ed05c..0000000 --- a/core/event/management/controller/Run.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MAD_RUN_HPP -#define MAD_RUN_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" -#include "world/World.hpp" - -namespace mad::core { - - class Run : public Controller { - public: - enum class Direction { - Right, - Left, - }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - Direction dir; - PhysicalEntity* m_entity; - - }; - -} - -#endif//MAD_RUN_HPP diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index c6ca448..9385d06 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -65,10 +65,21 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared()); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -78,9 +89,43 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(3, 0, std::make_shared(machine, 0)); - machine->add_transition(3, 1, std::make_shared(machine, 1)); - machine->add_transition(3, 2, std::make_shared(machine, 2)); + + machine->add_transition(3, 5, std::make_shared()); + machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); + + float t = 1; + + machine->add_transition(4, 8, std::make_shared(t)); + machine->add_transition(5, 8, std::make_shared(t)); + machine->add_transition(6, 8, std::make_shared(t)); + + machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(7, 11, std::make_shared(t)); + machine->add_transition(8, 11, std::make_shared(t)); + machine->add_transition(9, 11, std::make_shared(t)); + + machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(10, 0, std::make_shared(t)); + machine->add_transition(11, 0, std::make_shared(t)); + machine->add_transition(12, 0, std::make_shared(t)); + + + + + + + machine->set_initial_state(0); controllers.push_back(machine); } From 6774b46aa9fc4b075fc2695e794de05a05904fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 21:35:29 +0300 Subject: [PATCH 23/44] create Hero 2.0 --- core/CMakeLists.txt | 2 +- core/event/management/controller/Idle.cpp | 6 ++ core/event/management/controller/Idle.hpp | 20 +++++++ core/event/management/controller/Jump.cpp | 15 +++++ core/event/management/controller/Jump.hpp | 25 +++++++++ core/event/management/controller/Run.cpp | 21 +++++++ core/event/management/controller/Run.hpp | 29 ++++++++++ core/loader/LevelLoaderFromFile.cpp | 20 +++---- game/mobs/hero/Hero.cpp | 68 ++++------------------- game/mobs/hero/Hero.hpp | 1 - 10 files changed, 136 insertions(+), 71 deletions(-) create mode 100644 core/event/management/controller/Idle.cpp create mode 100644 core/event/management/controller/Idle.hpp create mode 100644 core/event/management/controller/Jump.cpp create mode 100644 core/event/management/controller/Jump.hpp create mode 100644 core/event/management/controller/Run.cpp create mode 100644 core/event/management/controller/Run.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index e5e0a8a..a8995e7 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp new file mode 100644 index 0000000..f3ef8dd --- /dev/null +++ b/core/event/management/controller/Idle.cpp @@ -0,0 +1,6 @@ +#include "Idle.hpp" +mad::core::Idle::Idle() { +} +void mad::core::Idle::control() { + +} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp new file mode 100644 index 0000000..e7ea1ff --- /dev/null +++ b/core/event/management/controller/Idle.hpp @@ -0,0 +1,20 @@ +#ifndef MAD_IDLE_HPP +#define MAD_IDLE_HPP +#include "Controller.hpp" + +namespace mad::core { + + class Idle : public Controller { + public: + explicit Idle(); + + void control() override; + + private: + + }; + +} + + +#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp new file mode 100644 index 0000000..9e5dd5a --- /dev/null +++ b/core/event/management/controller/Jump.cpp @@ -0,0 +1,15 @@ +#include "Jump.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +} +void mad::core::Jump::control() { + + auto impulse = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); + }); + }; + + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); +} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp new file mode 100644 index 0000000..25d5cf1 --- /dev/null +++ b/core/event/management/controller/Jump.hpp @@ -0,0 +1,25 @@ +#ifndef MAD_JUMP_HPP +#define MAD_JUMP_HPP + +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" +namespace mad::core { + + class Jump : public Controller { + public: + + explicit Jump(std::shared_ptr world, Entity::Id entity_id); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + + }; + +} + +#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp new file mode 100644 index 0000000..3fe6107 --- /dev/null +++ b/core/event/management/controller/Run.cpp @@ -0,0 +1,21 @@ +#include "Run.hpp" +#include "world/intent/LambdaIntent.hpp" +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +} +void mad::core::Run::control() { + + auto force = [](mad::core::Vec2d dir) { + return mad::core::LambdaIntent( + [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { + mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); + }); + }; + //SPDLOG_DEBUG("controller 2"); + if(dir == Direction::Right){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); + } + else if(dir == Direction::Left){ + m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); + } + +} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp new file mode 100644 index 0000000..00c03e5 --- /dev/null +++ b/core/event/management/controller/Run.hpp @@ -0,0 +1,29 @@ +#ifndef MAD_RUN_HPP +#define MAD_RUN_HPP +#include "Controller.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Run : public Controller { + public: + enum class Direction { + Right, + Left, + }; + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + + void control() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + std::shared_ptr key; + Direction dir; + + }; + +} + +#endif//MAD_RUN_HPP diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 0b1443d..9ce3747 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -28,10 +28,6 @@ namespace mad::core { m_config_json["camera"]["position"]["y"]}; auto camera = std::make_shared(camera_position, world); - controllers = {std::make_shared( - camera)}; - - Entity::Id hero_id = create_world(world); camera->turn_on(*level_dispatcher, hero_id); @@ -63,7 +59,7 @@ namespace mad::core { machine->set_initial_state(0); std::vector> controllers{machine, std::make_shared( - camera)};*/ + camera)}; auto level_runner = std::make_unique( system_listener, @@ -72,7 +68,8 @@ namespace mad::core { global_dispatcher, level_dispatcher, world, - controllers); + controllers + ); level_dispatcher->registry(std::make_shared(*level_runner)); level_dispatcher->registry(std::make_shared(*level_runner)); @@ -81,14 +78,13 @@ namespace mad::core { } Entity::Id LevelLoaderFromFile::create_world(std::shared_ptr world) { - m_level_map = std::ifstream(m_level_directory / "map"); float object_size = m_config_json["block"]; float current_position_x = object_size / 2; float current_position_y = object_size / 2; Entity::Id hero_id = 0; std::string map_line; while (std::getline(m_level_map, map_line)) { - for (char object : map_line) { + for (char object: map_line) { switch (m_objects[object]) { case Objects::UnstableBlock: { create_block(world, @@ -142,14 +138,16 @@ namespace mad::core { {{ImageStorage::TypeAction::Idle, std::make_shared(source, block_size, block_size, - StaticImage::TransformType::Tile)}})); + StaticImage::TransformType::Tile) + }})); Entity::Id square_id = world->create_physical_entity( 0, position, 0, image_storage, - is_stable); + is_stable + ); } Entity::Id LevelLoaderFromFile::create_hero(std::shared_ptr world, Vec2d position) { @@ -191,4 +189,4 @@ namespace mad::core { return hero_id; } -}// namespace mad::core \ No newline at end of file +} \ No newline at end of file diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 9385d06..8407ce7 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,12 +5,9 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Fall.hpp" -#include "event/management/controller/FlyUp.hpp" -#include "event/management/controller/GroundMovement.hpp" -#include "event/management/controller/JumpImpulse.hpp" -#include "event/management/controller/Movement.hpp" -#include "event/management/controller/StartJump.hpp" +#include "event/management/controller/Idle.hpp" +#include "event/management/controller/Jump.hpp" +#include "event/management/controller/Run.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -65,21 +62,10 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - - + machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); + machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); + machine->add_state(std::make_shared(world, hero_id)); machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -89,43 +75,9 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - - machine->add_transition(3, 5, std::make_shared()); - machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - - float t = 1; - - machine->add_transition(4, 8, std::make_shared(t)); - machine->add_transition(5, 8, std::make_shared(t)); - machine->add_transition(6, 8, std::make_shared(t)); - - machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); - - machine->add_transition(7, 11, std::make_shared(t)); - machine->add_transition(8, 11, std::make_shared(t)); - machine->add_transition(9, 11, std::make_shared(t)); - - machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); - - machine->add_transition(10, 0, std::make_shared(t)); - machine->add_transition(11, 0, std::make_shared(t)); - machine->add_transition(12, 0, std::make_shared(t)); - - - - - - - + machine->add_transition(3, 0, std::make_shared(machine, 0)); + machine->add_transition(3, 1, std::make_shared(machine, 1)); + machine->add_transition(3, 2, std::make_shared(machine, 2)); machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index 70c3953..d8795df 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,7 +17,6 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; - float horizontal_velocity = 81; }; }// namespace mad::core From 5e9695828d16ff5f44dba36ef7735b36594bad55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sat, 14 May 2022 22:04:45 +0300 Subject: [PATCH 24/44] set animations in statemachine --- core/event/management/controller/Idle.cpp | 6 ++++-- core/event/management/controller/Idle.hpp | 7 +++++-- core/event/management/controller/Run.cpp | 6 +++++- core/event/management/controller/Run.hpp | 6 +++--- game/mobs/hero/Hero.cpp | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp index f3ef8dd..282c2ba 100644 --- a/core/event/management/controller/Idle.cpp +++ b/core/event/management/controller/Idle.cpp @@ -1,6 +1,8 @@ #include "Idle.hpp" -mad::core::Idle::Idle() { +mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } -void mad::core::Idle::control() { +void mad::core::Idle::control() { + m_entity->set_action(ImageStorage::TypeAction::Idle); } diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp index e7ea1ff..fa94200 100644 --- a/core/event/management/controller/Idle.hpp +++ b/core/event/management/controller/Idle.hpp @@ -1,17 +1,20 @@ #ifndef MAD_IDLE_HPP #define MAD_IDLE_HPP #include "Controller.hpp" +#include "world/LocalWorld.hpp" namespace mad::core { class Idle : public Controller { public: - explicit Idle(); + explicit Idle(std::shared_ptr world, Entity::Id entity_id); void control() override; private: - + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity* m_entity; }; } diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp index 3fe6107..c8cfd7b 100644 --- a/core/event/management/controller/Run.cpp +++ b/core/event/management/controller/Run.cpp @@ -1,6 +1,8 @@ #include "Run.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ +#include +mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } void mad::core::Run::control() { @@ -11,6 +13,7 @@ void mad::core::Run::control() { }); }; //SPDLOG_DEBUG("controller 2"); + m_entity->set_action(ImageStorage::TypeAction::Run); if(dir == Direction::Right){ m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); } @@ -18,4 +21,5 @@ void mad::core::Run::control() { m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); } + } diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp index 00c03e5..07ed05c 100644 --- a/core/event/management/controller/Run.hpp +++ b/core/event/management/controller/Run.hpp @@ -12,15 +12,15 @@ namespace mad::core { Right, Left, }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); + explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); void control() override; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id m_entity_id; - std::shared_ptr key; Direction dir; + PhysicalEntity* m_entity; }; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 8407ce7..379854a 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -62,7 +62,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared()); + machine->add_state(std::make_shared(world, hero_id)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); machine->add_state(std::make_shared(world, hero_id)); From 32ecd069026ae5ae9116b3febe615e50f87b99aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:01:08 +0300 Subject: [PATCH 25/44] set animations in statemachine --- core/CMakeLists.txt | 2 +- core/event/management/controller/Idle.cpp | 8 -- core/event/management/controller/Idle.hpp | 23 ------ core/event/management/controller/Jump.cpp | 15 ---- core/event/management/controller/Jump.hpp | 25 ------ core/event/management/controller/Run.cpp | 25 ------ core/event/management/controller/Run.hpp | 29 ------- game/mobs/hero/Hero.cpp | 98 ++++++++++++++++++++--- game/mobs/hero/Hero.hpp | 1 + 9 files changed, 90 insertions(+), 136 deletions(-) delete mode 100644 core/event/management/controller/Idle.cpp delete mode 100644 core/event/management/controller/Idle.hpp delete mode 100644 core/event/management/controller/Jump.cpp delete mode 100644 core/event/management/controller/Jump.hpp delete mode 100644 core/event/management/controller/Run.cpp delete mode 100644 core/event/management/controller/Run.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index a8995e7..e5e0a8a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -82,7 +82,7 @@ set( visual/image/storage/ImageStorage.cpp visual/image/storage/ImageStorage.hpp visual/Renderable.hpp visual/Camera.cpp visual/Camera.hpp - event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/controller/Idle.hpp event/management/controller/Idle.cpp event/management/controller/Run.hpp event/management/controller/Run.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/Jump.hpp event/management/controller/Jump.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp) + event/management/condition/TrueCondition.hpp event/management/condition/TrueCondition.cpp event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/Idle.cpp b/core/event/management/controller/Idle.cpp deleted file mode 100644 index 282c2ba..0000000 --- a/core/event/management/controller/Idle.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Idle.hpp" -mad::core::Idle::Idle(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} - -void mad::core::Idle::control() { - m_entity->set_action(ImageStorage::TypeAction::Idle); -} diff --git a/core/event/management/controller/Idle.hpp b/core/event/management/controller/Idle.hpp deleted file mode 100644 index fa94200..0000000 --- a/core/event/management/controller/Idle.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef MAD_IDLE_HPP -#define MAD_IDLE_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" - -namespace mad::core { - - class Idle : public Controller { - public: - explicit Idle(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - PhysicalEntity* m_entity; - }; - -} - - -#endif//MAD_IDLE_HPP diff --git a/core/event/management/controller/Jump.cpp b/core/event/management/controller/Jump.cpp deleted file mode 100644 index 9e5dd5a..0000000 --- a/core/event/management/controller/Jump.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Jump.hpp" -#include "world/intent/LambdaIntent.hpp" -mad::core::Jump::Jump(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { -} -void mad::core::Jump::control() { - - auto impulse = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_linear_impulse_to_center(dir, event_dispatcher); - }); - }; - - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -200000.0f})); -} diff --git a/core/event/management/controller/Jump.hpp b/core/event/management/controller/Jump.hpp deleted file mode 100644 index 25d5cf1..0000000 --- a/core/event/management/controller/Jump.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAD_JUMP_HPP -#define MAD_JUMP_HPP - -#include "Controller.hpp" -#include "world/LocalWorld.hpp" -#include "world/World.hpp" -namespace mad::core { - - class Jump : public Controller { - public: - - explicit Jump(std::shared_ptr world, Entity::Id entity_id); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - std::shared_ptr key; - - }; - -} - -#endif//MAD_JUMP_HPP diff --git a/core/event/management/controller/Run.cpp b/core/event/management/controller/Run.cpp deleted file mode 100644 index c8cfd7b..0000000 --- a/core/event/management/controller/Run.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "Run.hpp" -#include "world/intent/LambdaIntent.hpp" -#include -mad::core::Run::Run(std::shared_ptr world, Entity::Id entity_id, Direction dir) : m_world(world), m_entity_id(entity_id), dir(dir){ - m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); -} -void mad::core::Run::control() { - - auto force = [](mad::core::Vec2d dir) { - return mad::core::LambdaIntent( - [=](mad::core::Entity &entity, mad::core::EventDispatcher &event_dispatcher) { - mad::core::cast_to(entity).apply_force_to_center(dir, event_dispatcher); - }); - }; - //SPDLOG_DEBUG("controller 2"); - m_entity->set_action(ImageStorage::TypeAction::Run); - if(dir == Direction::Right){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{100000.0f, 0.0f})); - } - else if(dir == Direction::Left){ - m_world->manipulate_entity_id(m_entity_id, force(mad::core::Vec2d{-100000.0f, 0.0f})); - } - - -} diff --git a/core/event/management/controller/Run.hpp b/core/event/management/controller/Run.hpp deleted file mode 100644 index 07ed05c..0000000 --- a/core/event/management/controller/Run.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MAD_RUN_HPP -#define MAD_RUN_HPP -#include "Controller.hpp" -#include "world/LocalWorld.hpp" -#include "world/World.hpp" - -namespace mad::core { - - class Run : public Controller { - public: - enum class Direction { - Right, - Left, - }; - explicit Run(std::shared_ptr world, Entity::Id entity_id, Direction dir); - - void control() override; - - private: - std::shared_ptr m_world; - Entity::Id m_entity_id; - Direction dir; - PhysicalEntity* m_entity; - - }; - -} - -#endif//MAD_RUN_HPP diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 379854a..dcee27d 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,9 +5,12 @@ #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/Idle.hpp" -#include "event/management/controller/Jump.hpp" -#include "event/management/controller/Run.hpp" +#include "event/management/controller/Fall.hpp" +#include "event/management/controller/FlyUp.hpp" +#include "event/management/controller/GroundMovement.hpp" +#include "event/management/controller/JumpImpulse.hpp" +#include "event/management/controller/Movement.hpp" +#include "event/management/controller/StartJump.hpp" #include "event/management/controller/statemachine/StateMachine.hpp" mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_config_json, std::shared_ptr level_dispatcher, std::vector> &controllers) : level_dispatcher(level_dispatcher){ std::filesystem::path source(m_config_json["animated_resources"]); @@ -36,6 +39,36 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) + }, + {ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fly_up, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) + }, + {ImageStorage::TypeAction::Fall, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], + m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], + m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], + m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) }} ) ); @@ -62,10 +95,21 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Right)); - machine->add_state(std::make_shared(world, hero_id, Run::Direction::Left)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + + machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); @@ -75,9 +119,43 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(3, 0, std::make_shared(machine, 0)); - machine->add_transition(3, 1, std::make_shared(machine, 1)); - machine->add_transition(3, 2, std::make_shared(machine, 2)); + + machine->add_transition(3, 5, std::make_shared()); + machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); + + float t = 1; + + machine->add_transition(4, 8, std::make_shared(t)); + machine->add_transition(5, 8, std::make_shared(t)); + machine->add_transition(6, 8, std::make_shared(t)); + + machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(7, 11, std::make_shared(t)); + machine->add_transition(8, 11, std::make_shared(t)); + machine->add_transition(9, 11, std::make_shared(t)); + + machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(10, 0, std::make_shared(t)); + machine->add_transition(11, 0, std::make_shared(t)); + machine->add_transition(12, 0, std::make_shared(t)); + + + + + + + machine->set_initial_state(0); controllers.push_back(machine); } diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index d8795df..70c3953 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -17,6 +17,7 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; int last_pressed_key; + float horizontal_velocity = 81; }; }// namespace mad::core From 3860f6ad71eee85a08413fa9790176f9fe31f047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 17:51:00 +0300 Subject: [PATCH 26/44] ? --- core/event/management/controller/Movement.cpp | 2 ++ .../image/animated/RenderableAnimatedSeveralFiles.cpp | 2 +- core/world/entity/PhysicalEntity.cpp | 2 +- game/mobs/hero/Hero.cpp | 7 +------ game/resources/levels/level_01/config.json | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/core/event/management/controller/Movement.cpp b/core/event/management/controller/Movement.cpp index a580c78..53d6cea 100644 --- a/core/event/management/controller/Movement.cpp +++ b/core/event/management/controller/Movement.cpp @@ -13,9 +13,11 @@ void mad::core::Movement::control() { if(dir == Direction::Right || dir == Direction::Left){ m_entity->set_action(Move_animation); if(dir == Direction::Right){ + m_entity->flip_over(Image::Orientation::Right); m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(velocity)); } else if(dir == Direction::Left){ + m_entity->flip_over(Image::Orientation::Left); m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(-velocity)); } } diff --git a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp index f53e098..7f63794 100644 --- a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp +++ b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp @@ -22,7 +22,7 @@ namespace mad::core { m_textures.push_back(texture); } - std::reverse(m_textures.begin(), m_textures.end()); + //std::reverse(m_textures.begin(), m_textures.end()); auto [texture_width, texture_height] = m_textures[0].getSize(); diff --git a/core/world/entity/PhysicalEntity.cpp b/core/world/entity/PhysicalEntity.cpp index 6f94482..478df92 100644 --- a/core/world/entity/PhysicalEntity.cpp +++ b/core/world/entity/PhysicalEntity.cpp @@ -37,7 +37,7 @@ mad::core::PhysicalEntity::PhysicalEntity(std::int32_t id, int z_ind, Vec2d init b2FixtureDef fixtureDef; fixtureDef.shape = &dynamicBox; fixtureDef.density = 1.0f; - fixtureDef.friction = 0.0f; + fixtureDef.friction = 50.0f; fixtureDef.restitution = 0.0f; body->SetLinearDamping(0.0000000001); body->SetAngularDamping(0); diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index dcee27d..dc26bfb 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -23,7 +23,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {{ImageStorage::TypeAction::Idle, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], - m_config_json["hero"]["animated"]["actions"]["idle"]["count_files"], m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], @@ -33,7 +32,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {ImageStorage::TypeAction::Run, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], - m_config_json["hero"]["animated"]["actions"]["run"]["count_files"], m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], @@ -43,7 +41,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {ImageStorage::TypeAction::Jump, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], - m_config_json["hero"]["animated"]["actions"]["jump"]["count_files"], m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], @@ -53,7 +50,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {ImageStorage::TypeAction::Fly_up, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["count_files"], m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], @@ -63,7 +59,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ {ImageStorage::TypeAction::Fall, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], - m_config_json["hero"]["animated"]["actions"]["fall"]["count_files"], m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], @@ -126,7 +121,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - float t = 1; + float t = 2; machine->add_transition(4, 8, std::make_shared(t)); machine->add_transition(5, 8, std::make_shared(t)); diff --git a/game/resources/levels/level_01/config.json b/game/resources/levels/level_01/config.json index 29f0003..31d26c9 100644 --- a/game/resources/levels/level_01/config.json +++ b/game/resources/levels/level_01/config.json @@ -44,7 +44,7 @@ "type": "several_files", "width_scale": 1, "height_scale": 1, - "delta_time": 250, + "delta_time": 500, "size_width": 100, "size_height": 74, "count_files": 4 From 699b2cbec7f349ebcb879189e689e39acf6a8d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 15 May 2022 19:47:14 +0300 Subject: [PATCH 27/44] ? --- core/loader/LevelLoaderFromFile.cpp | 2 ++ .../animated/RenderableAnimatedSeveralFiles.cpp | 14 +++++++++----- game/resources/levels/level_01/config.json | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 1806a23..9471e94 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -65,6 +65,8 @@ namespace mad::core { std::make_shared( camera)};*/ + camera->set_zoom(0.2); + auto level_runner = std::make_unique( system_listener, std::make_unique(), diff --git a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp index 50fee8b..e7d2386 100644 --- a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp +++ b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp @@ -29,6 +29,8 @@ namespace mad::core { m_textures.push_back(texture); } + m_current_frame = m_textures.size(); + //std::reverse(m_textures.begin(), m_textures.end()); auto [texture_width, texture_height] = m_textures[0].getSize(); @@ -38,8 +40,8 @@ namespace mad::core { } void RenderableAnimatedSeveralFiles::render(sf::RenderWindow &window){ - if (m_clock.getElapsedTime().asMilliseconds() >= m_delta_time) { - update_frame(); + if (m_current_frame == m_textures.size()) { + m_current_frame = 0; m_clock.restart(); } @@ -61,13 +63,15 @@ namespace mad::core { render_sprite.setRotation(*m_rotation); window.draw(render_sprite); + + if (m_clock.getElapsedTime().asMilliseconds() >= m_delta_time) { + update_frame(); + m_clock.restart(); + } } void RenderableAnimatedSeveralFiles::update_frame() { m_current_frame += 1; - if (m_current_frame == m_textures.size()) { - m_current_frame = 0; - } } } diff --git a/game/resources/levels/level_01/config.json b/game/resources/levels/level_01/config.json index 31d26c9..0ca99fe 100644 --- a/game/resources/levels/level_01/config.json +++ b/game/resources/levels/level_01/config.json @@ -1,7 +1,7 @@ { "name" : "level_01", "animated_resources" : "../../game/resources/animated/", - "block" : 50.0, + "block" : 10.0, "camera": { "position" : { "x" : 10.0, From 7ba72f60b1e4cf33956ea688ebba793525d7dacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Mon, 16 May 2022 14:17:54 +0300 Subject: [PATCH 28/44] set normal jump animations --- core/CMakeLists.txt | 2 +- .../condition/EndAnimationCondition.cpp | 15 ++++++++++++ .../condition/EndAnimationCondition.hpp | 21 ++++++++++++++++ .../management/controller/JumpImpulse.cpp | 4 ++-- .../management/controller/JumpImpulse.hpp | 3 ++- core/event/management/controller/Movement.cpp | 4 ++-- core/loader/LevelLoaderFromFile.cpp | 4 ++-- core/world/entity/PhysicalEntity.cpp | 4 ++-- game/mobs/hero/Hero.cpp | 24 ++++++++++--------- game/mobs/hero/Hero.hpp | 4 ++-- game/resources/levels/level_01/config.json | 24 +++++++++---------- 11 files changed, 74 insertions(+), 35 deletions(-) create mode 100644 core/event/management/condition/EndAnimationCondition.cpp create mode 100644 core/event/management/condition/EndAnimationCondition.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 5144cc1..7f98b59 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -89,7 +89,7 @@ set( event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp - event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp) + event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/condition/EndAnimationCondition.cpp b/core/event/management/condition/EndAnimationCondition.cpp new file mode 100644 index 0000000..309397e --- /dev/null +++ b/core/event/management/condition/EndAnimationCondition.cpp @@ -0,0 +1,15 @@ +#include "EndAnimationCondition.hpp" +#include "common/Cast.hpp" +#include +mad::core::EndAnimationCondition::EndAnimationCondition(Entity::Id m_entity_id, ImageStorage::TypeAction m_type_action) : m_entity_id(m_entity_id), m_type_action(m_type_action){ +} +bool mad::core::EndAnimationCondition::is_triggered_by(const mad::core::Event &event) { + auto e = const_cast_to(event); + return m_entity_id == e.get_entity_id() && m_type_action == e.get_type_action(); +} +std::unordered_set mad::core::EndAnimationCondition::triggers() { + return {mad::core::Event::Type::EndOfRenderAction}; +} +void mad::core::EndAnimationCondition::on_start() { + +} diff --git a/core/event/management/condition/EndAnimationCondition.hpp b/core/event/management/condition/EndAnimationCondition.hpp new file mode 100644 index 0000000..cc930f5 --- /dev/null +++ b/core/event/management/condition/EndAnimationCondition.hpp @@ -0,0 +1,21 @@ +#ifndef MAD_ENDANIMATIONCONDITION_HPP +#define MAD_ENDANIMATIONCONDITION_HPP + +#include "Condition.hpp" +#include "visual/image/storage/ImageStorage.hpp" +#include "world/entity/Entity.hpp" +namespace mad::core { + struct EndAnimationCondition : Condition { + public: + explicit EndAnimationCondition(Entity::Id m_entity_id, ImageStorage::TypeAction m_type_action); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + Entity::Id m_entity_id; + ImageStorage::TypeAction m_type_action; + }; +}// namespace mad::core + +#endif//MAD_ENDANIMATIONCONDITION_HPP diff --git a/core/event/management/controller/JumpImpulse.cpp b/core/event/management/controller/JumpImpulse.cpp index 6ffc28d..8ef771f 100644 --- a/core/event/management/controller/JumpImpulse.cpp +++ b/core/event/management/controller/JumpImpulse.cpp @@ -1,6 +1,6 @@ #include "JumpImpulse.hpp" #include "world/intent/LambdaIntent.hpp" -mad::core::JumpImpulse::JumpImpulse(std::shared_ptr world, Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +mad::core::JumpImpulse::JumpImpulse(std::shared_ptr world, Entity::Id entity_id, float m_impulse) : m_world(world), m_entity_id(entity_id), m_impulse(m_impulse) { } void mad::core::JumpImpulse::control() { @@ -11,5 +11,5 @@ void mad::core::JumpImpulse::control() { }); }; - m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -2000000.0f})); + m_world->manipulate_entity_id(m_entity_id, impulse(mad::core::Vec2d{0.0f, -m_impulse})); } diff --git a/core/event/management/controller/JumpImpulse.hpp b/core/event/management/controller/JumpImpulse.hpp index 5e69a29..4d3a654 100644 --- a/core/event/management/controller/JumpImpulse.hpp +++ b/core/event/management/controller/JumpImpulse.hpp @@ -9,7 +9,7 @@ namespace mad::core { class JumpImpulse : public Controller { public: - explicit JumpImpulse(std::shared_ptr world, Entity::Id entity_id); + explicit JumpImpulse(std::shared_ptr world, Entity::Id entity_id, float m_impulse); void control() override; @@ -17,6 +17,7 @@ namespace mad::core { std::shared_ptr m_world; Entity::Id m_entity_id; std::shared_ptr key; + float m_impulse; }; diff --git a/core/event/management/controller/Movement.cpp b/core/event/management/controller/Movement.cpp index 53d6cea..ec235af 100644 --- a/core/event/management/controller/Movement.cpp +++ b/core/event/management/controller/Movement.cpp @@ -24,6 +24,6 @@ void mad::core::Movement::control() { else if(dir == Direction::Idle){ m_entity->set_action(Idle_animation); } - - + float k = 0.8; + m_world->manipulate_entity_id(m_entity_id, set_horizontal_velocity(m_entity->get_linear_velocity().get_x() * k)); } diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 9471e94..186c146 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -65,7 +65,7 @@ namespace mad::core { std::make_shared( camera)};*/ - camera->set_zoom(0.2); + camera->set_zoom(0.07); auto level_runner = std::make_unique( system_listener, @@ -143,7 +143,7 @@ namespace mad::core { {{ImageStorage::TypeAction::Idle, std::make_shared(source, block_size, block_size, - StaticImage::TransformType::Tile)}})); + StaticImage::TransformType::Fit)}})); Entity::Id square_id = world->create_physical_entity( 0, diff --git a/core/world/entity/PhysicalEntity.cpp b/core/world/entity/PhysicalEntity.cpp index 478df92..3021849 100644 --- a/core/world/entity/PhysicalEntity.cpp +++ b/core/world/entity/PhysicalEntity.cpp @@ -37,9 +37,9 @@ mad::core::PhysicalEntity::PhysicalEntity(std::int32_t id, int z_ind, Vec2d init b2FixtureDef fixtureDef; fixtureDef.shape = &dynamicBox; fixtureDef.density = 1.0f; - fixtureDef.friction = 50.0f; + fixtureDef.friction = 0.0f; fixtureDef.restitution = 0.0f; - body->SetLinearDamping(0.0000000001); + body->SetLinearDamping(0); body->SetAngularDamping(0); body->CreateFixture(&fixtureDef); diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index dc26bfb..79cdb36 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -1,4 +1,5 @@ #include "Hero.hpp" +#include "event/management/condition/EndAnimationCondition.hpp" #include "event/management/condition/KeyDownCondition.hpp" #include "event/management/condition/KeyPressedCondition.hpp" #include "event/management/condition/KeyReleasedCondition.hpp" @@ -93,7 +94,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id)); + machine->add_state(std::make_shared(world, hero_id, m_impulse)); machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); @@ -121,29 +122,30 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - float t = 2; + float t1 = 0.1; + float t2 = 0.2; - machine->add_transition(4, 8, std::make_shared(t)); - machine->add_transition(5, 8, std::make_shared(t)); - machine->add_transition(6, 8, std::make_shared(t)); + machine->add_transition(4, 8, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); + machine->add_transition(5, 8, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); + machine->add_transition(6, 8, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(7, 11, std::make_shared(t)); - machine->add_transition(8, 11, std::make_shared(t)); - machine->add_transition(9, 11, std::make_shared(t)); + machine->add_transition(7, 11, std::make_shared(t1)); + machine->add_transition(8, 11, std::make_shared(t1)); + machine->add_transition(9, 11, std::make_shared(t1)); machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(10, 0, std::make_shared(t)); - machine->add_transition(11, 0, std::make_shared(t)); - machine->add_transition(12, 0, std::make_shared(t)); + machine->add_transition(10, 0, std::make_shared(t2)); + machine->add_transition(11, 0, std::make_shared(t2)); + machine->add_transition(12, 0, std::make_shared(t2)); diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index 70c3953..6864a21 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -16,8 +16,8 @@ namespace mad::core { std::shared_ptr m_world; Entity::Id hero_id; std::shared_ptr level_dispatcher; - int last_pressed_key; - float horizontal_velocity = 81; + float horizontal_velocity = 20; + float m_impulse = 3000; }; }// namespace mad::core diff --git a/game/resources/levels/level_01/config.json b/game/resources/levels/level_01/config.json index 0ca99fe..f4ac8eb 100644 --- a/game/resources/levels/level_01/config.json +++ b/game/resources/levels/level_01/config.json @@ -24,9 +24,9 @@ "type": "several_files", "width_scale": 1, "height_scale": 1, - "delta_time": 100, - "size_width": 100, - "size_height": 74, + "delta_time": 200, + "size_width": 10, + "size_height": 7.4, "count_files": 4 }, "run" : { @@ -35,8 +35,8 @@ "width_scale": 1, "height_scale": 1, "delta_time": 100, - "size_width": 100, - "size_height": 74, + "size_width": 10, + "size_height": 7.4, "count_files": 6 }, "jump" : { @@ -44,9 +44,9 @@ "type": "several_files", "width_scale": 1, "height_scale": 1, - "delta_time": 500, - "size_width": 100, - "size_height": 74, + "delta_time": 30, + "size_width": 10, + "size_height": 7.4, "count_files": 4 }, "fly_up" : { @@ -55,8 +55,8 @@ "width_scale": 1, "height_scale": 1, "delta_time": 100, - "size_width": 100, - "size_height": 74, + "size_width": 10, + "size_height": 7.4, "count_files": 1 }, "fall" : { @@ -65,8 +65,8 @@ "width_scale": 1, "height_scale": 1, "delta_time": 100, - "size_width": 100, - "size_height": 74, + "size_width": 10, + "size_height": 7.4, "count_files": 2 } } From 9a8c21758e830279a675884a905b20413f03294c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Mon, 16 May 2022 14:48:07 +0300 Subject: [PATCH 29/44] set normal jump animations --- core/CMakeLists.txt | 2 +- .../management/condition/FallCondition.cpp | 15 ++++++++++++ .../management/condition/FallCondition.hpp | 24 +++++++++++++++++++ game/mobs/hero/Hero.cpp | 7 +++--- game/mobs/hero/Hero.hpp | 3 ++- 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 core/event/management/condition/FallCondition.cpp create mode 100644 core/event/management/condition/FallCondition.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 7f98b59..f5e6511 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -89,7 +89,7 @@ set( event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp - event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp) + event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/condition/FallCondition.cpp b/core/event/management/condition/FallCondition.cpp new file mode 100644 index 0000000..235eb11 --- /dev/null +++ b/core/event/management/condition/FallCondition.cpp @@ -0,0 +1,15 @@ +#include "FallCondition.hpp" + + + +bool mad::core::FallCondition::is_triggered_by(const mad::core::Event &event) { + return m_entity->get_linear_velocity().get_y() >= 0; +} +std::unordered_set mad::core::FallCondition::triggers() { + return {mad::core::Event::Type::WorldUpdate}; +} +void mad::core::FallCondition::on_start() { +} +mad::core::FallCondition::FallCondition(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { + m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); +} diff --git a/core/event/management/condition/FallCondition.hpp b/core/event/management/condition/FallCondition.hpp new file mode 100644 index 0000000..905fe0b --- /dev/null +++ b/core/event/management/condition/FallCondition.hpp @@ -0,0 +1,24 @@ +#ifndef MAD_FALLCONDITION_HPP +#define MAD_FALLCONDITION_HPP + +#include "Condition.hpp" +#include "visual/image/storage/ImageStorage.hpp" +#include "world/LocalWorld.hpp" +#include "world/entity/Entity.hpp" +#include "world/entity/PhysicalEntity.hpp" +namespace mad::core { + struct FallCondition : Condition { + public: + explicit FallCondition(std::shared_ptr world, Entity::Id entity_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + std::shared_ptr m_world; + Entity::Id m_entity_id; + PhysicalEntity *m_entity; + }; +}// namespace mad::core + +#endif//MAD_FALLCONDITION_HPP diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 79cdb36..7627f90 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -1,5 +1,6 @@ #include "Hero.hpp" #include "event/management/condition/EndAnimationCondition.hpp" +#include "event/management/condition/FallCondition.hpp" #include "event/management/condition/KeyDownCondition.hpp" #include "event/management/condition/KeyPressedCondition.hpp" #include "event/management/condition/KeyReleasedCondition.hpp" @@ -134,9 +135,9 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(7, 11, std::make_shared(t1)); - machine->add_transition(8, 11, std::make_shared(t1)); - machine->add_transition(9, 11, std::make_shared(t1)); + machine->add_transition(7, 11, std::make_shared(world, hero_id)); + machine->add_transition(8, 11, std::make_shared(world, hero_id)); + machine->add_transition(9, 11, std::make_shared(world, hero_id)); machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index 6864a21..ba1cc84 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -13,8 +13,9 @@ namespace mad::core { Entity::Id get_hero_id() const; private: - std::shared_ptr m_world; + std::shared_ptr m_world; Entity::Id hero_id; + std::shared_ptr m_entity; std::shared_ptr level_dispatcher; float horizontal_velocity = 20; float m_impulse = 3000; From 9ea45542f6d61e1d7225854e470e05f0eeabee7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Tue, 17 May 2022 18:39:53 +0300 Subject: [PATCH 30/44] debug --- core/event/management/controller/statemachine/StateMachine.cpp | 2 +- core/event/management/handler/CollisionHandler.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/event/management/controller/statemachine/StateMachine.cpp b/core/event/management/controller/statemachine/StateMachine.cpp index ab5f66c..96cc912 100644 --- a/core/event/management/controller/statemachine/StateMachine.cpp +++ b/core/event/management/controller/statemachine/StateMachine.cpp @@ -15,7 +15,7 @@ void mad::core::Transition::handle(const mad::core::Event &event) { m_state_machine->has_made_transition = true; m_state_machine->m_previous_state_id = m_state_machine->m_current_state_id; m_state_machine->m_current_state_id = next_state; - SPDLOG_DEBUG("current state {}", m_state_machine->m_current_state_id); + //SPDLOG_DEBUG("current state {}", m_state_machine->m_current_state_id); for (auto &i : m_state_machine->m_transitions[current_state]) { i->is_active = false; } diff --git a/core/event/management/handler/CollisionHandler.cpp b/core/event/management/handler/CollisionHandler.cpp index 1c80ba1..569f9ab 100644 --- a/core/event/management/handler/CollisionHandler.cpp +++ b/core/event/management/handler/CollisionHandler.cpp @@ -14,7 +14,7 @@ void mad::core::CollisionHandler::handle(const mad::core::Event &event) { const auto &collision = const_cast_to(event); Entity::Id id_A = collision.first_object_id; Entity::Id id_B = collision.second_object_id; -// SPDLOG_INFO("handle collision {0} {1}", id_A, id_B); + SPDLOG_INFO("handle collision {0} {1}", id_A, id_B); } std::unordered_set mad::core::CollisionHandler::handled_types() { return {Event::Type::Collision}; From 7f893c06ec57d097d476797485307c05e960a04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Tue, 17 May 2022 19:42:55 +0300 Subject: [PATCH 31/44] add sensor to physicalEntity --- core/CMakeLists.txt | 2 +- core/event/Event.hpp | 3 ++- core/event/physics/Collision.cpp | 3 ++- core/event/physics/SensorCollision.cpp | 5 +++++ core/event/physics/SensorCollision.hpp | 15 +++++++++++++++ .../entity/ContactListener/ContactListener.hpp | 11 +++++++++-- core/world/entity/PhysicalEntity.cpp | 9 +++++++++ core/world/entity/PhysicalEntity.hpp | 2 ++ game/mobs/hero/Hero.cpp | 7 +++++-- game/mobs/hero/Hero.hpp | 2 -- 10 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 core/event/physics/SensorCollision.cpp create mode 100644 core/event/physics/SensorCollision.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index f5e6511..ce65621 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -89,7 +89,7 @@ set( event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp - event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp) + event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/Event.hpp b/core/event/Event.hpp index c6d231a..ece2fec 100644 --- a/core/event/Event.hpp +++ b/core/event/Event.hpp @@ -17,7 +17,8 @@ namespace mad::core { LevelPause, Runner, WorldUpdate, - EndOfRenderAction + EndOfRenderAction, + SensorCollision }; explicit Event(Type new_type); diff --git a/core/event/physics/Collision.cpp b/core/event/physics/Collision.cpp index cc9d138..0484b0c 100644 --- a/core/event/physics/Collision.cpp +++ b/core/event/physics/Collision.cpp @@ -1,4 +1,5 @@ #include "Collision.hpp" +#include "spdlog/spdlog.h" mad::core::Collision::Collision(int new_first_object_id, int new_second_object_id) : Event(Event::Type::Collision), first_object_id(new_first_object_id), second_object_id(new_second_object_id) { - + SPDLOG_INFO("handle collision {0} {1}", first_object_id, second_object_id); } diff --git a/core/event/physics/SensorCollision.cpp b/core/event/physics/SensorCollision.cpp new file mode 100644 index 0000000..b8f0c33 --- /dev/null +++ b/core/event/physics/SensorCollision.cpp @@ -0,0 +1,5 @@ +#include "SensorCollision.hpp" +#include "spdlog/spdlog.h" +mad::core::SensorCollision::SensorCollision(int m_id) : Event(Event::Type::SensorCollision), m_id(m_id) { + SPDLOG_INFO("sensor {}", m_id); +} diff --git a/core/event/physics/SensorCollision.hpp b/core/event/physics/SensorCollision.hpp new file mode 100644 index 0000000..762bb90 --- /dev/null +++ b/core/event/physics/SensorCollision.hpp @@ -0,0 +1,15 @@ +#ifndef MAD_SENSORCOLLISION_HPP +#define MAD_SENSORCOLLISION_HPP + +#include "event/Event.hpp" +namespace mad::core { + + struct SensorCollision : public Event { + explicit SensorCollision(int m_id); + + const int m_id; + }; + +} + +#endif//MAD_SENSORCOLLISION_HPP diff --git a/core/world/entity/ContactListener/ContactListener.hpp b/core/world/entity/ContactListener/ContactListener.hpp index c4e0983..9a42504 100644 --- a/core/world/entity/ContactListener/ContactListener.hpp +++ b/core/world/entity/ContactListener/ContactListener.hpp @@ -1,15 +1,22 @@ #ifndef MAD_CONTACTLISTENER_HPP #define MAD_CONTACTLISTENER_HPP +#include "event/physics/SensorCollision.hpp" +#include "spdlog/spdlog.h" #include -#include #include #include +#include namespace mad::core{ class MyContactListener : public b2ContactListener { void BeginContact(b2Contact *contact) override { - + ///sensors + b2FixtureUserData fixture_data_A = contact->GetFixtureA()->GetUserData(); + b2FixtureUserData fixture_data_B = contact->GetFixtureB()->GetUserData(); + if(static_cast(fixture_data_A.pointer) != 0) dispatcher.dispatch(std::make_shared(fixture_data_A.pointer)); + if(static_cast(fixture_data_B.pointer) != 0) dispatcher.dispatch(std::make_shared(fixture_data_B.pointer)); + ///bodies b2BodyUserData dataA = contact->GetFixtureA()->GetBody()->GetUserData(); b2BodyUserData dataB = contact->GetFixtureB()->GetBody()->GetUserData(); //std::cout << "!!! " << dataA.pointer << "\n"; diff --git a/core/world/entity/PhysicalEntity.cpp b/core/world/entity/PhysicalEntity.cpp index 3021849..d62eb10 100644 --- a/core/world/entity/PhysicalEntity.cpp +++ b/core/world/entity/PhysicalEntity.cpp @@ -160,3 +160,12 @@ mad::core::Vec2d mad::core::PhysicalEntity::get_local_center() { mad::core::Vec2d mad::core::PhysicalEntity::get_world_center() { return {body->GetWorldCenter().x, body->GetWorldCenter().y}; } +void mad::core::PhysicalEntity::add_sensor(b2Vec2 offset, float x_size, float y_size) { + b2FixtureDef FixtureDef; + b2PolygonShape fixture; + fixture.SetAsBox(x_size, y_size, offset, 0); + FixtureDef.shape = &fixture; + FixtureDef.isSensor = true; + b2Fixture* footSensorFixture = body->CreateFixture(&FixtureDef); + footSensorFixture->GetUserData().pointer = m_id; +} diff --git a/core/world/entity/PhysicalEntity.hpp b/core/world/entity/PhysicalEntity.hpp index 6c3e0fd..14fcaff 100644 --- a/core/world/entity/PhysicalEntity.hpp +++ b/core/world/entity/PhysicalEntity.hpp @@ -79,6 +79,8 @@ namespace mad::core { void synchronize_position_with_viewable(); + void add_sensor(b2Vec2 offset, float x_size, float y_size); + private: b2Body *body; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 7627f90..6388f70 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -152,10 +152,13 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ - - machine->set_initial_state(0); controllers.push_back(machine); + + + /// add sensor + auto m_entity = cast_to_or_null(world->get_storage().get_entity(hero_id)); + m_entity->add_sensor({0, 5}, 0.3, 0.3); } mad::core::Entity::Id mad::core::Hero::get_hero_id() const { return hero_id; diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index ba1cc84..988369e 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -13,9 +13,7 @@ namespace mad::core { Entity::Id get_hero_id() const; private: - std::shared_ptr m_world; Entity::Id hero_id; - std::shared_ptr m_entity; std::shared_ptr level_dispatcher; float horizontal_velocity = 20; float m_impulse = 3000; From 6df869fcde872ee966cff60790fc4b89a1c76445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Tue, 17 May 2022 19:51:40 +0300 Subject: [PATCH 32/44] finish jump state --- core/CMakeLists.txt | 2 +- .../management/condition/SensorCondition.cpp | 14 ++++++++++++++ .../management/condition/SensorCondition.hpp | 19 +++++++++++++++++++ game/mobs/hero/Hero.cpp | 9 +++++---- 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 core/event/management/condition/SensorCondition.cpp create mode 100644 core/event/management/condition/SensorCondition.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index ce65621..55f9bb2 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -89,7 +89,7 @@ set( event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp - event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp) + event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp event/management/condition/SensorCondition.hpp event/management/condition/SensorCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/condition/SensorCondition.cpp b/core/event/management/condition/SensorCondition.cpp new file mode 100644 index 0000000..24a25b1 --- /dev/null +++ b/core/event/management/condition/SensorCondition.cpp @@ -0,0 +1,14 @@ +#include "SensorCondition.hpp" +#include "common/Cast.hpp" +#include "event/physics/SensorCollision.hpp" +mad::core::SensorCondition::SensorCondition(Entity::Id m_entity_id) : m_entity_id(m_entity_id){ +} +bool mad::core::SensorCondition::is_triggered_by(const mad::core::Event &event) { + const auto &e = const_cast_to(event); + return e.m_id == m_entity_id; +} +std::unordered_set mad::core::SensorCondition::triggers() { + return {mad::core::Event::Type::SensorCollision}; +} +void mad::core::SensorCondition::on_start() { +} diff --git a/core/event/management/condition/SensorCondition.hpp b/core/event/management/condition/SensorCondition.hpp new file mode 100644 index 0000000..31ab53a --- /dev/null +++ b/core/event/management/condition/SensorCondition.hpp @@ -0,0 +1,19 @@ +#ifndef MAD_SENSORCONDITION_HPP +#define MAD_SENSORCONDITION_HPP +#include "Condition.hpp" +#include "world/entity/Entity.hpp" +namespace mad::core { + struct SensorCondition : Condition { + public: + explicit SensorCondition(Entity::Id m_entity_id); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + Entity::Id m_entity_id; + }; +}// namespace mad::core + + +#endif//MAD_SENSORCONDITION_HPP diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 6388f70..f8515cd 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -5,6 +5,7 @@ #include "event/management/condition/KeyPressedCondition.hpp" #include "event/management/condition/KeyReleasedCondition.hpp" #include "event/management/condition/LastStateCondition.hpp" +#include "event/management/condition/SensorCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" #include "event/management/controller/Fall.hpp" @@ -144,9 +145,9 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(10, 0, std::make_shared(t2)); - machine->add_transition(11, 0, std::make_shared(t2)); - machine->add_transition(12, 0, std::make_shared(t2)); + machine->add_transition(10, 0, std::make_shared(hero_id)); + machine->add_transition(11, 0, std::make_shared(hero_id)); + machine->add_transition(12, 0, std::make_shared(hero_id)); @@ -158,7 +159,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ /// add sensor auto m_entity = cast_to_or_null(world->get_storage().get_entity(hero_id)); - m_entity->add_sensor({0, 5}, 0.3, 0.3); + m_entity->add_sensor({0, 4}, 0.3, 0.05); } mad::core::Entity::Id mad::core::Hero::get_hero_id() const { return hero_id; From dba4e722ed0bcd3ee66489d64184148ac91c5ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 22 May 2022 14:50:22 +0300 Subject: [PATCH 33/44] merge main --- game/mobs/hero/Hero.cpp | 53 +++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index f8515cd..0e4173e 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -21,55 +21,52 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ std::shared_ptr image_storage; + float physical_size_width = m_config_json["hero"]["animated"]["size_width"]; + float physical_size_height = m_config_json["hero"]["animated"]["size_height"]; + float size_scale = m_config_json["hero"]["animated"]["size_scale"]; + float delta_x = m_config_json["hero"]["animated"]["delta_x"]; + float delta_y = m_config_json["hero"]["animated"]["delta_y"]; + + image_storage = std::make_shared( std::unordered_map>( {{ImageStorage::TypeAction::Idle, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], + m_config_json["hero"]["animated"]["actions"]["idle"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["idle"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["idle"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["idle"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["idle"]["height_scale"]) - }, + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, {ImageStorage::TypeAction::Run, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["run"]["source"], + m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["run"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["run"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["run"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["run"]["height_scale"]) - }, + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, {ImageStorage::TypeAction::Jump, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["jump"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["jump"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["jump"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["jump"]["height_scale"]) - }, + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, {ImageStorage::TypeAction::Fly_up, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["fly_up"]["height_scale"]) - }, + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, {ImageStorage::TypeAction::Fall, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], - m_config_json["hero"]["animated"]["actions"]["fall"]["size_width"], - m_config_json["hero"]["animated"]["actions"]["fall"]["size_height"], - m_config_json["hero"]["animated"]["actions"]["fall"]["width_scale"], - m_config_json["hero"]["animated"]["actions"]["fall"]["height_scale"]) - }} - ) - ); + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)} + } + )); hero_id = world->create_physical_entity( 0, @@ -124,8 +121,6 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - float t1 = 0.1; - float t2 = 0.2; machine->add_transition(4, 8, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); machine->add_transition(5, 8, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); From 6fc2b695c5f4ca18d1d62778afbd5384c046f4fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 22 May 2022 15:04:47 +0300 Subject: [PATCH 34/44] add animations --- .../hero_attack_1_beg/adventurer-attack1-00.png | Bin 0 -> 1159 bytes .../hero_attack_1_beg/adventurer-attack1-01.png | Bin 0 -> 1159 bytes .../hero_attack_1_beg/adventurer-attack1-02.png | Bin 0 -> 1118 bytes .../hero_attack_1_beg/adventurer-attack1-03.png | Bin 0 -> 1118 bytes .../hero_attack_1_beg/adventurer-attack1-04.png | Bin 0 -> 1257 bytes .../hero_attack_1_end/adventurer-attack1-02.png | Bin 0 -> 1257 bytes .../hero_attack_1_end/adventurer-attack1-03.png | Bin 0 -> 1244 bytes .../hero_attack_1_end/adventurer-attack1-04.png | Bin 0 -> 1244 bytes .../hero_attack_1_end/adventurer-attack1-05.png | Bin 0 -> 1141 bytes .../hero_attack_1_end/adventurer-attack1-06.png | Bin 0 -> 1141 bytes 10 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-00.png create mode 100644 game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-01.png create mode 100644 game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-02.png create mode 100644 game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-03.png create mode 100644 game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-04.png create mode 100644 game/resources/animated/hero/hero_attack_1_end/adventurer-attack1-02.png create mode 100644 game/resources/animated/hero/hero_attack_1_end/adventurer-attack1-03.png create mode 100644 game/resources/animated/hero/hero_attack_1_end/adventurer-attack1-04.png create mode 100644 game/resources/animated/hero/hero_attack_1_end/adventurer-attack1-05.png create mode 100644 game/resources/animated/hero/hero_attack_1_end/adventurer-attack1-06.png diff --git a/game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-00.png b/game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-00.png new file mode 100644 index 0000000000000000000000000000000000000000..893cbe190193a8ad25fee0aa1683b257c7a4a37b GIT binary patch literal 1159 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 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-03.png b/game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-03.png new file mode 100644 index 0000000000000000000000000000000000000000..d5d52cf581f2cf4312c9c1f47460494ae4759845 GIT binary patch literal 1118 zcmV-k1flzhP)F?+6cm8%Hoj4mU0O&A6x|B zzVk(XJl;Sc9Hu6e#Ow28Dl>8Q<_NBH9XOw>z;&)eD>uF97E!}1c)b0125xJ8zlvV4VLo&TwY!!5DruP zN(buX_bD071j1o@r^a9^HRfXHb*4eWRoz+Hw@A>{&cvdFKbCrBRcQ#1x1afY-F#>{ zPw&*2R!XbYxvYNi9@SS;hh3oa1FWQe3l*6}?rX100FSp{uLJM|C%gO3mpF?1^$T>{cXN(v0Pl6LAhrYR{fkl%b+OOr|d5c@6@RCFt#yl3oD_gus1!K(E8z zMF!mwg3EK*tv30S`y0+SwGmvN6M3J$qe*OMLv|f8vo=42lz+W>NGTCQAf=?pWI}+H zLg2{R5bguf*u&#@N1~#6IWGDLI{Bn0!2}@c3f4FLU1uJia96A zyKT*fBl0+jmZs9Q|3$0@Hloo~P(?ve6iDqs0SGCjNVy3votB>jR8<%G;*!)*L{sG%*_$A kYE0G?7fBB3lly5b(EtDd07*qoM6N<$g0y7|Hvj+t literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-04.png b/game/resources/animated/hero/hero_attack_1_beg/adventurer-attack1-04.png new file mode 100644 index 0000000000000000000000000000000000000000..00f60010a843926ff8097d7eb6cbd75230e6711d GIT binary patch literal 1257 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 Hu0mjfyP6-N literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_1_end/adventurer-attack1-06.png b/game/resources/animated/hero/hero_attack_1_end/adventurer-attack1-06.png new file mode 100644 index 0000000000000000000000000000000000000000..7f4983a5c9833fd646786bb684b34681fdf71f74 GIT binary patch literal 1141 zcmV-*1d98KP)uT1dNt*Z9<3*E)B&EahoKcW|;o*7C?>Xo9JKyK` zmK@l{E_U%O2o*|h`eU_2dDvrDqIWwmDbytu>e@C8dKENy0~C3AyUK==(;w54JfAO%OinU6-nHfYOINQ0$YJ+5u~PBR9kJ2(tJ8Fo(M_b*6AOz!G2oiupU^Fl&8=az_LEAlV6*n)b~z=0+vOy&mY}V( z4deBT%<0`g1<$?ie?Ivd-Enx>QkHI)6M(?t5&$8)3xI!chV&;T<00qc3iA{`5&YyIl15^b+=8)ooX49|=xPvyzBnZ??%mc!BD* z+?8ctM+X4Dxq15TU!t?i#ad($fNsx8-I1ZZA@;X*$e9OsS&l{lw0qDyhPTwt{&1O3 zFVC|US>)h>5l#gkDzU3Pw5q6jpcX;z7%QuxI@!#FyPUo9t!{hDhy0%0M_WGSZ?OMXdHYu2)=VlaOaM0`^rKql#bDAZjpiTf)-A-h-V4_ z3}%)AxMxl9)SMH8z8gyHEAvRUn5Rl&Uq?qBnRbgA*dTMS`6W%hYR+@|=iimsSLTs; zKD|lSdgj6=*`Xmfj-Fls%tm!>Ol8&5`bMKSs$pe%l)+J{SdN}v;>(Y;kW+!@R(>mxONmv4l%x^~f`32KUI-y@v`9Qh$MFB6 zKjD=Ti6oPPhX3wYdOBq$k=PIjft2+JEeW$#BBhe}Qby$C*;xQFdTg9hp@7L`(nwSx z8gfENsq73%=}(l=w~kOM6fm02n@DU0Rq3vb$Y;k#=_#c#HZ{rY`g+~FiYLUzqo8^L zIE*DF_H~EWmmeMjAe+hXDp`3gvR)TLQc5AEtd$9iD3Osy`KB#HsA$x?1wbc}uRb_R zKA*?j)FfLh7P7e<$GgE7M?^MS2SNzueEzz1C*C-O-B<$l&}S&<*@6aLL{g~~Hk(aG zV=;u3PzfP#JDj`b-*TPZP((;D6^oP=HAP)HQYaK;G#ODwJA9c`rqJR#;2c(FwbIs00000NkvXX Hu0mjfyP6-N literal 0 HcmV?d00001 From c7f7f64288e3a48319c74a90a1f278b81c11936b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 22 May 2022 15:12:39 +0300 Subject: [PATCH 35/44] add animations --- .../hero_attack_2_beg/adventurer-attack2-00.png | Bin 0 -> 1096 bytes .../hero_attack_2_beg/adventurer-attack2-01.png | Bin 0 -> 1083 bytes .../hero_attack_2_beg/adventurer-attack2-02.png | Bin 0 -> 1072 bytes .../hero_attack_2_beg/adventurer-attack2-03.png | Bin 0 -> 1052 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-00.png create mode 100644 game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-01.png create mode 100644 game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-02.png create mode 100644 game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-03.png diff --git a/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-00.png b/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-00.png new file mode 100644 index 0000000000000000000000000000000000000000..38e830110fb1255d924e4efd9e05a734ac942655 GIT binary patch literal 1096 zcmV-O1h@N%P) zn4n(FfkMS8qOjdeTT|Rv39Kw=S(~JrX`1F_r%Ahfy3Z} zf_!@NC7$egLRQ8;`1&)RKY7M*m>mWA=+)!gT)HI#{k;IFt15j1enM?S0QCEh00<*M z>U59r5S^P`=H}8Z>GyRqH9H4@z1hz7Yav`S=POT@+Ya!EGNwWA)8(K-Bo@W*>jc2> z>qK2uu{Ya+a%EgI=b1Io({PZ>L4`ze313I2oQ&Lq2}Pn1DMN)KQQ~)euyB^XoY7HIgLfw0GQ?l^WDk#xlgz4kY<8}`aac<_y`IN;<9h&N9+-A_W8Q2hfaua6qO*OU zUVBZtK*D3=D0ee>Y@7L}@w3mlXujg@EEu`1;&;Z@*F}(SD(UNcA#8;F0v#*e@ z){18pTn&vfw6dVZVyP4WPOC+OxZbc=`#oXFapKY?J+|9Q7sy5-M`&e%SSm$_+pR&| zul>D#TD+|QSWG*!E7Ap$&SkfaYwZM>2Sx!{PQ-CqE!2sf0nt0zwS7`WHNI z%>HMehQIM{VQXq)Bb&uzmSVRBx~-B^7iM((8?r^|4-7pJ+pK^nf2^(wK(ZiYw^hoL zL93W{>-EkmcnPN7)jy+>SmY-W>KT+7HkO^uR&;E%%pjQ#>J*oK8J4Eo6c O0000n){PWPsHhdBp`XWAyOa!Ms_#)zy zQW0OqM6tt(Zlm3cTWU%lmK9p8+t4;CF74XfG)a>#w>dtfxuaci$~_T;d?61x-240f zK74=Ya1yAhs;a80s;a6G|CQ13cNYObc!Q==BRcc(7y*Af00DnH>6J7tuL~$8GrB6^k74$8^(ph!lvSbxv9!E^ zzpY(P&Bx63sreY;=nMd(s{(J6pM70@WY<=e?Ga@lWr*gcJ@RVgJjc$AF*P5<<#qA; z*-6Hqd5zFOGu|dYE6ei$>~=P&vR4B#d-Bv4h(rBDBu>8sKsY)>>#xIH3JE@)aI&&I zuRIM7^Uq_Su_lK z1`aCsw4BItCL<{QuHdU(TSsR*jF6JT`nm)}&%i;hU;D+X{r%c1itK;-0Bpkiot*Xc z&Iq6oFVuB%jYCq(s+sv!PBWJ8t4=I6^cWA=DsA ztmTA|5}RQlibX3en6d=2p3loSM{sLwRhM=KjH%0&e002ovPDHLkV1mYE B3-ka0 literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-02.png b/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-02.png new file mode 100644 index 0000000000000000000000000000000000000000..18e53fceed59efac5db1c34812d2d44b61b482c8 GIT binary patch literal 1072 zcmV-01kd}4P)N;P#Nia_@M4;nI;1hsY8|6Z+KK5`PMe%0H6O1RP0pG%bu;G_6!L>Wc+YwB{Gapu z-*es*XwaZRg9Z&6AdXt#tt(e}X5_pa^j|<#6T;={X6S^~bREU?UwnwQl_mMz)FhGU z3@%rGcr)m?XjATW3mhsVMETojjQiHO;PWlS}4 z?fM#j?9Af#^#b7c^^)33;qW*BxW1f*Mf%26&xN1uV1@E=-g{~I(%$x z#sO%xJI#=-!myEwiO!BE_s`fA#!+@TmU zvUu?_0B48CS^H>gFNyuf1LrA}ngE#C+~%j_ec~w600U3h#fz6wcQss1t@7);bGnIn zdkTQ|78?Mel8=GidjL2KR`K>XA)__dr0zr#85LJktBh_e>tn0Qr2c(7n`b+lubQ)C zHGhv)p)MoSqobtrIiefOtR|Cq-R>$A?JYJvky9uAtb0eysrDbJI}t6PtGQolZ?Wk~ zSWk}wu(qD4SLU&)_x4+5VqY4fax7Hx(N#9k)!7ZJ_v(~-JnCBP)1#vj_6*o87LhL& zE5^iBr$-7Y(Nd{uAtC5$wuqF?PWanf#;UGC-L18o&kJXBv&a{VP`)5jogSG@rO2ey z2yyTlrEGRtDik>V!t-?(d>E!|7fy|wL9tjUJxHb|_O>>1nT)PG_rs57$O9(sejjDx zA!JVzygLyvOWwGV!NBl=v2t69%0~!spw*shSEMMFOfzH1$j7ga@nVl1A%v_Ht0)ST zi~l7wtD903MPxNipKC1?kcuLa=DhV9+x<#OU)wR+cl;QtssgZ>k>dBP(EC3U+@;}%AmcIdJvXopiJyhxd0000%RaRLgkl1L4!=sA;GRH7eTpb4+a@xHk|BwojNL~1668dG3G+Y{d zPJ<=U@aQ5-k$;HC*N7*iDMPNEmFdF;+&(iU1JU%&cR{UL5KPHIzyt#ZAUiOd0z^{^ zD6hHv8BmD8CX6QpL|KaYi zEsc#}NWG%^@wi=j8#M`~sD9d;+OoN{l_|?0ONkg5HX!H_THw0=Xg{pCYk%zLUO>T5 z`~EggemF+=SD$mrIZp5F5%~2BJMm_ftv7prXD6{lg8Arw>)HshyZ1a^Wf1Q#=k>m) z{=7=J10#xdxxjQTD*a`-|qoz)n0TQY|!Jkb^M+f8sg&v2f&aSEh_+v zDTw*7s`mx%TBU_X2qnkOeRdI!-U+~`7i+lZ?j7>sj$;CPjIL}S0D09~DHsW`=cS|# z=b=mT>_=}hA6AJ6FXM4I+0}iTmA*3ow1lfn&;U>NUDDf+-CrTHWdn+w5lwGQOaO?v zkuI*?Xk|J0v+g(^yv)|-M+G+n^7`5L*wvkU*#-K}Br^kqY8_%VpyE{q<$ll8c$Gn; zc}ozaC840|cl5&7wAKyC3$vdPljAr;Z!zHQ5PQO7a_QzR)7Z(atvu89A^=rmBSLjL zX?ESG2VEl`(PGKDH?-J|6>#1lS(bs=Hg|--hN^Xt`syu=thsqGK1F@?7OI{&E-GAY z_DbUgn#wrbLoDqE+> Date: Sun, 22 May 2022 15:19:12 +0300 Subject: [PATCH 36/44] add animations --- .../adventurer-attack2-000.png | Bin 0 -> 1096 bytes .../adventurer-attack2-02.png | Bin 1072 -> 1083 bytes .../adventurer-attack2-03.png | Bin 1052 -> 1072 bytes .../adventurer-attack2-04.png | Bin 0 -> 1072 bytes .../adventurer-attack2-05.png | Bin 0 -> 1052 bytes .../adventurer-attack2-03.png | Bin 0 -> 1052 bytes .../adventurer-attack2-04.png | Bin 0 -> 1173 bytes .../adventurer-attack2-05.png | Bin 0 -> 1173 bytes .../adventurer-attack2-06.png | Bin 0 -> 1202 bytes .../adventurer-attack2-07.png | Bin 0 -> 1202 bytes .../adventurer-attack3-00.png | Bin 0 -> 1107 bytes .../adventurer-attack3-01.png | Bin 0 -> 1107 bytes .../adventurer-attack3-02.png | Bin 0 -> 1044 bytes .../adventurer-attack3-03.png | Bin 0 -> 1044 bytes .../adventurer-attack3-04.png | Bin 0 -> 1083 bytes .../adventurer-attack3-02.png | Bin 0 -> 1083 bytes .../adventurer-attack3-03.png | Bin 0 -> 1077 bytes .../adventurer-attack3-04.png | Bin 0 -> 1077 bytes .../adventurer-attack3-05.png | Bin 0 -> 1092 bytes .../adventurer-attack3-06.png | Bin 0 -> 1092 bytes .../adventurer-attack3-07.png | Bin 0 -> 1065 bytes .../adventurer-attack3-08.png | Bin 0 -> 1065 bytes 22 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-000.png create mode 100644 game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-04.png create mode 100644 game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-05.png create mode 100644 game/resources/animated/hero/hero_attack_2_end/adventurer-attack2-03.png create mode 100644 game/resources/animated/hero/hero_attack_2_end/adventurer-attack2-04.png create mode 100644 game/resources/animated/hero/hero_attack_2_end/adventurer-attack2-05.png create mode 100644 game/resources/animated/hero/hero_attack_2_end/adventurer-attack2-06.png create mode 100644 game/resources/animated/hero/hero_attack_2_end/adventurer-attack2-07.png create mode 100644 game/resources/animated/hero/hero_attack_3_beg/adventurer-attack3-00.png create mode 100644 game/resources/animated/hero/hero_attack_3_beg/adventurer-attack3-01.png create mode 100644 game/resources/animated/hero/hero_attack_3_beg/adventurer-attack3-02.png create mode 100644 game/resources/animated/hero/hero_attack_3_beg/adventurer-attack3-03.png create mode 100644 game/resources/animated/hero/hero_attack_3_beg/adventurer-attack3-04.png create mode 100644 game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-02.png create mode 100644 game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-03.png create mode 100644 game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-04.png create mode 100644 game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-05.png create mode 100644 game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-06.png create mode 100644 game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-07.png create mode 100644 game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-08.png diff --git a/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-000.png b/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-000.png new file mode 100644 index 0000000000000000000000000000000000000000..38e830110fb1255d924e4efd9e05a734ac942655 GIT binary patch literal 1096 zcmV-O1h@N%P) zn4n(FfkMS8qOjdeTT|Rv39Kw=S(~JrX`1F_r%Ahfy3Z} zf_!@NC7$egLRQ8;`1&)RKY7M*m>mWA=+)!gT)HI#{k;IFt15j1enM?S0QCEh00<*M z>U59r5S^P`=H}8Z>GyRqH9H4@z1hz7Yav`S=POT@+Ya!EGNwWA)8(K-Bo@W*>jc2> z>qK2uu{Ya+a%EgI=b1Io({PZ>L4`ze313I2oQ&Lq2}Pn1DMN)KQQ~)euyB^XoY7HIgLfw0GQ?l^WDk#xlgz4kY<8}`aac<_y`IN;<9h&N9+-A_W8Q2hfaua6qO*OU zUVBZtK*D3=D0ee>Y@7L}@w3mlXujg@EEu`1;&;Z@*F}(SD(UNcA#8;F0v#*e@ z){18pTn&vfw6dVZVyP4WPOC+OxZbc=`#oXFapKY?J+|9Q7sy5-M`&e%SSm$_+pR&| zul>D#TD+|QSWG*!E7Ap$&SkfaYwZM>2Sx!{PQ-CqE!2sf0nt0zwS7`WHNI z%>HMehQIM{VQXq)Bb&uzmSVRBx~-B^7iM((8?r^|4-7pJ+pK^nf2^(wK(ZiYw^hoL zL93W{>-EkmcnPN7)jy+>SmY-W>KT+7HkO^uR&;E%%pjQ#>J*oK8J4Eo6c O0000n){PWPsHhdBp`XWAyOa!Ms_#)zyQW0OqM6tt(Zlm3cTWU%lmK9p8+t4;CF74Xf zG)a>#w>dtfxuaci$~_T;d?61x-240fK74=Ya1yAhs;a80s(-4g5dW3Y@OKvhWH2y@ zt|vreV+(yx*p$^*S7`_R@Odu)cl1Yyj$M|;)r-I<1OtOo*Ars$rlAa`Vjy3<`7%D^ zNeSSqhrm;@pclIE@Bufm-OQ?32w$CSZT z1mx_(sHe>>@w zG%l|TC?zwxD&UV{_I33s^VO79q6D$Dynw&0T~5u%%=M}H7~$v)0Hdn{ZXU+Ph!MtC90`_@8I- z>mjmTFVGntBc4nGaO=Qf022fd@0@wts=X;Ci9G7^NPt8ALo9x9)Lfqp9ih$R0ZIVn zk%}$cQh$D=7cD$CP_2y=#?q;%*YL!x*LQPFXYzdIk#j5@N+A50dfBFDy!u*|__4VY})&OXAAbQ;zAC81ov|xR-f}#Eg z);5z6<&O~JfpmJ^niRz%r;mlKwg6ZJ`S_Ki9By?YgplQCHBE!f=5LHom{6LgiCi{o zzH2iKq^3#aLxcQBvbIO0q@%u8c068-u7B$Q%&tlCTTYns9}PzUGda;@lY|+G@mHCLk*x htKY5k|E>SM{sLwRhM=KjH%0&e002ovPDHLkV1iuj48Q;Y delta 1052 zcmV+%1mpX=2(So{BYy+;NklN;P#Nia_@M4;nI;1hsY8|6Z+KK5`PMe%0 zH6O1RP0pG%bu;G_6!L>Wc+YwB{Gapu-*es*XwaZRg9Z&6Ab*Zp;H@iHcxL3h9Q0p6 zRTIMH>SpMK)pQ-j^k004wUs6L-P9zJ=nO7bw^Y>xckUKU*D?Rn0H3~jiD&ztlKaP^ zKqNZDp#Os82s**^MAk!>(9#;8e|eL5Y>9YmiTSxG{y)R}Pm_nuuNTu3xtAVe>Ha6u z@9QNPSs*ZY5`Txs!TeklmuHEH*@9(EHFE9x8h`A};`j9e;P>^C+DhT@H~_f5oQCB| z2KtB0lm$#|t=nN0SxS&q&d6wdMIVpGR|rNHnAs6{I(!WD520mt{+ny$c35S7^FBUr zuUwAbWa8>AqVW|R9tW>qyF=*QYj`?*Y;DE?Xtg`dkbkYhu#t+1&WXA)__d zr0zr#85LJktBh_e>tn0Qr2c(7n`b+lubQ)CHGhv)p)MoSqobtrIiefOtR|Cq-R>$A z?JYJvky9uAtb0eysrDbJI}t6PtGQolZ?Wk~SbtBC1F*K9s8{B(srU9X`k7mdNChmS8W#S=ZPZPX55im>MxRJrY@PV;%TZzg? z2yvj*o@-a6D3wezW5~$Iua5Czj~yX|tQ4y#3Y3fgB{Zv>QWQmGHBFyuEfkQ7B9Z32 z^%~p#N=aYaG1+(g7^fK$p?TEpA!M3`j6P$Icp z4k0C~s_F$jZLhtEBf&6{V3>eYlE`F*kP>U5fGCxWl%QkC$ZjqtliS-^EEXX_Amt

l7sb diff --git a/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-03.png b/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-03.png index 5e807d541e54607a38c45a33ad8a202e3f084019..18e53fceed59efac5db1c34812d2d44b61b482c8 100644 GIT binary patch delta 1051 zcmV+$1mydi2(So{B!BlwL_t(oh3%MKXj^3*#((cgvbJfHCMo>@)7Xnm%c@x?l-0(0 zv2IY%n-*m3%8Q{Ff(Y(P)C;HA-gsGWrGcr)m?XjATW3mhkwVx{9F{5XNic}f@MrKa_#yWf9%ZS_w@qc_w|z6O5yN00Jy%KhUG~H z`iIPv1x#$M+hG-1N|05~$Y^{;ACJaY2u2o|*%5d;d<^stp=Eadn``8DSY>_lK0a@+ zT#nyl;_5A;@f92%2d`hdL+IRVcshJ+ZN>p;wL8s_t$)I>k&21Vjwj^z;V(ElJkHN= zoC6>jS)k{)Nrqy-vb7mMvNXViHB!rj*X@RlBmnP!wor9`tKG?aSKl!zdjP|UR7~{w zUec3T?Z~0M{0d&To2||GgO>Vg+Nj*27&5YW@iG8shsRm_XlyTu{l^36DU_N3nAqIr zr{jI%D1Xub15en+iQv_8+J_5iOsqxnF8;vFS-zPk)aCu(qD4SLU&)_x4+5VqY4fax7Hx z(N#9k)!7ZJ_v(~-JnCBP)1#vj_6*o87LhL&E5^iBr$-7Y(Nd{uAtC5$wuqF?PWanf z#;UGC-L18o&kJXBv&a{VP`)5jogSG@rO2ey2yyTlrEGRtDik>V!t-?(d>E!|7fy|w zL4UDWC_PA~Cib>Aa+!>-JNLtnX2=63?tUL-;vr;D6TCYSFiYOJk-@<5fw6L1iONR^ zaiGIFS*uf2#P!7!0vn1EA~$Yh0(5^JG=D3y$qpkv6$ZZ0R2+uK+y79l|(oE zqMZBTC)8;l>a>r^D+;xaItj?oTyWiZi&-&E%!YvYuFpu1+r@9*YXCT!986wOP^W#w zV$odXiX~ZITK%1!(zAVc#(P(9sAAs^w<(~hrCAZZwSNjg#JvpwkK09LK7ymkk?c3L zjY@m3SdwLs`pO!ig#KPPdx3=o0O?;2>wPVajbKQnUf$8nZ?fC9HCrvhcho{6^yn(mh z?*VMpUUVF6(Brpt{GJ#Z;^PAcz>pa&D*%fri21Op_XX}+rG-WaCCANub`g%=3Bacp zYq;m`9rEFhV*+}Nu52FwdDU7e7zwcFrKAn#p?^#A>_=}hA6AJ6FXM4I+0}iTmA*3o zw1lfn&;U>NUDDf+-CrTHWdn+w5lwGQOaO?vkuI*?Xk|J0v+g(^yv)|-M+G+n^7`5L z*wvkU*#-K}Br^kqY8_%VpyE{q<$ll8c$Gn;c}ozaC840|cl5&7wAKyC3$vdPljAr; zZ+|i1?GSsyV{+-{Ez{V^t*t!M^&$XOVY%<#XwNtu7~%pMQct4Br7VONm{u>_X_BR%L|H8pVdm2Lkdd z8ttrO%X00k%o_siAHNybzA*r+8L~M6Ie!Ng{lltQ88Rp*1lR{L?Wv&;o|RGv4)+Y$ zG-J09t AZ2$lO diff --git a/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-04.png b/game/resources/animated/hero/hero_attack_2_beg/adventurer-attack2-04.png new file mode 100644 index 0000000000000000000000000000000000000000..18e53fceed59efac5db1c34812d2d44b61b482c8 GIT binary patch literal 1072 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 Q;s5{u07*qoM6N<$g1dA#-~a#s literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_2_end/adventurer-attack2-07.png b/game/resources/animated/hero/hero_attack_2_end/adventurer-attack2-07.png new file mode 100644 index 0000000000000000000000000000000000000000..95b51a45b8c2cdfec45f7e65c084b5c416b94102 GIT binary patch literal 1202 zcmV;j1Wo&iP)sUuOw{{)l&(`7ir!36*U{n@)5CxJ&O-KwO5HvCIPmCrSUr2}%10nGN zAMnA5Ch|l!!UzT=1|lwMW=!Q6&u>?djNz2}~L z&iDH}zjM#Ig%Tx7lqgZ6M2Qk5{x7J9(aG2EZD!SD%Vl<1GM-S@>M8)9es`zgKFo$& zcmR@#BnOWkr=xu(0P%@9txvWIKrnE#D8V!pqmlbDa{Y$1Ih*JmyZ}J8y_(_kZakwS zOim`{K94^T55-8Evq?Y3C*pef>~o_OJ+&@vdV|r}O`_A20^kdWaeKVF8Mns^o}4MS z$4iHOWl{Pqijn%hTWAT45lf|r&Q*B*0Xkb1 zTb&B4eIZ+&ii@gN{dB6=uo2^PBqh`~%$LC*e*j?k_W}LZSYRAqU5ZAVjpm?6b5JAj zML&V7X9-+AOFA*3-d?lBummW=Ix=uME8p(@2!Qt|;(UMkJijhojJ?hYz|v68SYyb7 zFC4z3{}0ZcGb#c22Xo|1U!>qVY>m`a3YJtZY~hyy)g}tH=svte#5hD+4u?oht{supYesm zbUSQJjg258C{-9}pVca0(c3DPi2@^2DeaCuPt(FVx*0&WY@B!36v(GjSG}EdGKo?O zr4*W$8x9e{WHOPA$FWvd1IVea;w*%D^mXKx$ovn0R9aJ&7SkQ&cca^3LzF^95D_#@ z%a4dsw@;W%B+$yr7>UL(B?9VTcTZ7vzlIyx``QKoiH5@*4JkdPL_`-4xj#!3}bt(&$q27lgVH%FQ>+4LxN!dl{Yik+o#uU?|24sfs=KX1e!8Y zt3N7uI)>)RXd($f&73)Wc5L82wF{YRE>ok4q%>Dqg@^Pf$bW)A0Z%X1fT>ed Q;s5{u07*qoM6N<$g1dA#-~a#s literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_3_beg/adventurer-attack3-00.png b/game/resources/animated/hero/hero_attack_3_beg/adventurer-attack3-00.png new file mode 100644 index 0000000000000000000000000000000000000000..99b6794bfb6bb3bb41d79dc9b09ef1c3eac45379 GIT binary patch literal 1107 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 O0000sy$P35}Z z_DVb9vtji**3_x`uoVhKW3n1Yfzkp&B2-R5{O|Tr(bXvf{N%eucdztB4`VJ1-Wm@8 zBjXbQXe)Hbq1RO(Z}!fr&uXExRU*l-%Nj(12(@=G{PBlevf*O&-qhR-H~#!RK}llF zWx-cpOWot$-2ckUys_~#_f9vk?UbMAKl&!A4-Hg8g^WNJvQ`E3*J+nqvJ|2$7V^F+!VYn9Q> zKSO1(nl)_P=pxhIL}$9y;8Q>LGF1-OFS-ay64y!+3x5T1FWCvTcMv@KEN(;plQZ z9rXjS|KKsT?KM|ebzTg)6IMfGMG`=?J--l+vlx!6tHx)8$8~MJ#YX_>`(#0wp8Z>a z(Is_@BFDrk>Y~5mC@!FA+aAH{sYRMRgIIm3T<_h^@JK%o-hP{qr1z69=SBz}h+*ic z0SuEX;koj;TLIYJ_AQ6EZl$=O0B2d5tjq^RUtE4A!NpnK^AEIjsCi0+1|?=v^XVV} zK{eF-!5_FPtx1EVfKd%;^`ieC*%FVlKMp}j!YzvG_kpD_rS{d`{Goks3n$*$r{>#r z=S%7QrvgwtXg4A`O=BP}kWPm>cc0I4zORtiHtZsY17T%_huhvV6)zJ+b5n)BM+XK& zY0Ij}EKoMe(5VSKyK(t74i!_AEf-*!MgtjM@l!6pCJ#vKEz{={Q#*UA6>S}q;K%IY zDyvtNr&_O*WkDbkj|(=dl>_g6nYR7jo9ZaBUc}OJT)wQV6hL_T{jamJpen1E#<6pM zG9ErhbUB_80^rq811v4aaTFE^p;+vK9P0je`UgDuc(sBxN2dS)002ovPDHLkV1ngm B{(}Gj literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-02.png b/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-02.png new file mode 100644 index 0000000000000000000000000000000000000000..40901e1942d5dbf03a82209d18ca82e6d1a0ee76 GIT binary patch literal 1083 zcmV-B1jPG^P)sy$P35}Z z_DVb9vtji**3_x`uoVhKW3n1Yfzkp&B2-R5{O|Tr(bXvf{N%eucdztB4`VJ1-Wm@8 zBjXbQXe)Hbq1RO(Z}!fr&uXExRU*l-%Nj(12(@=G{PBlevf*O&-qhR-H~#!RK}llF zWx-cpOWot$-2ckUys_~#_f9vk?UbMAKl&!A4-Hg8g^WNJvQ`E3*J+nqvJ|2$7V^F+!VYn9Q> zKSO1(nl)_P=pxhIL}$9y;8Q>LGF1-OFS-ay64y!+3x5T1FWCvTcMv@KEN(;plQZ z9rXjS|KKsT?KM|ebzTg)6IMfGMG`=?J--l+vlx!6tHx)8$8~MJ#YX_>`(#0wp8Z>a z(Is_@BFDrk>Y~5mC@!FA+aAH{sYRMRgIIm3T<_h^@JK%o-hP{qr1z69=SBz}h+*ic z0SuEX;koj;TLIYJ_AQ6EZl$=O0B2d5tjq^RUtE4A!NpnK^AEIjsCi0+1|?=v^XVV} zK{eF-!5_FPtx1EVfKd%;^`ieC*%FVlKMp}j!YzvG_kpD_rS{d`{Goks3n$*$r{>#r z=S%7QrvgwtXg4A`O=BP}kWPm>cc0I4zORtiHtZsY17T%_huhvV6)zJ+b5n)BM+XK& zY0Ij}EKoMe(5VSKyK(t74i!_AEf-*!MgtjM@l!6pCJ#vKEz{={Q#*UA6>S}q;K%IY zDyvtNr&_O*WkDbkj|(=dl>_g6nYR7jo9ZaBUc}OJT)wQV6hL_T{jamJpen1E#<6pM zG9ErhbUB_80^rq811v4aaTFE^p;+vK9P0je`UgDuc(sBxN2dS)002ovPDHLkV1ngm B{(}Gj literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-03.png b/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-03.png new file mode 100644 index 0000000000000000000000000000000000000000..22462fabeabb1255ecf93df51e73741fd7ce5fde GIT binary patch literal 1077 zcmV-51j_q~P)Z z#+ayRbbcX>2s3exZMqN6F(R4ND%;33C?ThX9Dhrp4>Qn0#CMv1hpe*mSLf+-vE0 z{eA$RC@6+KdH^iW4I(YWj{T7Xw@=92h0k65?Dd)U77C4@@O8r|YqnN0bg`LQXE{G! z?j+Y{qdCipJf*6ocqJ8xqRxx|lIcgbT6`G&za%o>MN-n*+p zfI1-w8TtI%lWg6*BjLH;KNzK_?^x0ttNt?nfi7gI8~0z6RO<_**Y79SW>a>4V%^Ps z>Pp+lOWx01MQ}%<)PR)IS(i<}4sY z0tq$HwqZ+BFmGTaA?}MW9a7@#e`b%Wj4UPu77>%0Dnu-nXfk|SE$0{VVWR;l@n?OiJP+l~43wLz3ecrs5eC zLZH*>5JDh?U@{cqhF%XKGp2lECXVV}vh2q%OCL9d4?e0uN{LPv-ywV09XwM@p0?# v%bF92M7bkHFM2~^nV(^jtkS>K{|)~EPnn19h4=`}00000NkvXXu0mjf)Gh^y literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-04.png b/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-04.png new file mode 100644 index 0000000000000000000000000000000000000000..22462fabeabb1255ecf93df51e73741fd7ce5fde GIT binary patch literal 1077 zcmV-51j_q~P)Z z#+ayRbbcX>2s3exZMqN6F(R4ND%;33C?ThX9Dhrp4>Qn0#CMv1hpe*mSLf+-vE0 z{eA$RC@6+KdH^iW4I(YWj{T7Xw@=92h0k65?Dd)U77C4@@O8r|YqnN0bg`LQXE{G! z?j+Y{qdCipJf*6ocqJ8xqRxx|lIcgbT6`G&za%o>MN-n*+p zfI1-w8TtI%lWg6*BjLH;KNzK_?^x0ttNt?nfi7gI8~0z6RO<_**Y79SW>a>4V%^Ps z>Pp+lOWx01MQ}%<)PR)IS(i<}4sY z0tq$HwqZ+BFmGTaA?}MW9a7@#e`b%Wj4UPu77>%0Dnu-nXfk|SE$0{VVWR;l@n?OiJP+l~43wLz3ecrs5eC zLZH*>5JDh?U@{cqhF%XKGp2lECXVV}vh2q%OCL9d4?e0uN{LPv-ywV09XwM@p0?# v%bF92M7bkHFM2~^nV(^jtkS>K{|)~EPnn19h4=`}00000NkvXXu0mjf)Gh^y literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-05.png b/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-05.png new file mode 100644 index 0000000000000000000000000000000000000000..ceedfdf3c36ed2ea58920000662bc6ace7fa3363 GIT binary patch literal 1092 zcmV-K1iSl*P) z?#vWTymA?4OBT0;Xk^J0WN~wVVcCp2DFaqM3iON5_IOcR=wQn){J~pTf6dSBEWz%7XX*Dgn%!A)ozXTuV`z}AD zF*n?GN&Vy9r*Sz;0O<1!f+r@b&ohYIUbeBw@4yhAiIQzr?kT-$We4=`0pRN&N|VOy z+bdwqi(^v(03%~w9vP3)#~|*iGLC-u3r$~s&Z`ey;l%BI(9xP6A=zd{4i3))@VDoD z%7!j;>^nDl8OLJ>lg4}#9()rX?D@{5{?49j)Lw6;-7SE}Y2OMbBDI3=E^872AlfhZ zk}?t(6{n;yb4|nPrHuUX*>Yd8%?7|ZhePZi8Ifo5RqXjrp8oweZcR=C@a(o7(2xN@ zZow9jm1D>L)KTq1E_P2b9f+V>Gw%F*B^`_2=0+J0CLXZq&?K{MwpD8a^k)ZTQPVMo zzIqqcY@~R?ln@gqwEqQW=4ORC%f#F7zokt`ys=dDcdZp~b7M;D09?-r5{XI)P}CH= z?1HC0pm@RrzzugDBV%3w9GeQLta(lxs4L%)fK>skIKBS0@V(8A6ttXPb&1vN%1gA5 zA9Bm-nT4eB{;aLkA3g#=$EjF>ztPf`7=L1$LDR*UWSpv)wbqFXdGElJsAgkAh-x;{ z6?IZR_a~~^h-vphVJInMa(D<^VUetI?WL#hdtPpANS_c$60?$Zh1KlJ6FVE~aWIF` zQn=>)TmI1`zc0P=W@292g>01S`dXqwfTBnx5@9A3LdMDjDJ4P(q?A~!v71~9As$w9 z6GBe5ow@%)K6!B;fB9#*63UQKMPb(OUv?mtUBrc%R2318Qjs|)TEG1<9U*9cYaKuG z3{pzA72uYeYQ`77Bo#(3whQo-Z8d7bx zc)(&wfDl5^)7edL*CiB1q0}rzy(vgkQ5f_G(jXy*ri=(FnO|I#KEEF!B|=Je=Nm=W z!~#8?-K*wb{pn|_>nrgDB5cmFP-@B6;ywvY84*&-n3#wFgaq-RSfID-(p_!B3yTTS z^N~o}4jWAw83={|P%|_6=-jU<*$5!pkRb+wA-OrnlC~Q8-|!E&Bz{)u#4m9G0000< KMNUMnLSTYE_WyVQ literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-06.png b/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-06.png new file mode 100644 index 0000000000000000000000000000000000000000..ceedfdf3c36ed2ea58920000662bc6ace7fa3363 GIT binary patch literal 1092 zcmV-K1iSl*P) z?#vWTymA?4OBT0;Xk^J0WN~wVVcCp2DFaqM3iON5_IOcR=wQn){J~pTf6dSBEWz%7XX*Dgn%!A)ozXTuV`z}AD zF*n?GN&Vy9r*Sz;0O<1!f+r@b&ohYIUbeBw@4yhAiIQzr?kT-$We4=`0pRN&N|VOy z+bdwqi(^v(03%~w9vP3)#~|*iGLC-u3r$~s&Z`ey;l%BI(9xP6A=zd{4i3))@VDoD z%7!j;>^nDl8OLJ>lg4}#9()rX?D@{5{?49j)Lw6;-7SE}Y2OMbBDI3=E^872AlfhZ zk}?t(6{n;yb4|nPrHuUX*>Yd8%?7|ZhePZi8Ifo5RqXjrp8oweZcR=C@a(o7(2xN@ zZow9jm1D>L)KTq1E_P2b9f+V>Gw%F*B^`_2=0+J0CLXZq&?K{MwpD8a^k)ZTQPVMo zzIqqcY@~R?ln@gqwEqQW=4ORC%f#F7zokt`ys=dDcdZp~b7M;D09?-r5{XI)P}CH= z?1HC0pm@RrzzugDBV%3w9GeQLta(lxs4L%)fK>skIKBS0@V(8A6ttXPb&1vN%1gA5 zA9Bm-nT4eB{;aLkA3g#=$EjF>ztPf`7=L1$LDR*UWSpv)wbqFXdGElJsAgkAh-x;{ z6?IZR_a~~^h-vphVJInMa(D<^VUetI?WL#hdtPpANS_c$60?$Zh1KlJ6FVE~aWIF` zQn=>)TmI1`zc0P=W@292g>01S`dXqwfTBnx5@9A3LdMDjDJ4P(q?A~!v71~9As$w9 z6GBe5ow@%)K6!B;fB9#*63UQKMPb(OUv?mtUBrc%R2318Qjs|)TEG1<9U*9cYaKuG z3{pzA72uYeYQ`77Bo#(3whQo-Z8d7bx zc)(&wfDl5^)7edL*CiB1q0}rzy(vgkQ5f_G(jXy*ri=(FnO|I#KEEF!B|=Je=Nm=W z!~#8?-K*wb{pn|_>nrgDB5cmFP-@B6;ywvY84*&-n3#wFgaq-RSfID-(p_!B3yTTS z^N~o}4jWAw83={|P%|_6=-jU<*$5!pkRb+wA-OrnlC~Q8-|!E&Bz{)u#4m9G0000< KMNUMnLSTYE_WyVQ literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-07.png b/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-07.png new file mode 100644 index 0000000000000000000000000000000000000000..1156b4ebb79073695165aae069d080cb8d1683d0 GIT binary patch literal 1065 zcmV+^1lIeBP)ee=!?NDi1yA45VvB)~><`*&%@n#lbeljmaFBGRtD#IHG z>cy}M-i;0vh7O8?$h5UZ=h8@vleyWX>&Mz8%Xhz$<3*aRukBoyH#m^|;N={ibDr}& z|8w5+0R;*aC{Un4fdT~z6ew_OkpCjcr-z(<7{d zSTx3oQ>SU$(Fi~!5TR*jvjUi%xssR3)bcUNjkt7qLN&YU=y#6-P+nEe$T<(*u}j3` zF?9p?bzwO(c=e{8!u~T%&RN$?VCv!pIsEz|gRR+Bmn|cK2<27f0EW6*Eb&B&QeC^L zS*dWgqlR|_(C2P9w7n9DD0%y+!R8tKA}hw@^?^4n%H#FXR@G=G|16eLT~oe^1pxl? zo?f?Ovz{&key_p)q01d zpluGBRltM&MN?|Wg-{eX}Zg*5>T5*YDxSTZzWw$nq)XsI1H+EXx8!L~!>HGCVMZrfF=|m2}#oq%;j* zIFbhmX-ut%D8<6kk_v>wh*F4B-0QT;fPWEp|KO_r=YIT&*3K5ZktAEn>}<7{nh9^f z)QX5wDlH}{fGCiSvdHkj&~<&{i%VJ23&~{O4jWS|G8T;i;3zKU{jYyrmyZCYmLeI8 j#?+QFd*1fQ|AxN-1T25EEA3Vz00000NkvXXu0mjfgw_&C literal 0 HcmV?d00001 diff --git a/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-08.png b/game/resources/animated/hero/hero_attack_3_end/adventurer-attack3-08.png new file mode 100644 index 0000000000000000000000000000000000000000..1156b4ebb79073695165aae069d080cb8d1683d0 GIT binary patch literal 1065 zcmV+^1lIeBP)ee=!?NDi1yA45VvB)~><`*&%@n#lbeljmaFBGRtD#IHG z>cy}M-i;0vh7O8?$h5UZ=h8@vleyWX>&Mz8%Xhz$<3*aRukBoyH#m^|;N={ibDr}& z|8w5+0R;*aC{Un4fdT~z6ew_OkpCjcr-z(<7{d zSTx3oQ>SU$(Fi~!5TR*jvjUi%xssR3)bcUNjkt7qLN&YU=y#6-P+nEe$T<(*u}j3` zF?9p?bzwO(c=e{8!u~T%&RN$?VCv!pIsEz|gRR+Bmn|cK2<27f0EW6*Eb&B&QeC^L zS*dWgqlR|_(C2P9w7n9DD0%y+!R8tKA}hw@^?^4n%H#FXR@G=G|16eLT~oe^1pxl? zo?f?Ovz{&key_p)q01d zpluGBRltM&MN?|Wg-{eX}Zg*5>T5*YDxSTZzWw$nq)XsI1H+EXx8!L~!>HGCVMZrfF=|m2}#oq%;j* zIFbhmX-ut%D8<6kk_v>wh*F4B-0QT;fPWEp|KO_r=YIT&*3K5ZktAEn>}<7{nh9^f z)QX5wDlH}{fGCiSvdHkj&~<&{i%VJ23&~{O4jWS|G8T;i;3zKU{jYyrmyZCYmLeI8 j#?+QFd*1fQ|AxN-1T25EEA3Vz00000NkvXXu0mjfgw_&C literal 0 HcmV?d00001 From 34b75070aeb64c78fad79268c461ae4eeb2bb24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Mon, 23 May 2022 00:43:20 +0300 Subject: [PATCH 37/44] find bug in anim --- core/CMakeLists.txt | 2 +- .../condition/EndAnimationCondition.cpp | 8 +- .../condition/EndAnimationCondition.hpp | 3 +- core/event/management/controller/Attack.cpp | 50 +++++ core/event/management/controller/Attack.hpp | 19 ++ .../controller/statemachine/StateMachine.cpp | 2 +- core/event/physics/Collision.cpp | 2 +- core/event/physics/SensorCollision.cpp | 2 +- core/loader/LevelLoaderFromFile.cpp | 2 +- .../RenderableAnimatedSeveralFiles.cpp | 9 +- .../RenderableAnimatedSeveralFiles.hpp | 2 + core/visual/image/static/RenderableStatic.cpp | 2 +- core/visual/image/storage/ImageStorage.hpp | 8 +- core/world/LocalWorld.hpp | 2 +- game/mobs/hero/Hero.cpp | 194 +++++++++++++----- game/mobs/hero/Hero.hpp | 2 +- game/resources/levels/level_01/config.json | 61 +++++- game/resources/levels/level_01/map | 2 +- 18 files changed, 299 insertions(+), 73 deletions(-) create mode 100644 core/event/management/controller/Attack.cpp create mode 100644 core/event/management/controller/Attack.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index efccaff..1b3e1a0 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -96,7 +96,7 @@ set( event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp - event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp event/management/condition/SensorCondition.hpp event/management/condition/SensorCondition.cpp) + event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp event/management/condition/SensorCondition.hpp event/management/condition/SensorCondition.cpp event/management/controller/Attack.cpp event/management/controller/Attack.hpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/condition/EndAnimationCondition.cpp b/core/event/management/condition/EndAnimationCondition.cpp index 309397e..a7f09eb 100644 --- a/core/event/management/condition/EndAnimationCondition.cpp +++ b/core/event/management/condition/EndAnimationCondition.cpp @@ -1,10 +1,16 @@ #include "EndAnimationCondition.hpp" #include "common/Cast.hpp" +#include "spdlog/spdlog.h" #include -mad::core::EndAnimationCondition::EndAnimationCondition(Entity::Id m_entity_id, ImageStorage::TypeAction m_type_action) : m_entity_id(m_entity_id), m_type_action(m_type_action){ +mad::core::EndAnimationCondition::EndAnimationCondition(Entity::Id m_entity_id, ImageStorage::TypeAction m_type_action, int *stage) : m_entity_id(m_entity_id), m_type_action(m_type_action), stage(stage){ } bool mad::core::EndAnimationCondition::is_triggered_by(const mad::core::Event &event) { auto e = const_cast_to(event); + if(m_entity_id == e.get_entity_id() && m_type_action == e.get_type_action()){ + (*stage)++; + //SPDLOG_DEBUG("current attack_stage {}", *stage); + } + //SPDLOG_DEBUG("current attack_stage {}", *stage); return m_entity_id == e.get_entity_id() && m_type_action == e.get_type_action(); } std::unordered_set mad::core::EndAnimationCondition::triggers() { diff --git a/core/event/management/condition/EndAnimationCondition.hpp b/core/event/management/condition/EndAnimationCondition.hpp index cc930f5..0b9514c 100644 --- a/core/event/management/condition/EndAnimationCondition.hpp +++ b/core/event/management/condition/EndAnimationCondition.hpp @@ -7,7 +7,7 @@ namespace mad::core { struct EndAnimationCondition : Condition { public: - explicit EndAnimationCondition(Entity::Id m_entity_id, ImageStorage::TypeAction m_type_action); + explicit EndAnimationCondition(Entity::Id m_entity_id, ImageStorage::TypeAction m_type_action, int *stage = new int(0)); bool is_triggered_by(const mad::core::Event &event) override; std::unordered_set triggers() override; void on_start() override; @@ -15,6 +15,7 @@ namespace mad::core { private: Entity::Id m_entity_id; ImageStorage::TypeAction m_type_action; + int* stage; }; }// namespace mad::core diff --git a/core/event/management/controller/Attack.cpp b/core/event/management/controller/Attack.cpp new file mode 100644 index 0000000..f8d3a5b --- /dev/null +++ b/core/event/management/controller/Attack.cpp @@ -0,0 +1,50 @@ +#include "Attack.hpp" +mad::core::Attack::Attack(std::shared_ptr world, mad::core::Entity::Id entity_id, mad::core::Movement::Direction dir, int* attack_stage, float velocity) : Movement(world, entity_id, dir, velocity), attack_stage(attack_stage){ + Move_animation = ImageStorage::TypeAction::Attack_1_beg; + Idle_animation = ImageStorage::TypeAction::Attack_1_beg; +} +void mad::core::Attack::control() { + Movement::control(); + if((*attack_stage) % 6 == 0){ + if(Move_animation != ImageStorage::TypeAction::Attack_1_beg){ + SPDLOG_DEBUG("changed to Attack_1_beg"); + } + Move_animation = ImageStorage::TypeAction::Attack_1_beg; + Idle_animation = ImageStorage::TypeAction::Attack_1_beg; + } + if((*attack_stage) % 6 == 1){ + if(Move_animation != ImageStorage::TypeAction::Attack_1_end){ + SPDLOG_DEBUG("changed to Attack_1_end"); + } + Move_animation = ImageStorage::TypeAction::Attack_1_end; + Idle_animation = ImageStorage::TypeAction::Attack_1_end; + } + if((*attack_stage) % 6 == 2){ + if(Move_animation != ImageStorage::TypeAction::Attack_2_beg){ + SPDLOG_DEBUG("changed to Attack_2_beg"); + } + Move_animation = ImageStorage::TypeAction::Attack_2_beg; + Idle_animation = ImageStorage::TypeAction::Attack_2_beg; + } + if((*attack_stage) % 6 == 3){ + if(Move_animation != ImageStorage::TypeAction::Attack_2_end){ + SPDLOG_DEBUG("changed to Attack_2_end"); + } + Move_animation = ImageStorage::TypeAction::Attack_2_end; + Idle_animation = ImageStorage::TypeAction::Attack_2_end; + } + if((*attack_stage) % 6 == 4){ + if(Move_animation != ImageStorage::TypeAction::Attack_3_beg){ + SPDLOG_DEBUG("changed to Attack_3_beg"); + } + Move_animation = ImageStorage::TypeAction::Attack_3_beg; + Idle_animation = ImageStorage::TypeAction::Attack_3_beg; + } + if((*attack_stage) % 6 == 5){ + if(Move_animation != ImageStorage::TypeAction::Attack_3_end){ + SPDLOG_DEBUG("changed to Attack_3_end"); + } + Move_animation = ImageStorage::TypeAction::Attack_3_end; + Idle_animation = ImageStorage::TypeAction::Attack_3_end; + } +} diff --git a/core/event/management/controller/Attack.hpp b/core/event/management/controller/Attack.hpp new file mode 100644 index 0000000..e278c3a --- /dev/null +++ b/core/event/management/controller/Attack.hpp @@ -0,0 +1,19 @@ +#ifndef MAD_ATTACK_HPP +#define MAD_ATTACK_HPP + +#include "Movement.hpp" +#include "world/LocalWorld.hpp" +#include "world/World.hpp" + +namespace mad::core { + + class Attack : public Movement { + public: + Attack(std::shared_ptr world, Entity::Id entity_id, Direction dir, int* attack_stage, float velocity = 0); + void control() override; + int *attack_stage; + }; + +} + +#endif//MAD_ATTACK_HPP diff --git a/core/event/management/controller/statemachine/StateMachine.cpp b/core/event/management/controller/statemachine/StateMachine.cpp index 96cc912..ab5f66c 100644 --- a/core/event/management/controller/statemachine/StateMachine.cpp +++ b/core/event/management/controller/statemachine/StateMachine.cpp @@ -15,7 +15,7 @@ void mad::core::Transition::handle(const mad::core::Event &event) { m_state_machine->has_made_transition = true; m_state_machine->m_previous_state_id = m_state_machine->m_current_state_id; m_state_machine->m_current_state_id = next_state; - //SPDLOG_DEBUG("current state {}", m_state_machine->m_current_state_id); + SPDLOG_DEBUG("current state {}", m_state_machine->m_current_state_id); for (auto &i : m_state_machine->m_transitions[current_state]) { i->is_active = false; } diff --git a/core/event/physics/Collision.cpp b/core/event/physics/Collision.cpp index 0484b0c..b932ed2 100644 --- a/core/event/physics/Collision.cpp +++ b/core/event/physics/Collision.cpp @@ -1,5 +1,5 @@ #include "Collision.hpp" #include "spdlog/spdlog.h" mad::core::Collision::Collision(int new_first_object_id, int new_second_object_id) : Event(Event::Type::Collision), first_object_id(new_first_object_id), second_object_id(new_second_object_id) { - SPDLOG_INFO("handle collision {0} {1}", first_object_id, second_object_id); + //SPDLOG_INFO("handle collision {0} {1}", first_object_id, second_object_id); } diff --git a/core/event/physics/SensorCollision.cpp b/core/event/physics/SensorCollision.cpp index b8f0c33..24ec6bb 100644 --- a/core/event/physics/SensorCollision.cpp +++ b/core/event/physics/SensorCollision.cpp @@ -1,5 +1,5 @@ #include "SensorCollision.hpp" #include "spdlog/spdlog.h" mad::core::SensorCollision::SensorCollision(int m_id) : Event(Event::Type::SensorCollision), m_id(m_id) { - SPDLOG_INFO("sensor {}", m_id); + //SPDLOG_INFO("sensor {}", m_id); } diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 97eb900..549dbc4 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -64,7 +64,7 @@ namespace mad::core { std::make_shared( camera)};*/ - camera->set_zoom(0.07); + camera->set_zoom(0.10); auto level_runner = std::make_unique( system_listener, diff --git a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp index 8e8868f..023891e 100644 --- a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp +++ b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp @@ -1,8 +1,9 @@ #include "RenderableAnimatedSeveralFiles.hpp" +#include "spdlog/spdlog.h" -#include #include #include +#include namespace mad::core { @@ -36,7 +37,7 @@ namespace mad::core { m_scale = {animated_image->get_size_scale(), animated_image->get_size_scale()}; - float outline = 1; + float outline = 0.2; m_physical_shape = sf::RectangleShape({animated_image->get_physical_width() - outline, animated_image->get_physical_height() - outline}); m_physical_shape.setOrigin((animated_image->get_physical_width() - outline) / 2, @@ -55,6 +56,10 @@ namespace mad::core { } sf::Sprite render_sprite; + if(m_current_frame != debug_prev_sprite_num){ + debug_prev_sprite_num = m_current_frame; + SPDLOG_DEBUG("current frame number {}", m_current_frame); + } render_sprite.setTexture(m_textures[m_current_frame]); if (*m_orientation == Image::Orientation::Left && m_scale.get_x() > 0 || diff --git a/core/visual/image/animated/RenderableAnimatedSeveralFiles.hpp b/core/visual/image/animated/RenderableAnimatedSeveralFiles.hpp index cdde1a1..d8871ab 100644 --- a/core/visual/image/animated/RenderableAnimatedSeveralFiles.hpp +++ b/core/visual/image/animated/RenderableAnimatedSeveralFiles.hpp @@ -42,6 +42,8 @@ namespace mad::core { float m_delta_y; sf::RectangleShape m_physical_shape; + + int debug_prev_sprite_num = 0; }; } diff --git a/core/visual/image/static/RenderableStatic.cpp b/core/visual/image/static/RenderableStatic.cpp index 8884430..35b97d1 100644 --- a/core/visual/image/static/RenderableStatic.cpp +++ b/core/visual/image/static/RenderableStatic.cpp @@ -32,7 +32,7 @@ namespace mad::core { } } - float outline = 1; + float outline = 0.2; m_physical_shape = sf::RectangleShape({static_image->get_width() - outline, static_image->get_height() - outline}); m_physical_shape.setOrigin((static_image->get_width() - outline) / 2, (static_image->get_height() - outline) / 2); diff --git a/core/visual/image/storage/ImageStorage.hpp b/core/visual/image/storage/ImageStorage.hpp index d866bd0..59b4808 100644 --- a/core/visual/image/storage/ImageStorage.hpp +++ b/core/visual/image/storage/ImageStorage.hpp @@ -13,10 +13,16 @@ namespace mad::core { enum class TypeAction { Idle, Run, - Attack, + Attack_1_beg, + Attack_1_end, + Attack_2_beg, + Attack_2_end, + Attack_3_beg, + Attack_3_end, Jump, Fly_up, Fall, + }; explicit ImageStorage(std::unordered_map> actions); diff --git a/core/world/LocalWorld.hpp b/core/world/LocalWorld.hpp index 4cb88c3..c517b0e 100644 --- a/core/world/LocalWorld.hpp +++ b/core/world/LocalWorld.hpp @@ -22,7 +22,7 @@ namespace mad::core { class LocalWorld : public World { public: - explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 60.0f}); + explicit LocalWorld(EventDispatcher &event_dispatcher, Vec2d gravitation_scale = {0, 40.0f}); bool manipulate(const Filter &filter, const Intent &intent) override; diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index 0e4173e..fca0b4b 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -8,6 +8,7 @@ #include "event/management/condition/SensorCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" +#include "event/management/controller/Attack.hpp" #include "event/management/controller/Fall.hpp" #include "event/management/controller/FlyUp.hpp" #include "event/management/controller/GroundMovement.hpp" @@ -64,6 +65,48 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_1_beg, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_1_beg"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_1_beg"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_1_end, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_1_end"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_1_end"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_2_beg, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_2_beg"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_2_beg"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_2_end, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_2_end"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_2_end"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_3_beg, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_3_beg"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_3_beg"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_3_end, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_3_end"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_3_end"]["delta_time"], + physical_size_width, physical_size_height, size_scale, delta_x, delta_y)} } )); @@ -90,59 +133,108 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ }; auto machine = std::make_shared( std::shared_ptr(level_dispatcher)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, m_impulse)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); - machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); - - - machine->add_transition(0, 1, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(0, 2, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(1, 0, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(2, 0, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(1, 2, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(2, 1, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(0, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(1, 3, std::make_shared(sf::Keyboard::Space)); - machine->add_transition(2, 3, std::make_shared(sf::Keyboard::Space)); - - machine->add_transition(3, 5, std::make_shared()); - machine->add_transition(5, 4, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(5, 6, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(4, 5, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(6, 5, std::make_shared(sf::Keyboard::Right)); - - - machine->add_transition(4, 8, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); - machine->add_transition(5, 8, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); - machine->add_transition(6, 8, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); - - machine->add_transition(8, 7, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(8, 9, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(7, 8, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(9, 8, std::make_shared(sf::Keyboard::Right)); + StateMachine::StateId ground_idle = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + StateMachine::StateId ground_right = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + StateMachine::StateId ground_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + StateMachine::StateId jump_impulse = machine->add_state(std::make_shared(world, hero_id, m_impulse)); + StateMachine::StateId start_jump_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + StateMachine::StateId start_jump_idle = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + StateMachine::StateId start_jump_right = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + StateMachine::StateId fly_up_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + StateMachine::StateId fly_up_idle = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + StateMachine::StateId fly_up_right = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + StateMachine::StateId fall_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + StateMachine::StateId fall_idle = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + StateMachine::StateId fall_right= machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + int *attack_stage = new int(0); + StateMachine::StateId attack_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, attack_stage, horizontal_velocity)); + StateMachine::StateId attack_idle= machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, attack_stage, horizontal_velocity)); + StateMachine::StateId attack_right = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, attack_stage, horizontal_velocity)); + + machine->add_transition(ground_idle, ground_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(ground_idle, ground_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(ground_right, ground_idle, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(ground_left, ground_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(ground_right, ground_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(ground_left, ground_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(ground_idle, jump_impulse, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(ground_right, jump_impulse, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(ground_left, jump_impulse, std::make_shared(sf::Keyboard::Space)); + + machine->add_transition(jump_impulse, start_jump_idle, std::make_shared()); + machine->add_transition(start_jump_idle, start_jump_left , std::make_shared(sf::Keyboard::Left)); + machine->add_transition(start_jump_idle, start_jump_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(start_jump_left , start_jump_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(start_jump_right, start_jump_idle, std::make_shared(sf::Keyboard::Right)); + + + machine->add_transition(start_jump_left , fly_up_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); + machine->add_transition(start_jump_idle, fly_up_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); + machine->add_transition(start_jump_right, fly_up_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); + + machine->add_transition(fly_up_idle, fly_up_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(fly_up_idle, fly_up_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(fly_up_left, fly_up_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(fly_up_right, fly_up_idle, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(fly_up_left, fall_idle, std::make_shared(world, hero_id)); + machine->add_transition(fly_up_idle, fall_idle, std::make_shared(world, hero_id)); + machine->add_transition(fly_up_right, fall_idle, std::make_shared(world, hero_id)); + + machine->add_transition(fall_idle, fall_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(fall_idle, fall_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(fall_left, fall_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(fall_right, fall_idle, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(fall_left, ground_idle, std::make_shared(hero_id)); + machine->add_transition(fall_idle, ground_idle, std::make_shared(hero_id)); + machine->add_transition(fall_right, ground_idle, std::make_shared(hero_id)); + + + machine->add_transition(ground_left, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(ground_idle, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(ground_right, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(start_jump_left, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(start_jump_idle, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(start_jump_right, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fly_up_left, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fly_up_idle, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fly_up_right, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fall_left, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fall_idle, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fall_right, attack_idle, std::make_shared(sf::Keyboard::Q)); + + machine->add_transition(attack_idle, attack_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(attack_left, attack_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(attack_idle, attack_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(attack_right, attack_idle, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(attack_idle, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_beg, attack_stage)); + machine->add_transition(attack_left, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_beg, attack_stage)); + machine->add_transition(attack_right, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_beg, attack_stage)); + + machine->add_transition(attack_left, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_end, attack_stage)); + machine->add_transition(attack_idle, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_end, attack_stage)); + machine->add_transition(attack_right, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_end, attack_stage)); + + machine->add_transition(attack_idle, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_beg, attack_stage)); + machine->add_transition(attack_left, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_beg, attack_stage)); + machine->add_transition(attack_right, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_beg, attack_stage)); + + machine->add_transition(attack_left, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_end, attack_stage)); + machine->add_transition(attack_idle, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_end, attack_stage)); + machine->add_transition(attack_right, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_end, attack_stage)); + + machine->add_transition(attack_idle, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_beg, attack_stage)); + machine->add_transition(attack_left, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_beg, attack_stage)); + machine->add_transition(attack_right, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_beg, attack_stage)); + + machine->add_transition(attack_left, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_end, attack_stage)); + machine->add_transition(attack_idle, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_end, attack_stage)); + machine->add_transition(attack_right, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_end, attack_stage)); - machine->add_transition(7, 11, std::make_shared(world, hero_id)); - machine->add_transition(8, 11, std::make_shared(world, hero_id)); - machine->add_transition(9, 11, std::make_shared(world, hero_id)); - machine->add_transition(11, 10, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(11, 12, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(10, 11, std::make_shared(sf::Keyboard::Left)); - machine->add_transition(12, 11, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(10, 0, std::make_shared(hero_id)); - machine->add_transition(11, 0, std::make_shared(hero_id)); - machine->add_transition(12, 0, std::make_shared(hero_id)); @@ -154,7 +246,7 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ /// add sensor auto m_entity = cast_to_or_null(world->get_storage().get_entity(hero_id)); - m_entity->add_sensor({0, 4}, 0.3, 0.05); + m_entity->add_sensor({0, 6}, 2.65, 0.05); } mad::core::Entity::Id mad::core::Hero::get_hero_id() const { return hero_id; diff --git a/game/mobs/hero/Hero.hpp b/game/mobs/hero/Hero.hpp index 988369e..11df06c 100644 --- a/game/mobs/hero/Hero.hpp +++ b/game/mobs/hero/Hero.hpp @@ -16,7 +16,7 @@ namespace mad::core { Entity::Id hero_id; std::shared_ptr level_dispatcher; float horizontal_velocity = 20; - float m_impulse = 3000; + float m_impulse = 2000; }; }// namespace mad::core diff --git a/game/resources/levels/level_01/config.json b/game/resources/levels/level_01/config.json index 3f8bdfc..fcebda0 100644 --- a/game/resources/levels/level_01/config.json +++ b/game/resources/levels/level_01/config.json @@ -1,7 +1,7 @@ { "name" : "level_01", "animated_resources" : "../../game/resources/animated/", - "block" : 50.0, + "block" : 10.0, "camera": { "position" : { "x" : 10.0, @@ -18,21 +18,66 @@ "hero" : { "source" : "hero", "animated" : { - "size_width": 30, - "size_height": 50, - "size_scale": 0.2, + "size_width": 5.5, + "size_height": 9, + "size_scale": 0.3, "delta_x" : 0, - "delta_y" : 0, + "delta_y" : 3, "actions" : { "idle" : { - "source": "idle", + "source": "hero_idle", "type": "several_files", - "delta_time": 100 + "delta_time": 200000 }, "run" : { - "source": "run", + "source": "hero_run", + "type": "several_files", + "delta_time": 130 + }, + "jump" : { + "source": "hero_jump", + "type": "several_files", + "delta_time": 50 + }, + "fly_up" : { + "source": "hero_fly_up", "type": "several_files", "delta_time": 100 + }, + "fall" : { + "source": "hero_fall", + "type": "several_files", + "delta_time": 130 + }, + "attack_1_beg" : { + "source": "hero_attack_1_beg", + "type": "several_files", + "delta_time": 2000 + }, + "attack_1_end" : { + "source": "hero_attack_1_end", + "type": "several_files", + "delta_time": 2000 + }, + "attack_2_beg" : { + "source": "hero_attack_2_beg", + "type": "several_files", + "delta_time": 2000 + }, + "attack_2_end" : { + "source": "hero_attack_2_end", + "type": "several_files", + "delta_time": 2000 + }, + "attack_3_beg" : { + "source": "hero_attack_3_beg", + "type": "several_files", + "delta_time": 2000 + }, + "attack_3_end" : { + "source": "hero_attack_3_end", + "type": "several_files", + "delta_time": 2000 } } } diff --git a/game/resources/levels/level_01/map b/game/resources/levels/level_01/map index 6878e22..1d60380 100644 --- a/game/resources/levels/level_01/map +++ b/game/resources/levels/level_01/map @@ -1,5 +1,5 @@ @......H..#..# -....#.......## +...##.......## ...#.#......## ###########.## ............## From 458519dab3524ee1991122d08f211434bc7fd06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Mon, 23 May 2022 11:07:21 +0300 Subject: [PATCH 38/44] add debug --- .../image/animated/RenderableAnimatedSeveralFiles.cpp | 7 ++++--- .../image/animated/RenderableAnimatedSeveralFiles.hpp | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp index 023891e..3f5e6e5 100644 --- a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp +++ b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp @@ -27,6 +27,7 @@ namespace mad::core { CHECK_THROW(texture.loadFromFile(file_name), FileDoesNotExist, "File with StaticImage doesn't exist"); m_textures.push_back(texture); + debug_m_textures_names.push_back(file_name); } m_current_frame = m_textures.size(); @@ -56,9 +57,9 @@ namespace mad::core { } sf::Sprite render_sprite; - if(m_current_frame != debug_prev_sprite_num){ - debug_prev_sprite_num = m_current_frame; - SPDLOG_DEBUG("current frame number {}", m_current_frame); + if(debug_prev_name != debug_m_textures_names[m_current_frame]){ + debug_prev_name = debug_m_textures_names[m_current_frame]; + SPDLOG_DEBUG("current frame name {}", debug_prev_name); } render_sprite.setTexture(m_textures[m_current_frame]); diff --git a/core/visual/image/animated/RenderableAnimatedSeveralFiles.hpp b/core/visual/image/animated/RenderableAnimatedSeveralFiles.hpp index d8871ab..c4d28e1 100644 --- a/core/visual/image/animated/RenderableAnimatedSeveralFiles.hpp +++ b/core/visual/image/animated/RenderableAnimatedSeveralFiles.hpp @@ -44,6 +44,10 @@ namespace mad::core { sf::RectangleShape m_physical_shape; int debug_prev_sprite_num = 0; + + std::vector debug_m_textures_names; + + std::string debug_prev_name; }; } From b63a238fd311872ccfbcd66babf7848a661f83c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Mon, 23 May 2022 12:09:57 +0300 Subject: [PATCH 39/44] multiple conditions in one transaction --- .../management/condition/FallCondition.cpp | 4 ++-- .../management/condition/FallCondition.hpp | 3 ++- .../controller/statemachine/StateMachine.cpp | 18 ++++++++++++++---- .../controller/statemachine/StateMachine.hpp | 3 ++- .../RenderableAnimatedSeveralFiles.cpp | 2 +- game/mobs/hero/Hero.cpp | 9 ++++++--- game/resources/levels/level_01/config.json | 12 ++++++------ game/resources/levels/level_01/map | 5 +++++ 8 files changed, 38 insertions(+), 18 deletions(-) diff --git a/core/event/management/condition/FallCondition.cpp b/core/event/management/condition/FallCondition.cpp index 235eb11..ce13ed6 100644 --- a/core/event/management/condition/FallCondition.cpp +++ b/core/event/management/condition/FallCondition.cpp @@ -3,13 +3,13 @@ bool mad::core::FallCondition::is_triggered_by(const mad::core::Event &event) { - return m_entity->get_linear_velocity().get_y() >= 0; + return m_entity->get_linear_velocity().get_y() >= vel; } std::unordered_set mad::core::FallCondition::triggers() { return {mad::core::Event::Type::WorldUpdate}; } void mad::core::FallCondition::on_start() { } -mad::core::FallCondition::FallCondition(std::shared_ptr world, mad::core::Entity::Id entity_id) : m_world(world), m_entity_id(entity_id) { +mad::core::FallCondition::FallCondition(std::shared_ptr world, mad::core::Entity::Id entity_id, float vel) : m_world(world), m_entity_id(entity_id), vel(vel) { m_entity = cast_to_or_null(m_world->get_storage().get_entity(m_entity_id)); } diff --git a/core/event/management/condition/FallCondition.hpp b/core/event/management/condition/FallCondition.hpp index 905fe0b..2c54d13 100644 --- a/core/event/management/condition/FallCondition.hpp +++ b/core/event/management/condition/FallCondition.hpp @@ -9,7 +9,7 @@ namespace mad::core { struct FallCondition : Condition { public: - explicit FallCondition(std::shared_ptr world, Entity::Id entity_id); + explicit FallCondition(std::shared_ptr world, Entity::Id entity_id, float vel); bool is_triggered_by(const mad::core::Event &event) override; std::unordered_set triggers() override; void on_start() override; @@ -18,6 +18,7 @@ namespace mad::core { std::shared_ptr m_world; Entity::Id m_entity_id; PhysicalEntity *m_entity; + float vel; }; }// namespace mad::core diff --git a/core/event/management/controller/statemachine/StateMachine.cpp b/core/event/management/controller/statemachine/StateMachine.cpp index ab5f66c..82ce146 100644 --- a/core/event/management/controller/statemachine/StateMachine.cpp +++ b/core/event/management/controller/statemachine/StateMachine.cpp @@ -7,11 +7,17 @@ std::unordered_set mad::core::Transition::handled_types() { - return m_condition->triggers(); + return m_conditions[0]->triggers(); } void mad::core::Transition::handle(const mad::core::Event &event) { if (!is_active || m_state_machine->has_made_transition) return; - if (m_condition->is_triggered_by(event)) { + bool flag = true; + for(auto &i : m_conditions){ + if(!i->is_triggered_by(event)){ + flag = false; + } + } + if (flag) { m_state_machine->has_made_transition = true; m_state_machine->m_previous_state_id = m_state_machine->m_current_state_id; m_state_machine->m_current_state_id = next_state; @@ -21,11 +27,15 @@ void mad::core::Transition::handle(const mad::core::Event &event) { } for (auto &i : m_state_machine->m_transitions[next_state]) { i->is_active = true; - i->m_condition->on_start(); + for(auto &el : i->m_conditions){ + el->on_start(); + } } } } -mad::core::Transition::Transition(mad::core::StateMachine *m_state_machine, mad::core::StateMachine::StateId current_state, mad::core::StateMachine::StateId next_state, std::shared_ptr m_condition) : m_state_machine(m_state_machine), current_state(current_state), next_state(next_state), m_condition(std::move(m_condition)) { +mad::core::Transition::Transition(mad::core::StateMachine *m_state_machine, mad::core::StateMachine::StateId current_state, mad::core::StateMachine::StateId next_state, std::shared_ptr m_condition) : m_state_machine(m_state_machine), current_state(current_state), next_state(next_state), m_conditions({std::move(m_condition)}) { +} +mad::core::Transition::Transition(mad::core::StateMachine *m_state_machine, mad::core::StateMachine::StateId current_state, mad::core::StateMachine::StateId next_state, std::vector> m_conditions) : m_state_machine(m_state_machine), current_state(current_state), next_state(next_state), m_conditions(m_conditions) { } diff --git a/core/event/management/controller/statemachine/StateMachine.hpp b/core/event/management/controller/statemachine/StateMachine.hpp index 05e4791..880728f 100644 --- a/core/event/management/controller/statemachine/StateMachine.hpp +++ b/core/event/management/controller/statemachine/StateMachine.hpp @@ -37,6 +37,7 @@ namespace mad::core { struct Transition : EventHandler { public: Transition(StateMachine *m_state_machine, StateMachine::StateId current_state, StateMachine::StateId next_state, std::shared_ptr m_condition); + Transition(StateMachine *m_state_machine, StateMachine::StateId current_state, StateMachine::StateId next_state, std::vector> m_conditions); std::unordered_set handled_types() override; void handle(const Event &event) override; bool is_active = false; @@ -45,7 +46,7 @@ namespace mad::core { StateMachine *m_state_machine; StateMachine::StateId current_state; StateMachine::StateId next_state; - std::shared_ptr m_condition; + std::vector> m_conditions; }; }// namespace mad::core diff --git a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp index 3f5e6e5..cb6353c 100644 --- a/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp +++ b/core/visual/image/animated/RenderableAnimatedSeveralFiles.cpp @@ -59,7 +59,7 @@ namespace mad::core { sf::Sprite render_sprite; if(debug_prev_name != debug_m_textures_names[m_current_frame]){ debug_prev_name = debug_m_textures_names[m_current_frame]; - SPDLOG_DEBUG("current frame name {}", debug_prev_name); + //SPDLOG_DEBUG("current frame name {}", debug_prev_name); } render_sprite.setTexture(m_textures[m_current_frame]); diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index fca0b4b..e146f67 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -177,9 +177,12 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(fly_up_left, fly_up_idle, std::make_shared(sf::Keyboard::Left)); machine->add_transition(fly_up_right, fly_up_idle, std::make_shared(sf::Keyboard::Right)); - machine->add_transition(fly_up_left, fall_idle, std::make_shared(world, hero_id)); - machine->add_transition(fly_up_idle, fall_idle, std::make_shared(world, hero_id)); - machine->add_transition(fly_up_right, fall_idle, std::make_shared(world, hero_id)); + machine->add_transition(fly_up_left, fall_idle, std::make_shared(world, hero_id, 0)); + machine->add_transition(fly_up_idle, fall_idle, std::make_shared(world, hero_id, 0)); + machine->add_transition(fly_up_right, fall_idle, std::make_shared(world, hero_id, 0)); + machine->add_transition(ground_left, fall_idle, std::make_shared(world, hero_id, 3)); + machine->add_transition(ground_idle, fall_idle, std::make_shared(world, hero_id, 3)); + machine->add_transition(ground_right, fall_idle, std::make_shared(world, hero_id, 3)); machine->add_transition(fall_idle, fall_left, std::make_shared(sf::Keyboard::Left)); machine->add_transition(fall_idle, fall_right, std::make_shared(sf::Keyboard::Right)); diff --git a/game/resources/levels/level_01/config.json b/game/resources/levels/level_01/config.json index fcebda0..3181bec 100644 --- a/game/resources/levels/level_01/config.json +++ b/game/resources/levels/level_01/config.json @@ -52,32 +52,32 @@ "attack_1_beg" : { "source": "hero_attack_1_beg", "type": "several_files", - "delta_time": 2000 + "delta_time": 30 }, "attack_1_end" : { "source": "hero_attack_1_end", "type": "several_files", - "delta_time": 2000 + "delta_time": 30 }, "attack_2_beg" : { "source": "hero_attack_2_beg", "type": "several_files", - "delta_time": 2000 + "delta_time": 30 }, "attack_2_end" : { "source": "hero_attack_2_end", "type": "several_files", - "delta_time": 2000 + "delta_time": 30 }, "attack_3_beg" : { "source": "hero_attack_3_beg", "type": "several_files", - "delta_time": 2000 + "delta_time": 30 }, "attack_3_end" : { "source": "hero_attack_3_end", "type": "several_files", - "delta_time": 2000 + "delta_time": 30 } } } diff --git a/game/resources/levels/level_01/map b/game/resources/levels/level_01/map index 1d60380..846bc16 100644 --- a/game/resources/levels/level_01/map +++ b/game/resources/levels/level_01/map @@ -1,4 +1,9 @@ @......H..#..# +.............. +.............. +.............. +.............. +.............. ...##.......## ...#.#......## ###########.## From 94aee0cd4702ddce2f8983a1a38bfedda526b371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Mon, 23 May 2022 15:03:53 +0300 Subject: [PATCH 40/44] multiple conditions in one transaction + add fall without jump --- core/CMakeLists.txt | 2 +- core/event/Event.hpp | 3 ++- core/event/management/condition/Condition.hpp | 2 ++ .../condition/SensorEndCondition.cpp | 24 +++++++++++++++++ .../condition/SensorEndCondition.hpp | 23 ++++++++++++++++ .../controller/statemachine/StateMachine.cpp | 27 ++++++++++++++++--- .../controller/statemachine/StateMachine.hpp | 5 +++- core/event/physics/SensorCollisionEnd.cpp | 3 +++ core/event/physics/SensorCollisionEnd.hpp | 16 +++++++++++ .../ContactListener/ContactListener.hpp | 15 +++++------ game/mobs/hero/Hero.cpp | 8 +++--- game/resources/levels/level_01/config.json | 2 +- 12 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 core/event/management/condition/SensorEndCondition.cpp create mode 100644 core/event/management/condition/SensorEndCondition.hpp create mode 100644 core/event/physics/SensorCollisionEnd.cpp create mode 100644 core/event/physics/SensorCollisionEnd.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 1b3e1a0..db79e48 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -96,7 +96,7 @@ set( event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp - event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp event/management/condition/SensorCondition.hpp event/management/condition/SensorCondition.cpp event/management/controller/Attack.cpp event/management/controller/Attack.hpp) + event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp event/management/condition/SensorCondition.hpp event/management/condition/SensorCondition.cpp event/management/controller/Attack.cpp event/management/controller/Attack.hpp event/physics/SensorCollisionEnd.hpp event/physics/SensorCollisionEnd.cpp event/management/condition/SensorEndCondition.hpp event/management/condition/SensorEndCondition.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/Event.hpp b/core/event/Event.hpp index ece2fec..b8ba690 100644 --- a/core/event/Event.hpp +++ b/core/event/Event.hpp @@ -18,7 +18,8 @@ namespace mad::core { Runner, WorldUpdate, EndOfRenderAction, - SensorCollision + SensorCollision, + SensorCollisionEnd, }; explicit Event(Type new_type); diff --git a/core/event/management/condition/Condition.hpp b/core/event/management/condition/Condition.hpp index 8a5fa05..dd3904b 100644 --- a/core/event/management/condition/Condition.hpp +++ b/core/event/management/condition/Condition.hpp @@ -18,6 +18,8 @@ namespace mad::core { virtual void on_start() = 0; virtual ~Condition() = default; + + bool triggered; }; } diff --git a/core/event/management/condition/SensorEndCondition.cpp b/core/event/management/condition/SensorEndCondition.cpp new file mode 100644 index 0000000..3462a9e --- /dev/null +++ b/core/event/management/condition/SensorEndCondition.cpp @@ -0,0 +1,24 @@ + +#include "SensorEndCondition.hpp" +#include "common/Cast.hpp" +#include "event/physics/SensorCollisionEnd.hpp" +#include + +mad::core::SensorEndCondition::SensorEndCondition(Entity::Id m_entity_id, float delta_time) : m_entity_id(m_entity_id), m_dt(delta_time){ +} +bool mad::core::SensorEndCondition::is_triggered_by(const mad::core::Event &event) { + if(event.type == Event::Type::SensorCollisionEnd){ + const auto &e = const_cast_to(event); + if(e.m_id == m_entity_id){ + sf::Time time = clock.getElapsedTime(); + timerStart = time.asSeconds(); + } + } + return clock.getElapsedTime().asSeconds() - timerStart < m_dt; + +} +std::unordered_set mad::core::SensorEndCondition::triggers() { + return {mad::core::Event::Type::SensorCollisionEnd, mad::core::Event::Type::WorldUpdate}; +} +void mad::core::SensorEndCondition::on_start() { +} diff --git a/core/event/management/condition/SensorEndCondition.hpp b/core/event/management/condition/SensorEndCondition.hpp new file mode 100644 index 0000000..efc7c2c --- /dev/null +++ b/core/event/management/condition/SensorEndCondition.hpp @@ -0,0 +1,23 @@ +#ifndef MAD_SENSORENDCONDITION_HPP +#define MAD_SENSORENDCONDITION_HPP + +#include "Condition.hpp" +#include "world/entity/Entity.hpp" +#include +namespace mad::core { + struct SensorEndCondition : Condition { + public: + explicit SensorEndCondition(Entity::Id m_entity_id, float delta_time); + bool is_triggered_by(const mad::core::Event &event) override; + std::unordered_set triggers() override; + void on_start() override; + + private: + Entity::Id m_entity_id; + sf::Clock clock; + float timerStart; + float m_dt; + }; +}// namespace mad::core + +#endif//MAD_SENSORENDCONDITION_HPP diff --git a/core/event/management/controller/statemachine/StateMachine.cpp b/core/event/management/controller/statemachine/StateMachine.cpp index 82ce146..d5bd2d1 100644 --- a/core/event/management/controller/statemachine/StateMachine.cpp +++ b/core/event/management/controller/statemachine/StateMachine.cpp @@ -7,16 +7,25 @@ std::unordered_set mad::core::Transition::handled_types() { - return m_conditions[0]->triggers(); + std::unordered_set res; + for(auto const &i : m_conditions){ + res.insert(i->triggers().begin(), i->triggers().end()); + } + return res; } void mad::core::Transition::handle(const mad::core::Event &event) { if (!is_active || m_state_machine->has_made_transition) return; - bool flag = true; for(auto &i : m_conditions){ - if(!i->is_triggered_by(event)){ - flag = false; + if(i->triggers().find(event.type) != i->triggers().end()){ + if(i->is_triggered_by(event)){ + i->triggered = true; + } } } + bool flag = true; + for(auto &i : m_conditions){ + flag &= i->triggered; + } if (flag) { m_state_machine->has_made_transition = true; m_state_machine->m_previous_state_id = m_state_machine->m_current_state_id; @@ -42,6 +51,11 @@ mad::core::Transition::Transition(mad::core::StateMachine *m_state_machine, mad: /// StateMachine void mad::core::StateMachine::control() { //SPDLOG_DEBUG("current state {}", m_current_state_id); + for(auto &i : m_transitions[m_current_state_id]){ + for(auto &j : i->m_conditions){ + j->triggered = false; + } + } has_made_transition = false; m_states[m_current_state_id]->control(); } @@ -62,6 +76,11 @@ void mad::core::StateMachine::add_transition(mad::core::StateMachine::StateId st m_transitions[state_id_from].push_back(transition); m_dispatcher->registry(transition); } +void mad::core::StateMachine::add_transition(mad::core::StateMachine::StateId state_id_from, mad::core::StateMachine::StateId state_id_to, std::vector> transition_conditions) { + auto transition = std::make_shared(this, state_id_from, state_id_to, transition_conditions); + m_transitions[state_id_from].push_back(transition); + m_dispatcher->registry(transition); +} mad::core::StateMachine::StateMachine(std::shared_ptr m_dispatcher) : m_dispatcher(std::move(m_dispatcher)){ } mad::core::StateMachine::StateId mad::core::StateMachine::get_previous_state_id() { diff --git a/core/event/management/controller/statemachine/StateMachine.hpp b/core/event/management/controller/statemachine/StateMachine.hpp index 880728f..e9629da 100644 --- a/core/event/management/controller/statemachine/StateMachine.hpp +++ b/core/event/management/controller/statemachine/StateMachine.hpp @@ -19,6 +19,7 @@ namespace mad::core { StateId add_state(const std::shared_ptr &state); void add_transition(StateId state_id_from, StateId state_id_to, std::shared_ptr transition_condition); + void add_transition(StateId state_id_from, StateId state_id_to, std::vector> transition_conditions); void set_initial_state(StateId state_id); void control() override; StateId get_previous_state_id(); @@ -35,18 +36,20 @@ namespace mad::core { }; struct Transition : EventHandler { + std::vector> m_conditions; + public: Transition(StateMachine *m_state_machine, StateMachine::StateId current_state, StateMachine::StateId next_state, std::shared_ptr m_condition); Transition(StateMachine *m_state_machine, StateMachine::StateId current_state, StateMachine::StateId next_state, std::vector> m_conditions); std::unordered_set handled_types() override; void handle(const Event &event) override; bool is_active = false; + int cnt = 0; private: StateMachine *m_state_machine; StateMachine::StateId current_state; StateMachine::StateId next_state; - std::vector> m_conditions; }; }// namespace mad::core diff --git a/core/event/physics/SensorCollisionEnd.cpp b/core/event/physics/SensorCollisionEnd.cpp new file mode 100644 index 0000000..7da112c --- /dev/null +++ b/core/event/physics/SensorCollisionEnd.cpp @@ -0,0 +1,3 @@ +#include "SensorCollisionEnd.hpp" +mad::core::SensorCollisionEnd::SensorCollisionEnd(int m_id) : Event(Event::Type::SensorCollisionEnd), m_id(m_id) { +} diff --git a/core/event/physics/SensorCollisionEnd.hpp b/core/event/physics/SensorCollisionEnd.hpp new file mode 100644 index 0000000..6b936b1 --- /dev/null +++ b/core/event/physics/SensorCollisionEnd.hpp @@ -0,0 +1,16 @@ +#ifndef MAD_SENSORCOLLISIONEND_HPP +#define MAD_SENSORCOLLISIONEND_HPP + +#include "event/Event.hpp" +namespace mad::core { + + struct SensorCollisionEnd : public Event { + explicit SensorCollisionEnd(int m_id); + + const int m_id; + }; + +} + + +#endif//MAD_SENSORCOLLISIONEND_HPP diff --git a/core/world/entity/ContactListener/ContactListener.hpp b/core/world/entity/ContactListener/ContactListener.hpp index 9a42504..113a443 100644 --- a/core/world/entity/ContactListener/ContactListener.hpp +++ b/core/world/entity/ContactListener/ContactListener.hpp @@ -2,6 +2,7 @@ #define MAD_CONTACTLISTENER_HPP #include "event/physics/SensorCollision.hpp" +#include "event/physics/SensorCollisionEnd.hpp" #include "spdlog/spdlog.h" #include #include @@ -31,15 +32,11 @@ namespace mad::core{ void EndContact(b2Contact* contact) override{ - /*//check if fixture A was a ball - void* bodyUserData = contact->GetFixtureA()->GetBody()->GetUserData(); - if ( bodyUserData ) - static_cast( bodyUserData )->endContact(); - - //check if fixture B was a ball - bodyUserData = contact->GetFixtureB()->GetBody()->GetUserData(); - if ( bodyUserData ) - static_cast( bodyUserData )->endContact();*/ + ///sensors + b2FixtureUserData fixture_data_A = contact->GetFixtureA()->GetUserData(); + b2FixtureUserData fixture_data_B = contact->GetFixtureB()->GetUserData(); + if(static_cast(fixture_data_A.pointer) != 0) dispatcher.dispatch(std::make_shared(fixture_data_A.pointer)); + if(static_cast(fixture_data_B.pointer) != 0) dispatcher.dispatch(std::make_shared(fixture_data_B.pointer)); } diff --git a/game/mobs/hero/Hero.cpp b/game/mobs/hero/Hero.cpp index e146f67..0440854 100644 --- a/game/mobs/hero/Hero.cpp +++ b/game/mobs/hero/Hero.cpp @@ -6,6 +6,7 @@ #include "event/management/condition/KeyReleasedCondition.hpp" #include "event/management/condition/LastStateCondition.hpp" #include "event/management/condition/SensorCondition.hpp" +#include "event/management/condition/SensorEndCondition.hpp" #include "event/management/condition/TimerCondition.hpp" #include "event/management/condition/TrueCondition.hpp" #include "event/management/controller/Attack.hpp" @@ -180,9 +181,10 @@ mad::core::Hero::Hero(std::shared_ptr world, Vec2d position, json m_ machine->add_transition(fly_up_left, fall_idle, std::make_shared(world, hero_id, 0)); machine->add_transition(fly_up_idle, fall_idle, std::make_shared(world, hero_id, 0)); machine->add_transition(fly_up_right, fall_idle, std::make_shared(world, hero_id, 0)); - machine->add_transition(ground_left, fall_idle, std::make_shared(world, hero_id, 3)); - machine->add_transition(ground_idle, fall_idle, std::make_shared(world, hero_id, 3)); - machine->add_transition(ground_right, fall_idle, std::make_shared(world, hero_id, 3)); + + machine->add_transition(ground_left, fall_idle, std::vector>{std::make_shared(world, hero_id, 0.1), std::make_shared(hero_id, 0.2)}); + machine->add_transition(ground_idle, fall_idle, std::vector>{std::make_shared(world, hero_id, 0.1), std::make_shared(hero_id, 0.2)}); + machine->add_transition(ground_right, fall_idle, std::vector>{std::make_shared(world, hero_id, 0.1), std::make_shared(hero_id, 0.2)}); machine->add_transition(fall_idle, fall_left, std::make_shared(sf::Keyboard::Left)); machine->add_transition(fall_idle, fall_right, std::make_shared(sf::Keyboard::Right)); diff --git a/game/resources/levels/level_01/config.json b/game/resources/levels/level_01/config.json index 3181bec..7189c6c 100644 --- a/game/resources/levels/level_01/config.json +++ b/game/resources/levels/level_01/config.json @@ -27,7 +27,7 @@ "idle" : { "source": "hero_idle", "type": "several_files", - "delta_time": 200000 + "delta_time": 200 }, "run" : { "source": "hero_run", From 6624759f321235f7eeabc408a4d88f8045d80e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Sun, 29 May 2022 13:55:00 +0300 Subject: [PATCH 41/44] make HeroStateMachine --- core/CMakeLists.txt | 2 +- .../statemachine/HeroStateMachine.cpp | 138 ++++++++++++++++++ .../statemachine/HeroStateMachine.hpp | 16 ++ core/loader/LevelLoaderFromFile.cpp | 86 ++++++++++- 4 files changed, 235 insertions(+), 7 deletions(-) create mode 100644 core/event/management/controller/statemachine/HeroStateMachine.cpp create mode 100644 core/event/management/controller/statemachine/HeroStateMachine.hpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index db79e48..743ade8 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -96,7 +96,7 @@ set( event/management/condition/KeyPressedCondition.hpp event/management/condition/KeyPressedCondition.cpp event/management/condition/KeyDownCondition.hpp event/management/condition/KeyDownCondition.cpp event/management/condition/TimerCondition.hpp event/management/condition/TimerCondition.cpp - event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp event/management/condition/SensorCondition.hpp event/management/condition/SensorCondition.cpp event/management/controller/Attack.cpp event/management/controller/Attack.hpp event/physics/SensorCollisionEnd.hpp event/physics/SensorCollisionEnd.cpp event/management/condition/SensorEndCondition.hpp event/management/condition/SensorEndCondition.cpp) + event/WorldUpdate.hpp event/WorldUpdate.cpp ../game/mobs/hero/Hero.hpp ../game/mobs/hero/Hero.cpp event/management/condition/KeyReleasedCondition.hpp event/management/condition/KeyReleasedCondition.cpp event/management/controller/JumpImpulse.hpp event/management/controller/JumpImpulse.cpp event/management/condition/LastStateCondition.hpp event/management/condition/LastStateCondition.cpp event/management/controller/Movement.hpp event/management/controller/Movement.cpp event/management/controller/StartJump.hpp event/management/controller/StartJump.cpp event/management/controller/FlyUp.hpp event/management/controller/FlyUp.cpp event/management/controller/Fall.hpp event/management/controller/Fall.cpp event/management/controller/GroundMovement.hpp event/management/controller/GroundMovement.cpp event/management/condition/EndAnimationCondition.hpp event/management/condition/EndAnimationCondition.cpp event/management/condition/FallCondition.hpp event/management/condition/FallCondition.cpp event/physics/SensorCollision.hpp event/physics/SensorCollision.cpp event/management/condition/SensorCondition.hpp event/management/condition/SensorCondition.cpp event/management/controller/Attack.cpp event/management/controller/Attack.hpp event/physics/SensorCollisionEnd.hpp event/physics/SensorCollisionEnd.cpp event/management/condition/SensorEndCondition.hpp event/management/condition/SensorEndCondition.cpp event/management/controller/statemachine/HeroStateMachine.hpp event/management/controller/statemachine/HeroStateMachine.cpp) add_library( ${LIBRARY_CORE} STATIC diff --git a/core/event/management/controller/statemachine/HeroStateMachine.cpp b/core/event/management/controller/statemachine/HeroStateMachine.cpp new file mode 100644 index 0000000..45a8d8f --- /dev/null +++ b/core/event/management/controller/statemachine/HeroStateMachine.cpp @@ -0,0 +1,138 @@ +#include "HeroStateMachine.hpp" +#include "event/management/condition/EndAnimationCondition.hpp" +#include "event/management/condition/FallCondition.hpp" +#include "event/management/condition/KeyDownCondition.hpp" +#include "event/management/condition/KeyPressedCondition.hpp" +#include "event/management/condition/KeyReleasedCondition.hpp" +#include "event/management/condition/LastStateCondition.hpp" +#include "event/management/condition/SensorCondition.hpp" +#include "event/management/condition/SensorEndCondition.hpp" +#include "event/management/condition/TimerCondition.hpp" +#include "event/management/condition/TrueCondition.hpp" +#include "event/management/controller/Attack.hpp" +#include "event/management/controller/Fall.hpp" +#include "event/management/controller/FlyUp.hpp" +#include "event/management/controller/GroundMovement.hpp" +#include "event/management/controller/JumpImpulse.hpp" +#include "event/management/controller/Movement.hpp" +#include "event/management/controller/StartJump.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" + +mad::core::HeroStateMachine::HeroStateMachine(std::shared_ptr world, mad::core::Vec2d position, int hero_id, std::shared_ptr level_dispatcher, float m_impulse, float horizontal_velocity) : StateMachine(level_dispatcher){ + auto machine = this; + + + StateMachine::StateId ground_idle = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle)); + StateMachine::StateId ground_right = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + StateMachine::StateId ground_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + StateMachine::StateId jump_impulse = machine->add_state(std::make_shared(world, hero_id, m_impulse)); + StateMachine::StateId start_jump_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); + StateMachine::StateId start_jump_idle = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + StateMachine::StateId start_jump_right = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + StateMachine::StateId fly_up_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 7 + StateMachine::StateId fly_up_idle = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + StateMachine::StateId fly_up_right = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + StateMachine::StateId fall_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, horizontal_velocity)); /// 10 + StateMachine::StateId fall_idle = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, horizontal_velocity)); + StateMachine::StateId fall_right= machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, horizontal_velocity)); + int *attack_stage = new int(0); + StateMachine::StateId attack_left = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Left, attack_stage, horizontal_velocity)); + StateMachine::StateId attack_idle= machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Idle, attack_stage, horizontal_velocity)); + StateMachine::StateId attack_right = machine->add_state(std::make_shared(world, hero_id, Movement::Direction::Right, attack_stage, horizontal_velocity)); + + machine->add_transition(ground_idle, ground_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(ground_idle, ground_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(ground_right, ground_idle, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(ground_left, ground_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(ground_right, ground_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(ground_left, ground_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(ground_idle, jump_impulse, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(ground_right, jump_impulse, std::make_shared(sf::Keyboard::Space)); + machine->add_transition(ground_left, jump_impulse, std::make_shared(sf::Keyboard::Space)); + + machine->add_transition(jump_impulse, start_jump_idle, std::make_shared()); + machine->add_transition(start_jump_idle, start_jump_left , std::make_shared(sf::Keyboard::Left)); + machine->add_transition(start_jump_idle, start_jump_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(start_jump_left , start_jump_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(start_jump_right, start_jump_idle, std::make_shared(sf::Keyboard::Right)); + + + machine->add_transition(start_jump_left , fly_up_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); + machine->add_transition(start_jump_idle, fly_up_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); + machine->add_transition(start_jump_right, fly_up_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Jump)); + + machine->add_transition(fly_up_idle, fly_up_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(fly_up_idle, fly_up_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(fly_up_left, fly_up_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(fly_up_right, fly_up_idle, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(fly_up_left, fall_idle, std::make_shared(world, hero_id, 0)); + machine->add_transition(fly_up_idle, fall_idle, std::make_shared(world, hero_id, 0)); + machine->add_transition(fly_up_right, fall_idle, std::make_shared(world, hero_id, 0)); + + machine->add_transition(ground_left, fall_idle, std::vector>{std::make_shared(world, hero_id, 0.1), std::make_shared(hero_id, 0.2)}); + machine->add_transition(ground_idle, fall_idle, std::vector>{std::make_shared(world, hero_id, 0.1), std::make_shared(hero_id, 0.2)}); + machine->add_transition(ground_right, fall_idle, std::vector>{std::make_shared(world, hero_id, 0.1), std::make_shared(hero_id, 0.2)}); + + machine->add_transition(fall_idle, fall_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(fall_idle, fall_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(fall_left, fall_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(fall_right, fall_idle, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(fall_left, ground_idle, std::make_shared(hero_id)); + machine->add_transition(fall_idle, ground_idle, std::make_shared(hero_id)); + machine->add_transition(fall_right, ground_idle, std::make_shared(hero_id)); + + + machine->add_transition(ground_left, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(ground_idle, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(ground_right, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(start_jump_left, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(start_jump_idle, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(start_jump_right, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fly_up_left, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fly_up_idle, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fly_up_right, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fall_left, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fall_idle, attack_idle, std::make_shared(sf::Keyboard::Q)); + machine->add_transition(fall_right, attack_idle, std::make_shared(sf::Keyboard::Q)); + + machine->add_transition(attack_idle, attack_left, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(attack_left, attack_idle, std::make_shared(sf::Keyboard::Left)); + machine->add_transition(attack_idle, attack_right, std::make_shared(sf::Keyboard::Right)); + machine->add_transition(attack_right, attack_idle, std::make_shared(sf::Keyboard::Right)); + + machine->add_transition(attack_idle, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_beg, attack_stage)); + machine->add_transition(attack_left, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_beg, attack_stage)); + machine->add_transition(attack_right, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_beg, attack_stage)); + + machine->add_transition(attack_left, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_end, attack_stage)); + machine->add_transition(attack_idle, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_end, attack_stage)); + machine->add_transition(attack_right, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_1_end, attack_stage)); + + machine->add_transition(attack_idle, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_beg, attack_stage)); + machine->add_transition(attack_left, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_beg, attack_stage)); + machine->add_transition(attack_right, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_beg, attack_stage)); + + machine->add_transition(attack_left, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_end, attack_stage)); + machine->add_transition(attack_idle, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_end, attack_stage)); + machine->add_transition(attack_right, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_2_end, attack_stage)); + + machine->add_transition(attack_idle, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_beg, attack_stage)); + machine->add_transition(attack_left, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_beg, attack_stage)); + machine->add_transition(attack_right, attack_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_beg, attack_stage)); + + machine->add_transition(attack_left, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_end, attack_stage)); + machine->add_transition(attack_idle, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_end, attack_stage)); + machine->add_transition(attack_right, ground_idle, std::make_shared(hero_id, ImageStorage::TypeAction::Attack_3_end, attack_stage)); + + + + + + + + + machine->set_initial_state(0); + //controllers.push_back(machine); +} diff --git a/core/event/management/controller/statemachine/HeroStateMachine.hpp b/core/event/management/controller/statemachine/HeroStateMachine.hpp new file mode 100644 index 0000000..9b8b0f7 --- /dev/null +++ b/core/event/management/controller/statemachine/HeroStateMachine.hpp @@ -0,0 +1,16 @@ +#ifndef MAD_HEROSTATEMACHINE_HPP +#define MAD_HEROSTATEMACHINE_HPP + +#include "StateMachine.hpp" +#include "world/LocalWorld.hpp" +namespace mad::core{ + class HeroStateMachine : public StateMachine { + + public: + explicit HeroStateMachine(std::shared_ptr world, Vec2d position, int hero_id, std::shared_ptr level_dispatcher, float m_impulse, float horizontal_velocity); + }; +} + + + +#endif//MAD_HEROSTATEMACHINE_HPP diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 549dbc4..0ecc9ab 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -1,4 +1,5 @@ #include "LevelLoaderFromFile.hpp" +#include "event/management/controller/statemachine/HeroStateMachine.hpp" #include <../../game/mobs/hero/Hero.hpp> #include #include @@ -106,8 +107,8 @@ namespace mad::core { break; } case Objects::Hero: { - Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); - hero_id = hero.get_hero_id(); + // Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); + hero_id = create_hero(world, {current_position_x, current_position_y}); break; } case Objects::Enemy1: { @@ -158,8 +159,6 @@ namespace mad::core { std::filesystem::path source(m_config_json["animated_resources"]); source /= m_config_json["hero"]["source"]; - Entity::Id hero_id = 0; - std::shared_ptr image_storage; float physical_size_width = m_config_json["hero"]["animated"]["size_width"]; @@ -184,9 +183,74 @@ namespace mad::core { m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], physical_size_width, physical_size_height, size_scale, - delta_x, delta_y)}})); + delta_x, delta_y)}, + {ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], - hero_id = world->create_physical_entity( + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Fly_up, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], + + m_config_json["hero"]["animated"]["actions"]["fly_up"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Fall, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["fall"]["source"], + + m_config_json["hero"]["animated"]["actions"]["fall"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_1_beg, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_1_beg"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_1_beg"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_1_end, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_1_end"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_1_end"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_2_beg, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_2_beg"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_2_beg"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_2_end, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_2_end"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_2_end"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_3_beg, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_3_beg"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_3_beg"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_3_end, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["attack_3_end"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_3_end"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)} + } + )); + + Entity::Id hero_id = world->create_physical_entity( 0, position, 0, @@ -194,6 +258,16 @@ namespace mad::core { false, false ); + /// add sensor + auto m_entity = cast_to_or_null(world->get_storage().get_entity(hero_id)); + m_entity->add_sensor({0, 6}, 2.65, 0.05); + + float m_impulse = 2000; + float horizontal_velocity = 20; + + auto machine = std::make_shared(world, position, hero_id, level_dispatcher, m_impulse, horizontal_velocity); + controllers.push_back(machine); + return hero_id; } From b25cacda40a3df15eeba7f07c67781c10b7e3458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Wed, 1 Jun 2022 22:05:10 +0300 Subject: [PATCH 42/44] add slime files --- core/loader/LevelLoaderFromFile.cpp | 65 ++++++++++++++++++ core/loader/LevelLoaderFromFile.hpp | 2 + .../enemy/enemy_attack_beg/slime-attack-0.png | Bin 0 -> 356 bytes .../enemy/enemy_attack_beg/slime-attack-1.png | Bin 0 -> 354 bytes .../enemy/enemy_attack_beg/slime-attack-2.png | Bin 0 -> 477 bytes .../enemy/enemy_attack_beg/slime-attack-3.png | Bin 0 -> 442 bytes .../enemy/enemy_attack_end/slime-attack-4.png | Bin 0 -> 355 bytes .../enemy/enemy_idle/slime-idle-0.png | Bin 0 -> 385 bytes .../enemy/enemy_idle/slime-idle-1.png | Bin 0 -> 387 bytes .../enemy/enemy_idle/slime-idle-2.png | Bin 0 -> 359 bytes .../enemy/enemy_idle/slime-idle-3.png | Bin 0 -> 372 bytes .../animated/enemy/enemy_run/slime-move-0.png | Bin 0 -> 310 bytes .../animated/enemy/enemy_run/slime-move-1.png | Bin 0 -> 327 bytes .../animated/enemy/enemy_run/slime-move-2.png | Bin 0 -> 333 bytes .../animated/enemy/enemy_run/slime-move-3.png | Bin 0 -> 320 bytes game/resources/levels/level_01/config.json | 32 +++++++++ game/resources/levels/level_01/map | 2 +- 17 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 game/resources/animated/enemy/enemy_attack_beg/slime-attack-0.png create mode 100644 game/resources/animated/enemy/enemy_attack_beg/slime-attack-1.png create mode 100644 game/resources/animated/enemy/enemy_attack_beg/slime-attack-2.png create mode 100644 game/resources/animated/enemy/enemy_attack_beg/slime-attack-3.png create mode 100644 game/resources/animated/enemy/enemy_attack_end/slime-attack-4.png create mode 100644 game/resources/animated/enemy/enemy_idle/slime-idle-0.png create mode 100644 game/resources/animated/enemy/enemy_idle/slime-idle-1.png create mode 100644 game/resources/animated/enemy/enemy_idle/slime-idle-2.png create mode 100644 game/resources/animated/enemy/enemy_idle/slime-idle-3.png create mode 100644 game/resources/animated/enemy/enemy_run/slime-move-0.png create mode 100644 game/resources/animated/enemy/enemy_run/slime-move-1.png create mode 100644 game/resources/animated/enemy/enemy_run/slime-move-2.png create mode 100644 game/resources/animated/enemy/enemy_run/slime-move-3.png diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 0ecc9ab..9bedeb6 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -112,6 +112,7 @@ namespace mad::core { break; } case Objects::Enemy1: { + create_mob(world, {current_position_x, current_position_y}); break; } case Objects::Enemy2: { @@ -271,4 +272,68 @@ namespace mad::core { return hero_id; } + + void LevelLoaderFromFile::create_mob(std::shared_ptr world, Vec2d position) { + std::filesystem::path source(m_config_json["animated_resources"]); + source /= m_config_json["enemy"]["source"]; + + std::shared_ptr image_storage; + + float physical_size_width = m_config_json["enemy"]["animated"]["size_width"]; + float physical_size_height = m_config_json["enemy"]["animated"]["size_height"]; + float size_scale = m_config_json["enemy"]["animated"]["size_scale"]; + float delta_x = m_config_json["enemy"]["animated"]["delta_x"]; + float delta_y = m_config_json["enemy"]["animated"]["delta_y"]; + + + image_storage = std::make_shared( + std::unordered_map>( + {{ImageStorage::TypeAction::Idle, + std::make_shared( + source / m_config_json["enemy"]["animated"]["actions"]["idle"]["source"], + + m_config_json["enemy"]["animated"]["actions"]["idle"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Run, + std::make_shared( + source / m_config_json["enemy"]["animated"]["actions"]["run"]["source"], + + m_config_json["enemy"]["animated"]["actions"]["run"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_1_beg, + std::make_shared( + source / m_config_json["enemy"]["animated"]["actions"]["attack_beg"]["source"], + + m_config_json["enemy"]["animated"]["actions"]["attack_beg"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Attack_1_end, + std::make_shared( + source / m_config_json["enemy"]["animated"]["actions"]["attack_end"]["source"], + + m_config_json["hero"]["animated"]["actions"]["attack_end"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)} + } + )); + + Entity::Id enemy_id = world->create_physical_entity( + 0, + position, + 0, + image_storage, + false, false + ); + + + float m_impulse = 2000; + float horizontal_velocity = 20; + + auto machine = std::make_shared(world, position, enemy_id, level_dispatcher, m_impulse, horizontal_velocity); + controllers.push_back(machine); + + } + }// namespace mad::core \ No newline at end of file diff --git a/core/loader/LevelLoaderFromFile.hpp b/core/loader/LevelLoaderFromFile.hpp index 46d2f52..613566c 100644 --- a/core/loader/LevelLoaderFromFile.hpp +++ b/core/loader/LevelLoaderFromFile.hpp @@ -99,6 +99,8 @@ namespace mad::core { Entity::Id create_hero(std::shared_ptr world, Vec2d position); + void create_mob(std::shared_ptr world, Vec2d position); + private: enum class Objects { UnstableBlock, diff --git a/game/resources/animated/enemy/enemy_attack_beg/slime-attack-0.png b/game/resources/animated/enemy/enemy_attack_beg/slime-attack-0.png new file mode 100644 index 0000000000000000000000000000000000000000..b0c4d39bf7389ccee65c2443bb4f627654712308 GIT binary patch literal 356 zcmV-q0h|7bP)X1^@s6P!BAT0003iNkl1t~!NECXD7D2u&`Fo#(A~i?tN%a{gJUO$ir_zR4Ne_`i$iw{f&Kxp#SS5( zba60FU%YF3$pyhK_bh?q?t9;RzwZJLhr{7;?3hN~1LNr`x7~Ywd{9|`udZ-3$%?hb zEGE3X;K*wNaQl=J3_N6?YSv`NDuMBIl}D3|#Vpp=Mf@%M=IVO5aqj+ZSeOx_u&ZfS zCSVdzmvaE4IKb%P5rD(qnX!Ip0w!_QfDL}DQy2*bp4JZQ831@`e*o~AB=qT7pZhf% z6QQS3YCyexx}5WzymH#!r~hRyUPZIiK-g`l{k!o`{v^I_7Pcl3jNWrV>%HIV)av^> zG6zy$Uc*KLs<=3ouUe$8u<0cf(X1^@s6P!BAT0003gNkl1vcB@<{;(Ll-mKvieR#OzYR9CGLxl4Z@*GL7ON%vK_rnF;(zn(zmfm8_zv zTrd;s)Rlvj<_ZazdtATt?s@ON??9u`Xf&D=W9++dI$!0g|MuPHPS4rC;$W5muv~=r zqahcq1^~Br&j6T~T^e>fOsyN3&R2Ob%UCYLq9){@*&h#&FQw~D%f=rKi_idp-!%Xl zhsXt0a>01=T3T1Sfhu{L#41|=>$Y?pkHK||zS}fv&j7%C`x}6tD58g>ylx#fB)|g{ zhfqF!n#8HVt9ccC-`f!{Scj#qp?nU@F2<-ICzU@-p5fsNjqmR+mw+sMxo zN`_FD%1PxG)D@;ljC*sxQ5Vm!2q47ALIgND|L;|H>|Fzf{Qv*}07*qoM6N<$f^-I- A?EnA( literal 0 HcmV?d00001 diff --git a/game/resources/animated/enemy/enemy_attack_beg/slime-attack-2.png b/game/resources/animated/enemy/enemy_attack_beg/slime-attack-2.png new file mode 100644 index 0000000000000000000000000000000000000000..716ff73ddbe20434f52982e86b91bc9695265710 GIT binary patch literal 477 zcmV<30V4j1P)X1^@s6P!BAT0004`NklTQ8qY;XSwb|C#~($wPe~VGbT|607#R7 zjZG(G-1NKLd=h0GY!#R#fI&RVNtAJ>i{`ua8UWz*?3#^vM_mp^7lNClYyOgb;IiH2 z#!brx05lx;3#hJ@1WQ0=P9-wu=gi+HaJ7;U)&Kz9@4Ny4-iAXQzyScEu?WPpY@|s5 z0#`Y|MsJF{pH9XI@1Ex7?~Za25rnS30Xj{Cem?-XGWS<9ud3SOgNEb6v}~A`jpv8H zLGM>lngsBAqtafo1VEE`yuC00uxso19L1|j^fRa+H~`XV3M-aEn3jz=^tB~! zki8IxK0D)a=vM+LlMsOJ_@^qK23ZP1fKBSx0aQIf3P3tdgGRP@*k;kKdL%0YP!-LK zg{Z3{u&55C{{pW!%4OBQ&J={z?)64_ngrZ#MSsaET1<}i90s6jnd_FU>1|w}rt;Lw Tn7Xc900000NkvXXu0mjfU2W7A literal 0 HcmV?d00001 diff --git a/game/resources/animated/enemy/enemy_attack_beg/slime-attack-3.png b/game/resources/animated/enemy/enemy_attack_beg/slime-attack-3.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6ca49d3d63c791b143c0a6849118af28c8b5ce GIT binary patch literal 442 zcmV;r0Y(0aP)X1^@s6P!BAT0004jNklZ0F3GUyg?(YX$Sm{B@M1P41i2{%>4j+%U#~P-1FS~-U~D|G&KB2`rahX&c)a|X_X0^c97DyX$QX| z4gee3z`^N5%G?A1VBbGN)eVHc0|sMZ7LMDS%32HnK|j+RBnE(+<+mcch=|AZ7t5&P1*aRo#GCM=>jP#LLKa0kbqk z)eXEpT_~b(`=}$0Rm6)*A!UGBnqt~PN~1UEflS0vZ>c~Paxaq{hQ9M%j=B3fh-U%d kZz1;xYpJY2SzG=&U*>7jxj>IFhyVZp07*qoM6N<$g0b(#ga7~l literal 0 HcmV?d00001 diff --git a/game/resources/animated/enemy/enemy_attack_end/slime-attack-4.png b/game/resources/animated/enemy/enemy_attack_end/slime-attack-4.png new file mode 100644 index 0000000000000000000000000000000000000000..025a6609a73c1f27a3c7b951b627a6108774a9ae GIT binary patch literal 355 zcmeAS@N?(olHy`uVBq!ia0vp^3P3E$!3HD)_;n^SFfeL)x;Tb-bS5WAur5vz>1hfy zxWuSzcanGc{(tJ%A20;x?MXY#z-`wZ{-*xy0U-GB;*l5|5VTGAmpA%SW^SO-X=He( z`fvZj9a|V(=kM5J()1>0-n2F24S8BZu4Jix%oTjHMJ%gh4=yHn>IfIv-M?Zkt>rrX`@ zQ(&2qz>{)+f6cE6iMNkE=9zzf?&1?gNlyF^8;n@pENkU=xU}w&^sViC$RIJ{^7ll6 z>C@6d*x>7_WhV;0m|QSTv~za3&OBuk>tRL%cZGJgO^Gksgt9I58Yb!{=-KSe)$-z4 w@SHD*aaViT6itI93kKVY49)~Ti2?=&>3vP%YnzpXfq}>1>FVdQ&MBb@07%b=o&W#< literal 0 HcmV?d00001 diff --git a/game/resources/animated/enemy/enemy_idle/slime-idle-0.png b/game/resources/animated/enemy/enemy_idle/slime-idle-0.png new file mode 100644 index 0000000000000000000000000000000000000000..237a1e016cec2b8c05d1af5396c4412f936d4c7e GIT binary patch literal 385 zcmV-{0e=38P)X1^@s6P!BAT0003>qihrUX>YX1^@s6P!BAT0003>Nkl!`^#YTL<6*PzsAU}XVP)0$NsS`!w2ed9-L^KrXv1BP9KsdsMJ%4=qwZ@SH zfaCfAeq7)L3{B+fDFitHl3e5zd4}y~C9mmr{@&Ug!uxde9INQyjzN9bmIKx{r17dLlgj1}Mo zAspA2UELL2Ba%(1CUXOab4VB7Hk|eZ*b*ND^@|{{Kqps+3RP6kQQt*e&yfyLg92zQ hN@nx-C<+nxXb002ovPDHLkV1f_-pS%D7 literal 0 HcmV?d00001 diff --git a/game/resources/animated/enemy/enemy_idle/slime-idle-2.png b/game/resources/animated/enemy/enemy_idle/slime-idle-2.png new file mode 100644 index 0000000000000000000000000000000000000000..34383a0857343cb9bb743577a7a93b8703874d1b GIT binary patch literal 359 zcmV-t0hs=YP)X1^@s6P!BAT0003lNkl9hLXIHH0mwdHvHvy0ql;S@7#J8BX0#?V+T z<*?|$XDGTFWIjwDT@5@0aK#Y=1EdhaCr=K*S3J`d008R3fHZ%HQs@8x002ovPDHLk FV1i^FjV1s9 literal 0 HcmV?d00001 diff --git a/game/resources/animated/enemy/enemy_idle/slime-idle-3.png b/game/resources/animated/enemy/enemy_idle/slime-idle-3.png new file mode 100644 index 0000000000000000000000000000000000000000..fb4ac77d0741a9eb36bd660b8971d62dbe984b06 GIT binary patch literal 372 zcmV-)0gL{LP)X1^@s6P!BAT0003yNklYU6vlrBH|NqpjM4`%Q+)`@pqr!4Iye<4ac&WO1E)g93c1;i9Hgv=ea z4&`2M<30J)fG+uM$+;)rch7fkprN6mq2Zs|s7NgOd5+7F>P0a#_Ha;!u5_)@IN5f}%iu8H|9btv8{_T=u3& z-}se_=`>Hc4wK=P))gbjic8nXtY_Dl&#LZv{@NzB6DcEDork>oCP=^LKj#ObZGp3; S$CEbz0000w(bec z8}{_C3G=(pe$HJ_T0%nLDf2lSFO9E3TpUyROPCpi1hfy zxWuTulr6{N?^k=hoeaTwP0xhiGQ@~!b{ZM7s9ibubMIYV9uUy}w!iH{Dp$o@g%=Dn zjv6q_$KE+~00;uYCUhiPGBYzb@7Q7kq?nuM?BkE&nXeqd5qZxv(XQ>s>E-+zqxdE_ zH|R?69b_xm#WVlu5vC^>4v2D9I5V)7owiF%0D=qFAE#%WmXuKFYqew&PdKF3@#gn* ze|e*v+ZA(CPIt0K$TD~rYAFQugrzUpd8js!^MCk VyTxKAbAbWG;OXk;vd$@?2>^9Ic@F>p literal 0 HcmV?d00001 diff --git a/game/resources/animated/enemy/enemy_run/slime-move-2.png b/game/resources/animated/enemy/enemy_run/slime-move-2.png new file mode 100644 index 0000000000000000000000000000000000000000..327fb4a6d180c46e3436db660f8e24e6a86eaa40 GIT binary patch literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^3P3E$!3HD)_;n^SFffXEx;Tb-bS5WAur5vz>1hfy zxWuTuk;{C}zhCmRcTCa{KD_t({|&D=4W6oH*u}A)n6~c5|5=Sd@bKbMT^;L3W9-~-w0ekXaC@BbIS@xSREr<4z$UOKmZ<(_4rlb(=}ATWIz zh)S4n`Fmsc!(x^&PN!+Y%oAjr&NJ#9k=PdfjguJ&n(uY)cZocApyAC0T^_+${(p~) zScJ_SQ||At`86T&_OZt*k$zkUUNJ~C{9NR8rzeM-!&Nel{lKG%(-@XBPY5Gdzq1PefOUOz+htVboFyt=akR{0G4`#SpWb4 literal 0 HcmV?d00001 diff --git a/game/resources/animated/enemy/enemy_run/slime-move-3.png b/game/resources/animated/enemy/enemy_run/slime-move-3.png new file mode 100644 index 0000000000000000000000000000000000000000..ef83926146124e119908295a611c728d1e5f4184 GIT binary patch literal 320 zcmeAS@N?(olHy`uVBq!ia0vp^3P3E$!3HD)_;n^SFfg)vx;Tb-bS5WAur5vz>1hfy z;9`?75L%pZ_~rWl8#}c-jSTNp|K)eKIWT3mM)5~0hMSi}f5#ge0D;Y}9j%Q(uyBpS zL`Tmlor(qv`CR?;%b8F1B_2%u+4Xn*Louc1>HhLbTjzk3Wgn_x0|Cog`I@pt3_RBb zH_eey(9`XIG(j|#%fgv4n?s@b?k0Z;5cuNvNA*+@8(T_yo}z@5&kLp#`|5vwQ9Qh@ z_qgY#IUx-X86+BhE^@lllXJMU(`XJ~!%^k6jBbxQUQ~UU-^e)WX@_sg4TeqZA5`7e ztTbNq`e6N+7=`8Un@!UfL^t{JRynzpah!X@$juqWSQ9yU9RtI`fD}J7%Vj_o1B0il KpUXO@geCycvwHOa literal 0 HcmV?d00001 diff --git a/game/resources/levels/level_01/config.json b/game/resources/levels/level_01/config.json index 7189c6c..c97e902 100644 --- a/game/resources/levels/level_01/config.json +++ b/game/resources/levels/level_01/config.json @@ -81,5 +81,37 @@ } } } + }, + "enemy" : { + "source" : "enemy", + "animated" : { + "size_width": 5.5, + "size_height": 9, + "size_scale": 0.3, + "delta_x" : 0, + "delta_y" : 3, + "actions" : { + "idle" : { + "source": "enemy_idle", + "type": "several_files", + "delta_time": 200 + }, + "run" : { + "source": "enemy_run", + "type": "several_files", + "delta_time": 130 + }, + "attack_beg" : { + "source": "enemy_attack_beg", + "type": "several_files", + "delta_time": 30 + }, + "attack_end" : { + "source": "enemy_attack_end", + "type": "several_files", + "delta_time": 30 + } + } + } } } \ No newline at end of file diff --git a/game/resources/levels/level_01/map b/game/resources/levels/level_01/map index 846bc16..f3b1c65 100644 --- a/game/resources/levels/level_01/map +++ b/game/resources/levels/level_01/map @@ -8,4 +8,4 @@ ...#.#......## ###########.## ............## -............## \ No newline at end of file +............##= \ No newline at end of file From 0b95b65ab05f3ac88d2189409797b779161c0318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Wed, 1 Jun 2022 22:32:57 +0300 Subject: [PATCH 43/44] merge main --- core/loader/LevelLoaderFromFile.cpp | 79 +++++++--------- .../levels/level_with_finish/config.json | 93 +++++++++++++++++-- 2 files changed, 116 insertions(+), 56 deletions(-) diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index eca17a7..1c4a9e3 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -1,17 +1,17 @@ #include "LevelLoaderFromFile.hpp" +#include "event/management/condition/KeyDownCondition.hpp" +#include "event/management/condition/KeyPressedCondition.hpp" +#include "event/management/condition/TimerCondition.hpp" +#include "event/management/condition/TrueCondition.hpp" #include "event/management/controller/statemachine/HeroStateMachine.hpp" +#include "event/management/controller/statemachine/StateMachine.hpp" #include <../../game/mobs/hero/Hero.hpp> +#include #include #include #include #include #include -#include -#include "event/management/condition/KeyDownCondition.hpp" -#include "event/management/condition/KeyPressedCondition.hpp" -#include "event/management/condition/TimerCondition.hpp" -#include "event/management/condition/TrueCondition.hpp" -#include "event/management/controller/statemachine/StateMachine.hpp" #include @@ -33,8 +33,7 @@ namespace mad::core { Vec2d camera_position = {m_config_json["camera"]["position"]["x"], m_config_json["camera"]["position"]["y"]}; float camera_smoothness = m_config_json["camera"]["smoothness"]; - Camera::FollowType camera_type = m_config_json["camera"]["follow_type"] == "forward" ? - Camera::FollowType::Forward : Camera::FollowType::Backward; + Camera::FollowType camera_type = m_config_json["camera"]["follow_type"] == "forward" ? Camera::FollowType::Forward : Camera::FollowType::Backward; float minimal_distance = m_config_json["camera"]["minimal_distance"]; auto camera = std::make_shared(camera_position, world, true); @@ -43,7 +42,7 @@ namespace mad::core { camera)}; - Entity::Id hero_id = create_world(world); + //Entity::Id hero_id = create_world(world); auto keys = create_world(world); camera->turn_on(*level_dispatcher, keys[LevelLoaderFromFile::IdKeys::Hero], camera_smoothness, camera_type, minimal_distance); @@ -76,7 +75,7 @@ namespace mad::core { std::make_shared( camera)};*/ - camera->set_zoom(0.10); + camera->set_zoom(0.15); auto level_runner = std::make_unique( system_listener, @@ -105,7 +104,7 @@ namespace mad::core { create_background(world); while (std::getline(m_level_map, map_line)) { - for (char object: map_line) { + for (char object : map_line) { switch (m_objects[object]) { case Objects::UnstableBlock: { create_block(world, @@ -129,7 +128,7 @@ namespace mad::core { break; } case Objects::Hero: { - // Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); + // Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); hero_id = create_hero(world, {current_position_x, current_position_y}); break; } @@ -174,8 +173,7 @@ namespace mad::core { position, 0, image_storage, - is_stable - ); + is_stable); } Entity::Id LevelLoaderFromFile::create_hero(std::shared_ptr world, Vec2d position) { @@ -195,7 +193,14 @@ namespace mad::core { image_storage = std::make_shared( std::unordered_map>( - {{ImageStorage::TypeAction::Idle, + {{ImageStorage::TypeAction::Jump, + std::make_shared( + source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], + + m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], + physical_size_width, physical_size_height, size_scale, + delta_x, delta_y)}, + {ImageStorage::TypeAction::Idle, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["idle"]["source"], @@ -209,13 +214,6 @@ namespace mad::core { m_config_json["hero"]["animated"]["actions"]["run"]["delta_time"], physical_size_width, physical_size_height, size_scale, delta_x, delta_y)}, - {ImageStorage::TypeAction::Jump, - std::make_shared( - source / m_config_json["hero"]["animated"]["actions"]["jump"]["source"], - - m_config_json["hero"]["animated"]["actions"]["jump"]["delta_time"], - physical_size_width, physical_size_height, size_scale, - delta_x, delta_y)}, {ImageStorage::TypeAction::Fly_up, std::make_shared( source / m_config_json["hero"]["animated"]["actions"]["fly_up"]["source"], @@ -271,17 +269,14 @@ namespace mad::core { m_config_json["hero"]["animated"]["actions"]["attack_3_end"]["delta_time"], physical_size_width, physical_size_height, size_scale, - delta_x, delta_y)} - } - )); + delta_x, delta_y)}})); - Entity::Id hero_id = world->create_physical_entity( + hero_id = world->create_physical_entity( 0, position, 0, image_storage, - false, false - ); + false, false); /// add sensor auto m_entity = cast_to_or_null(world->get_storage().get_entity(hero_id)); @@ -339,17 +334,14 @@ namespace mad::core { m_config_json["hero"]["animated"]["actions"]["attack_end"]["delta_time"], physical_size_width, physical_size_height, size_scale, - delta_x, delta_y)} - } - )); + delta_x, delta_y)}})); Entity::Id enemy_id = world->create_physical_entity( 0, position, 0, image_storage, - false, false - ); + false, false); float m_impulse = 2000; @@ -357,10 +349,7 @@ namespace mad::core { auto machine = std::make_shared(world, position, enemy_id, level_dispatcher, m_impulse, horizontal_velocity); controllers.push_back(machine); - } - -}// namespace mad::core Entity::Id LevelLoaderFromFile::create_finish_block(std::shared_ptr world, Vec2d position, float block_size) { std::filesystem::path source("../../game/resources/static/"); source /= static_cast(m_config_json["texture"]["finish"]); @@ -370,16 +359,14 @@ namespace mad::core { {{ImageStorage::TypeAction::Idle, std::make_shared(source, block_size, block_size, - StaticImage::TransformType::Fit) - }})); + StaticImage::TransformType::Fit)}})); return world->create_physical_entity( 0, position, 0, image_storage, - true - ); + true); } void LevelLoaderFromFile::create_background(std::shared_ptr world) { @@ -394,17 +381,13 @@ namespace mad::core { std::make_shared( source, parallax_ratios, - m_config_json["background"]["scale"] - ) - }} - ) - ); + m_config_json["background"]["scale"])}})); world->create_viewable_entity( -1, {0, 0}, 0, - image_storage - ); + image_storage); } -} \ No newline at end of file + +}// namespace mad::core diff --git a/game/resources/levels/level_with_finish/config.json b/game/resources/levels/level_with_finish/config.json index a3b8ce0..391e191 100644 --- a/game/resources/levels/level_with_finish/config.json +++ b/game/resources/levels/level_with_finish/config.json @@ -1,7 +1,7 @@ { "name" : "level_with_finish", "animated_resources" : "../../game/resources/animated/", - "block" : 50.0, + "block" : 10.0, "camera": { "position" : { "x" : 10.0, @@ -26,21 +26,98 @@ "hero" : { "source" : "hero", "animated" : { - "size_width": 30, - "size_height": 50, - "size_scale": 0.2, + "size_width": 5.5, + "size_height": 9, + "size_scale": 0.3, "delta_x" : 0, - "delta_y" : 0, + "delta_y" : 3, "actions" : { "idle" : { - "source": "idle", + "source": "hero_idle", "type": "several_files", - "delta_time": 100 + "delta_time": 200 }, "run" : { - "source": "run", + "source": "hero_run", + "type": "several_files", + "delta_time": 130 + }, + "jump" : { + "source": "hero_jump", + "type": "several_files", + "delta_time": 50 + }, + "fly_up" : { + "source": "hero_fly_up", "type": "several_files", "delta_time": 100 + }, + "fall" : { + "source": "hero_fall", + "type": "several_files", + "delta_time": 130 + }, + "attack_1_beg" : { + "source": "hero_attack_1_beg", + "type": "several_files", + "delta_time": 30 + }, + "attack_1_end" : { + "source": "hero_attack_1_end", + "type": "several_files", + "delta_time": 30 + }, + "attack_2_beg" : { + "source": "hero_attack_2_beg", + "type": "several_files", + "delta_time": 30 + }, + "attack_2_end" : { + "source": "hero_attack_2_end", + "type": "several_files", + "delta_time": 30 + }, + "attack_3_beg" : { + "source": "hero_attack_3_beg", + "type": "several_files", + "delta_time": 30 + }, + "attack_3_end" : { + "source": "hero_attack_3_end", + "type": "several_files", + "delta_time": 30 + } + } + } + }, + "enemy" : { + "source" : "enemy", + "animated" : { + "size_width": 5.5, + "size_height": 9, + "size_scale": 0.3, + "delta_x" : 0, + "delta_y" : 3, + "actions" : { + "idle" : { + "source": "enemy_idle", + "type": "several_files", + "delta_time": 200 + }, + "run" : { + "source": "enemy_run", + "type": "several_files", + "delta_time": 130 + }, + "attack_beg" : { + "source": "enemy_attack_beg", + "type": "several_files", + "delta_time": 30 + }, + "attack_end" : { + "source": "enemy_attack_end", + "type": "several_files", + "delta_time": 30 } } } From f2a3d804404218e506d56ea96ce18f160fbe2d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=80=D0=BE=D0=BD?= Date: Wed, 1 Jun 2022 22:39:10 +0300 Subject: [PATCH 44/44] merge main --- core/loader/LevelLoaderFromFile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/core/loader/LevelLoaderFromFile.cpp b/core/loader/LevelLoaderFromFile.cpp index 1c4a9e3..fbe8805 100644 --- a/core/loader/LevelLoaderFromFile.cpp +++ b/core/loader/LevelLoaderFromFile.cpp @@ -130,6 +130,7 @@ namespace mad::core { case Objects::Hero: { // Hero hero(world, {current_position_x, current_position_y}, m_config_json, level_dispatcher, controllers); hero_id = create_hero(world, {current_position_x, current_position_y}); + keys[LevelLoaderFromFile::IdKeys::Hero] = hero_id; break; } case Objects::Enemy1: {