From 6e6dd0418df552aee35281f128d1c8d884dac4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9au?= <theau.baton@etu.univ-amu.fr> Date: Sun, 19 Jan 2025 23:12:30 +0100 Subject: [PATCH] Remake Linkers --- CMakelists.txt | 18 +++---- .../engine/graphics/front/engine/Engine.cpp | 9 ++++ .../engine/graphics/front/engine/Engine.hpp | 5 +- source/engine/graphics/front/engine/Layer.hpp | 18 +++++-- source/engine/graphics/front/object/Text.cpp | 3 -- source/engine/physic/front/engine/Engine.cpp | 20 +++++++ source/engine/physic/front/engine/Engine.hpp | 3 ++ .../engine/physic/front/object/Tangible.cpp | 4 +- .../engine/physic/front/object/Tangible.hpp | 2 +- source/game/Game.cpp | 24 +++++++-- source/game/back/GameObject.hpp | 7 ++- source/game/back/message/Receiver.hpp | 17 ------ source/game/back/object/Enemy.cpp | 33 ++++++++++++ source/game/back/object/Enemy.hpp | 22 ++++++++ source/game/back/object/Level.cpp | 18 +++++++ source/game/back/object/Level.hpp | 21 ++++++++ source/game/back/object/Player.cpp | 34 ++++++++++++ source/game/back/object/Player.hpp | 22 ++++++++ source/game/back/object/Terrain.hpp | 14 ----- source/game/front/profile/PlayerKeys.cpp | 24 +++++++++ source/game/front/profile/PlayerKeys.hpp | 18 +++++++ source/kernel/back/component/Component.hpp | 1 + source/kernel/back/component/Physical.hpp | 4 +- source/kernel/back/engine/Engine.hpp | 1 + source/kernel/back/engine/GraphicEngine.cpp | 4 ++ source/kernel/back/engine/GraphicEngine.hpp | 1 + source/kernel/back/engine/PhysicEngine.cpp | 4 ++ source/kernel/back/engine/PhysicEngine.hpp | 1 + source/kernel/back/linker/GraphicLinker.hpp | 16 ++++-- source/kernel/back/linker/GraphicLinker.tpp | 54 ++++++++++++++++--- source/kernel/back/linker/PriorityPair.hpp | 17 ------ source/kernel/back/linker/RenderTrace.hpp | 17 ++++++ source/kernel/back/linker/UniqueLinker.hpp | 16 ++++-- source/kernel/back/linker/UniqueLinker.tpp | 33 ++++++++---- source/kernel/front/Kernel.cpp | 16 ++++++ source/kernel/front/Kernel.hpp | 5 +- .../kernel/front/component/graphic/Sprite.cpp | 5 ++ .../kernel/front/component/graphic/Sprite.hpp | 1 + .../front/component/graphic/TileMap.cpp | 5 ++ .../front/component/graphic/TileMap.hpp | 1 + .../kernel/front/component/physic/Fixed.cpp | 10 ++-- .../kernel/front/component/physic/Fixed.hpp | 10 ++-- .../front/component/physic/FixedArray.cpp | 14 ++++- .../front/component/physic/FixedArray.hpp | 7 +-- .../kernel/front/component/physic/Movable.cpp | 12 +++-- .../kernel/front/component/physic/Movable.hpp | 7 +-- source/kernel/front/props/PropsPlayable.cpp | 18 +++++++ source/kernel/front/props/PropsPlayable.hpp | 29 ++++++++++ source/kernel/front/resolver/Resolver.hpp | 2 +- source/kernel/front/resolver/Resolver.tpp | 5 +- source/main.cpp | 50 +---------------- source/utility/Identifiable.cpp | 4 +- source/utility/Identifiable.hpp | 2 +- 53 files changed, 525 insertions(+), 183 deletions(-) delete mode 100644 source/game/back/message/Receiver.hpp create mode 100644 source/game/back/object/Enemy.cpp create mode 100644 source/game/back/object/Enemy.hpp create mode 100644 source/game/back/object/Level.cpp create mode 100644 source/game/back/object/Level.hpp create mode 100644 source/game/back/object/Player.cpp create mode 100644 source/game/back/object/Player.hpp delete mode 100644 source/game/back/object/Terrain.hpp create mode 100644 source/game/front/profile/PlayerKeys.cpp create mode 100644 source/game/front/profile/PlayerKeys.hpp delete mode 100644 source/kernel/back/linker/PriorityPair.hpp create mode 100644 source/kernel/back/linker/RenderTrace.hpp create mode 100644 source/kernel/front/props/PropsPlayable.cpp create mode 100644 source/kernel/front/props/PropsPlayable.hpp diff --git a/CMakelists.txt b/CMakelists.txt index e7bfb4c..2de7e4f 100644 --- a/CMakelists.txt +++ b/CMakelists.txt @@ -59,21 +59,17 @@ set_property(TARGET ${CURRENT_TARGET} PROPERTY RUNTIME_OUTPUT_DIRECTORY $<1:${CM target_include_directories(${CURRENT_TARGET} PRIVATE ${INCLUDE}) -#list(APPEND CMAKE_PREFIX_PATH "/amuhome/b20017738/Bureau/vcpkg/packages/glew_x64-linux") -#list(APPEND CMAKE_PREFIX_PATH "/amuhome/b20017738/Bureau/vcpkg/packages/glm_x64-linux") -#list(APPEND CMAKE_PREFIX_PATH "/amuhome/b20017738/Bureau/vcpkg/packages/imgui_x64-linux") +list(APPEND CMAKE_PREFIX_PATH "/amuhome/b20017738/Bureau/vcpkg/packages/glew_x64-linux") +list(APPEND CMAKE_PREFIX_PATH "/amuhome/b20017738/Bureau/vcpkg/packages/glm_x64-linux") +list(APPEND CMAKE_PREFIX_PATH "/amuhome/b20017738/Bureau/vcpkg/packages/imgui_x64-linux") -list(APPEND CMAKE_PREFIX_PATH "C:/vcpkg/packages/freetype_x64-windows") - -find_package(glfw3 REQUIRED) -find_package(GLEW REQUIRED) -find_package(glm CONFIG REQUIRED) -find_package(imgui REQUIRED) -find_package(Freetype REQUIRED) +find_package(glfw3 REQUIRED) +find_package(GLEW REQUIRED) +find_package(glm CONFIG REQUIRED) +find_package(imgui REQUIRED) target_link_libraries(${CURRENT_TARGET} PRIVATE glfw) target_link_libraries(${CURRENT_TARGET} PRIVATE GLEW::GLEW) target_link_libraries(${CURRENT_TARGET} PRIVATE glm::glm-header-only) target_link_libraries(${CURRENT_TARGET} PRIVATE imgui::imgui) -target_link_libraries(${CURRENT_TARGET} PRIVATE Freetype::Freetype) diff --git a/source/engine/graphics/front/engine/Engine.cpp b/source/engine/graphics/front/engine/Engine.cpp index 9adda5a..a7dc5a5 100644 --- a/source/engine/graphics/front/engine/Engine.cpp +++ b/source/engine/graphics/front/engine/Engine.cpp @@ -24,6 +24,15 @@ namespace megu { } } + void GraphicEngine::remove(const Identifiable & identifiable) { + for(auto & [priority, layer] : this->_layers) { + auto r = layer.get()->get(identifiable); + if(r.has_value()) { + layer.get()->remove(identifiable); + } + } + } + std::optional<std::reference_wrapper<const Layer>> GraphicEngine::get(Priority priority) const { const auto it = this->_layers.find(priority); if(it != this->_layers.end()) { diff --git a/source/engine/graphics/front/engine/Engine.hpp b/source/engine/graphics/front/engine/Engine.hpp index f85a336..38dce9f 100644 --- a/source/engine/graphics/front/engine/Engine.hpp +++ b/source/engine/graphics/front/engine/Engine.hpp @@ -19,8 +19,8 @@ namespace megu { void push(Priority, Renderer &); template <class T> - void push(Priority layer_priority, Priority object_priority, T & object, Module<T> * modul) { - this->_layers[layer_priority].get()->push<T>(object_priority, object, modul); + size_t push(Priority layer_priority, Priority object_priority, T & object, Module<T> * modul) { + return this->_layers[layer_priority].get()->push<T>(object_priority, object, modul); } /*void push(Priority layer_priority, Priority object_priority, Renderable & renderable) { @@ -28,6 +28,7 @@ namespace megu { }*/ void remove(Priority); + void remove(const Identifiable &); std::optional<std::reference_wrapper<const Layer>> get(Priority) const; std::optional<std::reference_wrapper<const Renderable>> get(const Identifiable &) const; diff --git a/source/engine/graphics/front/engine/Layer.hpp b/source/engine/graphics/front/engine/Layer.hpp index 5b6feba..3efa4dd 100644 --- a/source/engine/graphics/front/engine/Layer.hpp +++ b/source/engine/graphics/front/engine/Layer.hpp @@ -26,16 +26,23 @@ namespace megu { inline const Renderer & renderer() const {return this->_renderer;} template <class T> - void push(Priority priority, T & object, Module<T> * modul) { - if(this->_objects.contains(priority)) { + size_t push(Priority priority, T & object, Module<T> * modul) { + + if(!this->_objects.contains(priority)) { this->_objects.erase(priority); } this->_objects.insert({priority, Renderable{ object, modul }}); + return this->_objects.at(priority).id(); } - /*void push(Priority priority, Renderable & renderable) { - this->_objects[priority] = renderable; - }*/ + void remove(const Identifiable & identifiable) { + for(auto & [priority, renderable] : this->_objects) { + if(renderable.id() == identifiable.id()) { + this->_objects.erase(priority); + break; + } + } + } std::optional<std::reference_wrapper<const Renderable>> get(const Identifiable & id) const { for(const auto & [priority, object] : this->_objects) { @@ -43,6 +50,7 @@ namespace megu { return object; } } + return {}; } const Texture & draw(const Window & w, const TextureArray & a) { diff --git a/source/engine/graphics/front/object/Text.cpp b/source/engine/graphics/front/object/Text.cpp index ff65d54..6b16ea6 100644 --- a/source/engine/graphics/front/object/Text.cpp +++ b/source/engine/graphics/front/object/Text.cpp @@ -1,9 +1,6 @@ #include "Text.hpp" #include <exception> -#include <ft2build.h> -#include FT_FREETYPE_H - #include <iostream> namespace megu { diff --git a/source/engine/physic/front/engine/Engine.cpp b/source/engine/physic/front/engine/Engine.cpp index 6aa664b..d32f1b3 100644 --- a/source/engine/physic/front/engine/Engine.cpp +++ b/source/engine/physic/front/engine/Engine.cpp @@ -19,6 +19,26 @@ namespace megu { } } + void PhysicEngine::remove(TangibleStatic & t) { + for(auto & [p, objs] : this->_statics) { + auto it = std::find(objs.begin(), objs.end(), t); + if(it != objs.end()) { + objs.erase(it); + break; + } + } + } + + void PhysicEngine::remove(TangibleMovable & t) { + for(auto & [p, objs] : this->_dynamic) { + auto it = std::find(objs.begin(), objs.end(), t); + if(it != objs.end()) { + objs.erase(it); + break; + } + } + } + void PhysicEngine::step(double time) { this->_collisions.clear(); for(const auto & [priority, layer] : this->_dynamic) { diff --git a/source/engine/physic/front/engine/Engine.hpp b/source/engine/physic/front/engine/Engine.hpp index b1db159..23b08fc 100644 --- a/source/engine/physic/front/engine/Engine.hpp +++ b/source/engine/physic/front/engine/Engine.hpp @@ -22,6 +22,9 @@ namespace megu { void push(Priority, TangibleStatic &); void push(Priority, TangibleMovable &); + void remove(TangibleStatic &); + void remove(TangibleMovable &); + void step(double); void step(double, Priority); diff --git a/source/engine/physic/front/object/Tangible.cpp b/source/engine/physic/front/object/Tangible.cpp index f514928..eb6b3df 100644 --- a/source/engine/physic/front/object/Tangible.cpp +++ b/source/engine/physic/front/object/Tangible.cpp @@ -15,7 +15,7 @@ namespace megu { return this->_box == entity._box; } - bool Tangible::operator!=(const Tangible & entity) const { + /*bool Tangible::operator!=(const Tangible & entity) const { return !(*this == entity); - } + }*/ } \ No newline at end of file diff --git a/source/engine/physic/front/object/Tangible.hpp b/source/engine/physic/front/object/Tangible.hpp index 926a4ca..8345cf5 100644 --- a/source/engine/physic/front/object/Tangible.hpp +++ b/source/engine/physic/front/object/Tangible.hpp @@ -27,7 +27,7 @@ namespace megu { bool isColliding(const Tangible &) const; bool operator==(const Tangible &) const; - bool operator!=(const Tangible &) const; + //bool operator!=(const Tangible &) const; using UpdateLambda = std::function<void(double)>; diff --git a/source/game/Game.cpp b/source/game/Game.cpp index 65d0899..badff2f 100644 --- a/source/game/Game.cpp +++ b/source/game/Game.cpp @@ -2,11 +2,13 @@ #include <kernel/front/Kernel.hpp> -#include <engine/io/Window.hpp> -#include <game/utility/FrameCouter.hpp> +#include <game/back/object/Player.hpp> +#include <game/back/object/Enemy.hpp> #include <game/object/Test.hpp> +#include <game/utility/FrameCouter.hpp> + namespace megu::game { Game::Game(const std::string & title) : _title(title) { @@ -22,13 +24,29 @@ namespace megu::game { kernel::Kernel kernel(window); auto path = std::filesystem::path("assets/textures/Neera.png"); megu::game::Object object(path); - kernel.add(&object); + //kernel.add(&object); + + Player player(16, 16, 16, 16, path); + Enemy enemy(64, 64, 16, 16, path); + + player.setup(kernel); + enemy.setup(kernel); + + std::cout << "..." << std::endl; + + player.apply(kernel); + enemy.apply(kernel); + + //kernel.remove(&object); while(window.isOpen()) { counter.count(Window::Time()); window.pollEvents(); kernel.step(); } + + player.destroy(kernel); + enemy.destroy(kernel); } catch(std::exception & error) { std::cerr << "[Error] : " << error.what() << std::endl; diff --git a/source/game/back/GameObject.hpp b/source/game/back/GameObject.hpp index a2c7fd7..29ec8a7 100644 --- a/source/game/back/GameObject.hpp +++ b/source/game/back/GameObject.hpp @@ -1,9 +1,12 @@ #pragma once +#include <kernel/front/Kernel.hpp> + namespace megu::game { class GameObject { public: - virtual void setup() = 0; - virtual void destroy() = 0; + virtual void setup(kernel::Kernel &) = 0; + virtual void destroy(kernel::Kernel &) = 0; + virtual void apply(kernel::Kernel &) = 0; }; } \ No newline at end of file diff --git a/source/game/back/message/Receiver.hpp b/source/game/back/message/Receiver.hpp deleted file mode 100644 index 326864a..0000000 --- a/source/game/back/message/Receiver.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include <game/back/GameObject.hpp> - -namespace megu::game { - class Message; - - class Collider : public GameObject { - public: - Collider<> - - virtual void setup(); - - virtual void on(Message &); - virtual Message make() - }; -} \ No newline at end of file diff --git a/source/game/back/object/Enemy.cpp b/source/game/back/object/Enemy.cpp new file mode 100644 index 0000000..f635637 --- /dev/null +++ b/source/game/back/object/Enemy.cpp @@ -0,0 +1,33 @@ +#include "Enemy.hpp" + +#include <kernel/front/Kernel.hpp> + +namespace megu::game { + Enemy::Enemy(float x, float y, float w, float h, std::filesystem::path & path) + : kernel::PropsDynamic(this->_sprite, this->_movable), _sprite(path), _movable(x, y, w, h) { + this->_sprite.setPosition({x, y}); + } + + void Enemy::move(float x, float y) { + this->_movable.move(x, y); + this->_movable.move(x, y); + } + + void Enemy::setup(kernel::Kernel &) { + this->_sprite.setFrame({0.f, 0.f, 51.f, 98.f}); + this->_sprite.setSize({51.f, 98.f}); + + this->_movable.setCollideLambda([this](kernel::Kernel & kernel, const kernel::PhysicEngine &, const megu::kernel::Physical<kernel::PhysicEngine> &, double) { + std::cout << "Enemy Collide !" << std::endl; + kernel.remove(this); + }); + } + + void Enemy::destroy(kernel::Kernel &) { + + } + + void Enemy::apply(kernel::Kernel & kernel) { + kernel.add(this); + } +} \ No newline at end of file diff --git a/source/game/back/object/Enemy.hpp b/source/game/back/object/Enemy.hpp new file mode 100644 index 0000000..f3d240d --- /dev/null +++ b/source/game/back/object/Enemy.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include <game/back/GameObject.hpp> +#include <kernel/front/props/PropsDynamic.hpp> + +namespace megu::game { + class Enemy : public kernel::PropsDynamic, public GameObject { + public: + Enemy(float, float, float, float, std::filesystem::path &); + + void move(float, float); + + void setup(kernel::Kernel &) override; + void destroy(kernel::Kernel &) override; + + void apply(kernel::Kernel &) override; + + private: + kernel::Sprite _sprite; + kernel::Movable _movable; + }; +} \ No newline at end of file diff --git a/source/game/back/object/Level.cpp b/source/game/back/object/Level.cpp new file mode 100644 index 0000000..844932b --- /dev/null +++ b/source/game/back/object/Level.cpp @@ -0,0 +1,18 @@ +#include "Level.hpp" + +namespace megu::game { + Level::Level(const std::string & name) + : _name(name) {} + + void Level::apply(kernel::Kernel & kernel) { + for(auto & [id, prop] : this->_objecs) { + kernel.add(prop); + } + } + + void Level::destroy(kernel::Kernel & kernel) { + for(auto & [id, prop] : this->_objecs) { + kernel.remove(prop); + } + } +} \ No newline at end of file diff --git a/source/game/back/object/Level.hpp b/source/game/back/object/Level.hpp new file mode 100644 index 0000000..7e7a1eb --- /dev/null +++ b/source/game/back/object/Level.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include <game/back/GameObject.hpp> +#include <kernel/front/props/Props.hpp> + +namespace megu::game { + class Level : public GameObject { + private: + Level(const std::string &); + + inline const std::string & name() const {return this->_name;} + + virtual void apply(kernel::Kernel &) override final; + virtual void destroy(kernel::Kernel &) override final; + + public: + std::string _name; + std::map<size_t, kernel::Prop *> _objecs; + + }; +} \ No newline at end of file diff --git a/source/game/back/object/Player.cpp b/source/game/back/object/Player.cpp new file mode 100644 index 0000000..6e01644 --- /dev/null +++ b/source/game/back/object/Player.cpp @@ -0,0 +1,34 @@ +#include "Player.hpp" + +#include <game/front/profile/PlayerKeys.hpp> + +namespace megu::game { + Player::Player(float x, float y, float w, float h, std::filesystem::path & path) + : kernel::PropsPlayable(this->_sprite, this->_movable), _sprite(path), _movable(x, y, w, h) { + this->_sprite.setPosition({x, y}); + } + + void Player::move(float x, float y) { + this->_sprite.move({x, y}); + this->_movable.move(x, y); + } + + void Player::setup(kernel::Kernel & kernel) { + this->setControl(kernel.window(), new PlayerKeyProfile(*this)); + + this->_sprite.setFrame({0.f, 0.f, 51.f, 98.f}); + this->_sprite.setSize({51.f, 98.f}); + + this->_movable.setCollideLambda([](kernel::Kernel &, const kernel::PhysicEngine &, const megu::kernel::Physical<kernel::PhysicEngine> &, double) { + std::cout << "Player Collide !" << std::endl; + }); + } + + void Player::destroy(kernel::Kernel &) { + + } + + void Player::apply(kernel::Kernel & kernel) { + kernel.add(this); + } +} \ No newline at end of file diff --git a/source/game/back/object/Player.hpp b/source/game/back/object/Player.hpp new file mode 100644 index 0000000..74c7be8 --- /dev/null +++ b/source/game/back/object/Player.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include <kernel/front/props/PropsPlayable.hpp> +#include <game/back/GameObject.hpp> + +namespace megu::game { + class Player : public kernel::PropsPlayable, public GameObject { + public: + Player(float x, float y, float w, float h, std::filesystem::path &); + + void move(float, float); + + void setup(kernel::Kernel &) override; + void destroy(kernel::Kernel &) override; + + void apply(kernel::Kernel &) override; + + private: + kernel::Sprite _sprite; + kernel::Movable _movable; + }; +} \ No newline at end of file diff --git a/source/game/back/object/Terrain.hpp b/source/game/back/object/Terrain.hpp deleted file mode 100644 index 0058a3c..0000000 --- a/source/game/back/object/Terrain.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include <kernel/front/props/PropsTileMap.hpp> - -namespace megu::game { - class Terrain : public kernel::PropsTileMap { - public: - Terrain(float, float); - - private: - kernel::Tilemap _graphicMap; - kernel::FixedArray _solidMap; - }; -} \ No newline at end of file diff --git a/source/game/front/profile/PlayerKeys.cpp b/source/game/front/profile/PlayerKeys.cpp new file mode 100644 index 0000000..3d835a9 --- /dev/null +++ b/source/game/front/profile/PlayerKeys.cpp @@ -0,0 +1,24 @@ +#include "PlayerKeys.hpp" + +namespace megu::game { + PlayerKeyProfile::PlayerKeyProfile(Player & player) + : _player(player) {} + + void PlayerKeyProfile::on(Key key, int code, Action action, Mod mode) { + if(key == Keyboard::Key::ARROW_UP) { + this->_player.move(0.f, 1.f); + } + + if(key == Keyboard::Key::ARROW_DOWN) { + this->_player.move(0.f, -1.f); + } + + if(key == Keyboard::Key::ARROW_LEFT) { + this->_player.move(-1.f, 0.f); + } + + if(key == Keyboard::Key::ARROW_RIGHT) { + this->_player.move(1.f, 0.f); + } + } +} \ No newline at end of file diff --git a/source/game/front/profile/PlayerKeys.hpp b/source/game/front/profile/PlayerKeys.hpp new file mode 100644 index 0000000..47b5301 --- /dev/null +++ b/source/game/front/profile/PlayerKeys.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include <game/back/object/Player.hpp> + +#include <engine/io/Keyboard.hpp> +#include <engine/io/Mouse.hpp> + +namespace megu::game { + class PlayerKeyProfile : public Keyboard { + public: + PlayerKeyProfile(Player &); + + virtual void on(Key, int, Action, Mod); + + private: + Player & _player; + }; +} \ No newline at end of file diff --git a/source/kernel/back/component/Component.hpp b/source/kernel/back/component/Component.hpp index 2a3538a..b95d280 100644 --- a/source/kernel/back/component/Component.hpp +++ b/source/kernel/back/component/Component.hpp @@ -10,5 +10,6 @@ namespace megu::kernel { class Component : public virtual Identifiable { public: virtual void apply(Kernel & k, E &) = 0; + virtual void unapply(Kernel & k, E &) = 0; }; } \ No newline at end of file diff --git a/source/kernel/back/component/Physical.hpp b/source/kernel/back/component/Physical.hpp index 23028af..3db5579 100644 --- a/source/kernel/back/component/Physical.hpp +++ b/source/kernel/back/component/Physical.hpp @@ -9,8 +9,8 @@ namespace megu::kernel { template <class Pe> class Physical : public Component<Pe> { public: - virtual void on_collide(const Kernel &, const Pe &, Physical &, double) = 0; + virtual void on_collide(Kernel &, const Pe &, Physical &, double) = 0; - using CollideLambda = std::function<void(const Kernel &, const Pe &, const Physical &, double)>; + using CollideLambda = std::function<void(Kernel &, const Pe &, const Physical &, double)>; }; } \ No newline at end of file diff --git a/source/kernel/back/engine/Engine.hpp b/source/kernel/back/engine/Engine.hpp index b69f67f..8842381 100644 --- a/source/kernel/back/engine/Engine.hpp +++ b/source/kernel/back/engine/Engine.hpp @@ -15,5 +15,6 @@ namespace megu::kernel { virtual const O & get(const C &) const = 0; virtual void add(Kernel &, C &) = 0; + virtual void remove(Kernel &, C &) = 0; }; } \ No newline at end of file diff --git a/source/kernel/back/engine/GraphicEngine.cpp b/source/kernel/back/engine/GraphicEngine.cpp index 2ee0f70..efb8418 100644 --- a/source/kernel/back/engine/GraphicEngine.cpp +++ b/source/kernel/back/engine/GraphicEngine.cpp @@ -22,6 +22,10 @@ namespace megu::kernel { graphical.apply(kernel, *this); } + void GraphicEngine::remove(Kernel & kernel, Graphical<GraphicEngine> & graphical) { + graphical.unapply(kernel, *this); + } + const Renderable & GraphicEngine::get(const Graphical<GraphicEngine> & graphical) const { auto object = this->_engine.get(graphical); if(object.has_value()) { diff --git a/source/kernel/back/engine/GraphicEngine.hpp b/source/kernel/back/engine/GraphicEngine.hpp index d0d9811..77ce58f 100644 --- a/source/kernel/back/engine/GraphicEngine.hpp +++ b/source/kernel/back/engine/GraphicEngine.hpp @@ -24,6 +24,7 @@ namespace megu::kernel { void step(Kernel &, double) override; void add(Kernel &, Graphical<GraphicEngine> &) override; + void remove(Kernel &, Graphical<GraphicEngine> &) override; const megu::Renderable & get(const Graphical<GraphicEngine> &) const override; diff --git a/source/kernel/back/engine/PhysicEngine.cpp b/source/kernel/back/engine/PhysicEngine.cpp index 25e1c3a..26476f5 100644 --- a/source/kernel/back/engine/PhysicEngine.cpp +++ b/source/kernel/back/engine/PhysicEngine.cpp @@ -22,6 +22,10 @@ namespace megu::kernel { props.apply(kernel, *this); } + void PhysicEngine::remove(Kernel & kernel, Physical<PhysicEngine> & props) { + props.unapply(kernel, *this); + } + const megu::Tangible & PhysicEngine::get(const Physical<PhysicEngine> & props) const { auto tangible = this->_engine.get(props); if(tangible.has_value()) { diff --git a/source/kernel/back/engine/PhysicEngine.hpp b/source/kernel/back/engine/PhysicEngine.hpp index 7a7f441..5992197 100644 --- a/source/kernel/back/engine/PhysicEngine.hpp +++ b/source/kernel/back/engine/PhysicEngine.hpp @@ -17,6 +17,7 @@ namespace megu::kernel { void step(Kernel &, double) override; void add(Kernel &, Physical<PhysicEngine> &) override; + void remove(Kernel &, Physical<PhysicEngine> &) override; const megu::Tangible & get(const Physical<PhysicEngine> &) const override; diff --git a/source/kernel/back/linker/GraphicLinker.hpp b/source/kernel/back/linker/GraphicLinker.hpp index 12d87d0..a4947a8 100644 --- a/source/kernel/back/linker/GraphicLinker.hpp +++ b/source/kernel/back/linker/GraphicLinker.hpp @@ -1,9 +1,11 @@ #pragma once #include "Linker.hpp" -#include "PriorityPair.hpp" #include <kernel/back/engine/GraphicEngine.hpp> +#include <stack> +#include "RenderTrace.hpp" + namespace megu::kernel { template <class T> class GraphicLinker : public Linker<GraphicEngine> { @@ -11,17 +13,21 @@ namespace megu::kernel { GraphicLinker(); void link(T &, Priority, Priority); + void unlink(T &); + void link(GraphicEngine &) override; void setModule(Module<ref_set<T>> *); inline bool haveModule() const {return this->_module.get() != nullptr;} - inline ref_set<T> & objects() {return this->_object;} private: std::unique_ptr<Module<ref_set<T>>> _module; - std::map<Priority_Pair, ref_set<T>> _objects; - std::set<Priority_Pair> _waiting; + + std::map<RenderTrace, ref_set<T>> _stored; + std::map<RenderTrace, size_t> _ids; + std::set<RenderTrace> _await; + std::set<RenderTrace> _delete; }; } -#include "GraphicLinker.tpp" \ No newline at end of file +#include "GraphicLinker.tpp" diff --git a/source/kernel/back/linker/GraphicLinker.tpp b/source/kernel/back/linker/GraphicLinker.tpp index 2fccee8..28c72be 100644 --- a/source/kernel/back/linker/GraphicLinker.tpp +++ b/source/kernel/back/linker/GraphicLinker.tpp @@ -7,23 +7,61 @@ namespace megu::kernel { template <class T> void GraphicLinker<T>::link(T & object, Priority l, Priority o) { - auto layers = Priority_Pair{l, o}; - - this->_objects[layers].insert(object); - this->_waiting.insert(layers); + auto layers = RenderTrace{l, o}; + this->_stored[layers].insert(object); + this->_await.insert(layers); } template <class T> void GraphicLinker<T>::link(GraphicEngine & engine) { - for(const auto & layers : this->_waiting) { - engine.get().push(layers.layer, layers.object, this->_objects[layers], this->_module.get()); + for(const auto & layer : this->_delete) { + engine.get().remove(Identifiable(this->_ids[layer])); } - this->_waiting.clear(); + this->_delete.clear(); + + for(auto & layer : this->_await) { + size_t id = engine.get().push(layer.layer, layer.object, this->_stored[layer], this->_module.get()); + this->_ids[layer] = id; + } + + this->_await.clear(); + } + + template <class T> + void GraphicLinker<T>::unlink(T & object) { + for(auto it = this->_stored.begin(); it != this->_stored.end();) { + bool contains = false; + for(auto its = it->second.begin(); its != it->second.end();) { + if(&(its->get()) == &object) { + contains = true; + it->second.erase(its); + break; + } + else { + ++its; + } + } + + if(contains) { + this->_delete.insert(it->first); + this->_await.insert(it->first); + if(it->second.empty()) { + it = this->_stored.erase(it); + } + else { + ++it; + } + break; + } + else { + ++it; + } + } } template <class T> void GraphicLinker<T>::setModule(Module<ref_set<T>> * mod) { this->_module = std::unique_ptr<Module<ref_set<T>>>(mod); } -} \ No newline at end of file +} diff --git a/source/kernel/back/linker/PriorityPair.hpp b/source/kernel/back/linker/PriorityPair.hpp deleted file mode 100644 index 091ad26..0000000 --- a/source/kernel/back/linker/PriorityPair.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include <engine/utility/Priority.hpp> - -namespace megu::kernel { - struct Priority_Pair { - Priority layer; - Priority object; - - bool operator<(const Priority_Pair & pp) const { - if(this->layer == pp.layer) { - return this->object < pp.object; - } - return this->layer < pp.layer; - } - }; -} \ No newline at end of file diff --git a/source/kernel/back/linker/RenderTrace.hpp b/source/kernel/back/linker/RenderTrace.hpp new file mode 100644 index 0000000..00dcdb0 --- /dev/null +++ b/source/kernel/back/linker/RenderTrace.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include <engine/utility/Priority.hpp> + +namespace megu::kernel { + struct RenderTrace { + Priority layer; + Priority object; + + bool operator<(const RenderTrace & trace) const { + if(this->layer == trace.layer) { + return this->object < trace.object; + } + return this->layer < trace.layer; + } + }; +} \ No newline at end of file diff --git a/source/kernel/back/linker/UniqueLinker.hpp b/source/kernel/back/linker/UniqueLinker.hpp index 9453bab..2386856 100644 --- a/source/kernel/back/linker/UniqueLinker.hpp +++ b/source/kernel/back/linker/UniqueLinker.hpp @@ -1,9 +1,10 @@ #pragma once #include "Linker.hpp" -#include "PriorityPair.hpp" #include <kernel/back/engine/GraphicEngine.hpp> +#include "RenderTrace.hpp" + namespace megu::kernel { template <class T> class UniqueGraphicLinker : public Linker<GraphicEngine> { @@ -11,17 +12,22 @@ namespace megu::kernel { UniqueGraphicLinker(); void link(T &, Priority, Priority); + void unlink(T &); + void link(GraphicEngine &) override; void setModule(Module<T> *); inline bool haveModule() const {return this->_module.get() != nullptr;} - inline ref_set<T> & objects() {return this->_object;} private: std::unique_ptr<Module<T>> _module; - std::map<Priority_Pair, ref_set<T>> _objects; - std::set<Priority_Pair> _waiting; + std::map<RenderTrace, std::pair<std::reference_wrapper<T>, size_t>> _stored; + std::map<RenderTrace, std::reference_wrapper<T>> _await; + std::map<RenderTrace, size_t> _ids; + + std::set<RenderTrace> _delete; + }; } -#include "UniqueLinker.tpp" \ No newline at end of file +#include "UniqueLinker.tpp" diff --git a/source/kernel/back/linker/UniqueLinker.tpp b/source/kernel/back/linker/UniqueLinker.tpp index 9265d6c..907a106 100644 --- a/source/kernel/back/linker/UniqueLinker.tpp +++ b/source/kernel/back/linker/UniqueLinker.tpp @@ -7,25 +7,38 @@ namespace megu::kernel { template <class T> void UniqueGraphicLinker<T>::link(T & object, Priority l, Priority o) { - auto layers = Priority_Pair{l, o}; - - this->_objects[layers].insert(object); - this->_waiting.insert(layers); + auto layers = RenderTrace{l, o}; + this->_await.insert({layers, object}); } template <class T> void UniqueGraphicLinker<T>::link(GraphicEngine & engine) { - for(const auto & layers : this->_waiting) { - for(auto & object : this->_objects[layers]) { - engine.get().push<T>(layers.layer, layers.object, object, this->_module.get()); - } + for(const auto & layer : this->_delete) { + engine.get().remove(Identifiable(this->_ids[layer])); + } + + this->_delete.clear(); + + for(auto & [layer, object] : this->_await) { + this->_stored.insert({layer, object}); + size_t id = engine.get().push<T>(layer.layer, layer.object, this->_stored[layer], this->_module.get()); + this->_ids[layer] = id; } - this->_waiting.clear(); + this->_await.clear(); + } + + template <class T> + void UniqueGraphicLinker<T>::unlink(T & object) { + for(auto & [layer, obj] : this->_stored) { + if(&(obj.get()) == &object) { + this->_delete.insert(layer); + } + } } template <class T> void UniqueGraphicLinker<T>::setModule(Module<T> * mod) { this->_module = std::unique_ptr<Module<T>>(mod); } -} \ No newline at end of file +} diff --git a/source/kernel/front/Kernel.cpp b/source/kernel/front/Kernel.cpp index e0a917b..8e66ea9 100644 --- a/source/kernel/front/Kernel.cpp +++ b/source/kernel/front/Kernel.cpp @@ -38,4 +38,20 @@ namespace megu::kernel { this->_gResolver.add(*gComponent); } } + + void Kernel::remove(Prop * props) { + auto * pComponent = props->getPhysicComponent(); + if(pComponent != nullptr) { + this->_pEngine.remove(*this, *pComponent); + this->_pResolver.remove(*pComponent); + } + + auto * gComponent = props->getGraphicComponent(); + if(gComponent != nullptr) { + this->_gEngine.remove(*this, *gComponent); + this->_gResolver.remove(*gComponent); + } + + this->_props.erase(props->id()); + } } \ No newline at end of file diff --git a/source/kernel/front/Kernel.hpp b/source/kernel/front/Kernel.hpp index f6b7b7a..e7e7f04 100644 --- a/source/kernel/front/Kernel.hpp +++ b/source/kernel/front/Kernel.hpp @@ -20,12 +20,15 @@ namespace megu::kernel { void step(); void add(Prop *); - + void remove(Prop *); + inline Identifiable_Map<Prop> & props() {return this->_props;} inline PhysicEngine & getPhysicEngine() {return this->_pEngine;} inline GraphicEngine & getGraphicEngine() {return this->_gEngine;} + inline Window & window() {return this->_window;} + private: Window & _window; diff --git a/source/kernel/front/component/graphic/Sprite.cpp b/source/kernel/front/component/graphic/Sprite.cpp index c5f5069..ba3cbb9 100644 --- a/source/kernel/front/component/graphic/Sprite.cpp +++ b/source/kernel/front/component/graphic/Sprite.cpp @@ -79,4 +79,9 @@ namespace megu::kernel { Sprite::_Linker.link(*this, this->getLayerPriority(), this->getObjectPriority()); Sprite::_Linker.link(engine); } + + void Sprite::unapply(Kernel & kernel, GraphicEngine & engine) { + Sprite::_Linker.unlink(*this); + Sprite::_Linker.link(engine); + } } \ No newline at end of file diff --git a/source/kernel/front/component/graphic/Sprite.hpp b/source/kernel/front/component/graphic/Sprite.hpp index 5d1420f..b3bcc56 100644 --- a/source/kernel/front/component/graphic/Sprite.hpp +++ b/source/kernel/front/component/graphic/Sprite.hpp @@ -36,6 +36,7 @@ namespace megu::kernel { void update(double) override; void apply(Kernel &, GraphicEngine &) override; + void unapply(Kernel &, GraphicEngine &) override; static const GraphicLinker<megu::Sprite> & linker() {return Sprite::_Linker;} diff --git a/source/kernel/front/component/graphic/TileMap.cpp b/source/kernel/front/component/graphic/TileMap.cpp index 83cd774..e0df788 100644 --- a/source/kernel/front/component/graphic/TileMap.cpp +++ b/source/kernel/front/component/graphic/TileMap.cpp @@ -95,4 +95,9 @@ namespace megu::kernel { Tilemap::_Linker.link(*this, this->getLayerPriority(), this->getObjectPriority()); Tilemap::_Linker.link(engine); } + + void Tilemap::unapply(Kernel & kernel, GraphicEngine & engine) { + Tilemap::_Linker.unlink(*this); + Tilemap::_Linker.link(engine); + } } \ No newline at end of file diff --git a/source/kernel/front/component/graphic/TileMap.hpp b/source/kernel/front/component/graphic/TileMap.hpp index bdbc02b..6d6ad9d 100644 --- a/source/kernel/front/component/graphic/TileMap.hpp +++ b/source/kernel/front/component/graphic/TileMap.hpp @@ -37,6 +37,7 @@ namespace megu::kernel { void update(double) override; void apply(Kernel &, GraphicEngine &) override; + void unapply(Kernel &, GraphicEngine &) override; private: std::vector<TilePosition> _tilesPosition; diff --git a/source/kernel/front/component/physic/Fixed.cpp b/source/kernel/front/component/physic/Fixed.cpp index e981a42..8964777 100644 --- a/source/kernel/front/component/physic/Fixed.cpp +++ b/source/kernel/front/component/physic/Fixed.cpp @@ -12,7 +12,7 @@ namespace megu::kernel { } } - void Fixed::on_collide(const Kernel & kernel, const PhysicEngine & engine, Physical & physical, double time) { + void Fixed::on_collide(Kernel & kernel, const PhysicEngine & engine, Physical & physical, double time) { if(this->_collide != nullptr) { this->_collide(kernel, engine, physical, time); } @@ -22,11 +22,15 @@ namespace megu::kernel { engine.get().push(0, *this); } - void Fixed::setCollideLambda(const CollideLambda & lambda) { + void Fixed::unapply(Kernel & kernel, PhysicEngine & engine) { + engine.get().remove(*this); + } + + void Fixed::setCollideLambda(CollideLambda lambda) { this->_collide = lambda; } - void Fixed::setUpdateLambda(const UpdateLambda & lambda) { + void Fixed::setUpdateLambda(UpdateLambda lambda) { this->_update = lambda; } } \ No newline at end of file diff --git a/source/kernel/front/component/physic/Fixed.hpp b/source/kernel/front/component/physic/Fixed.hpp index 14e086b..232084a 100644 --- a/source/kernel/front/component/physic/Fixed.hpp +++ b/source/kernel/front/component/physic/Fixed.hpp @@ -13,17 +13,15 @@ namespace megu::kernel { Fixed(float x, float y, float w, float h); void update_physic(double) const override; - void on_collide(const Kernel &, const PhysicEngine &, Physical &, double) override; + void on_collide(Kernel &, const PhysicEngine &, Physical &, double) override; void apply(Kernel & k, PhysicEngine &) override; + void unapply(Kernel & k, PhysicEngine &) override; - void setCollideLambda(const CollideLambda &); - void setUpdateLambda(const UpdateLambda &); + void setCollideLambda(CollideLambda); + void setUpdateLambda(UpdateLambda); private: CollideLambda _collide; UpdateLambda _update; - - - }; } \ No newline at end of file diff --git a/source/kernel/front/component/physic/FixedArray.cpp b/source/kernel/front/component/physic/FixedArray.cpp index 4272875..5e5602d 100644 --- a/source/kernel/front/component/physic/FixedArray.cpp +++ b/source/kernel/front/component/physic/FixedArray.cpp @@ -22,7 +22,7 @@ namespace megu::kernel { this->_tangibles.erase(position); } - void FixedArray::on_collide(const Kernel & kernel, const PhysicEngine & engine, Physical & physical, double time) { + void FixedArray::on_collide(Kernel & kernel, const PhysicEngine & engine, Physical & physical, double time) { auto & tangible = engine.get(physical); for(auto & [position, fixed] : this->_tangibles) { if(fixed.isColliding(tangible)) { @@ -40,4 +40,16 @@ namespace megu::kernel { void FixedArray::apply(Kernel & kernel, PhysicEngine & engine) { engine.get().push(0, *this); } + + void FixedArray::unapply(Kernel & kernel, PhysicEngine & engine) { + engine.get().remove(*this); + } + + void FixedArray::setCollideLambda(CollideLambda lambda) { + this->_collide = lambda; + } + + void FixedArray::setUpdateLambda(UpdateLambda lambda) { + this->_update = lambda; + } } \ No newline at end of file diff --git a/source/kernel/front/component/physic/FixedArray.hpp b/source/kernel/front/component/physic/FixedArray.hpp index c506453..9f04d44 100644 --- a/source/kernel/front/component/physic/FixedArray.hpp +++ b/source/kernel/front/component/physic/FixedArray.hpp @@ -16,12 +16,13 @@ namespace megu::kernel { void erase(const Fixed &); void erase(const Position &); - void setCollideLambda(CollideLambda &); - void setUpdateLambda(UpdateLambda &); + void setCollideLambda(CollideLambda); + void setUpdateLambda(UpdateLambda); void update_physic(double) const override; - void on_collide(const Kernel &, const PhysicEngine &, Physical &, double) override; + void on_collide(Kernel &, const PhysicEngine &, Physical &, double) override; void apply(Kernel & k, PhysicEngine &) override; + void unapply(Kernel & k, PhysicEngine &) override; private: std::map<Position, Fixed> _tangibles; diff --git a/source/kernel/front/component/physic/Movable.cpp b/source/kernel/front/component/physic/Movable.cpp index 0fd7504..ac592e6 100644 --- a/source/kernel/front/component/physic/Movable.cpp +++ b/source/kernel/front/component/physic/Movable.cpp @@ -10,21 +10,25 @@ namespace megu::kernel { } } - void Movable::on_collide(const Kernel & kernel, const PhysicEngine & engine, Physical & physical, double time) { + void Movable::on_collide(Kernel & kernel, const PhysicEngine & engine, Physical & physical, double time) { if(this->_collide != nullptr) { this->_collide(kernel, engine, physical, time); } } void Movable::apply(Kernel & kernel, PhysicEngine & engine) { - engine.add(kernel, *this); + engine.get().push(0, *this); } - void Movable::setCollideLambda(CollideLambda & lambda) { + void Movable::unapply(Kernel & kernel, PhysicEngine & engine) { + engine.get().remove(*this); + } + + void Movable::setCollideLambda(CollideLambda lambda) { this->_collide = lambda; } - void Movable::setUpdateLambda(UpdateLambda & lambda) { + void Movable::setUpdateLambda(UpdateLambda lambda) { this->_update = lambda; } } \ No newline at end of file diff --git a/source/kernel/front/component/physic/Movable.hpp b/source/kernel/front/component/physic/Movable.hpp index 2e83bf9..f1cd9ff 100644 --- a/source/kernel/front/component/physic/Movable.hpp +++ b/source/kernel/front/component/physic/Movable.hpp @@ -13,11 +13,12 @@ namespace megu::kernel { Movable(float x, float y, float w, float h); void update_physic(double) override; - void on_collide(const Kernel &, const PhysicEngine &, Physical &, double) override; + void on_collide(Kernel &, const PhysicEngine &, Physical &, double) override; void apply(Kernel & k, PhysicEngine &) override; + void unapply(Kernel & k, PhysicEngine &) override; - void setCollideLambda(CollideLambda &); - void setUpdateLambda(UpdateLambda &); + void setCollideLambda(CollideLambda); + void setUpdateLambda(UpdateLambda); private: CollideLambda _collide; diff --git a/source/kernel/front/props/PropsPlayable.cpp b/source/kernel/front/props/PropsPlayable.cpp new file mode 100644 index 0000000..cf28c48 --- /dev/null +++ b/source/kernel/front/props/PropsPlayable.cpp @@ -0,0 +1,18 @@ +#include "PropsPlayable.hpp" + +#include <engine/io/Window.hpp> + +namespace megu::kernel { + PropsPlayable::PropsPlayable(Sprite & graphic, Movable & physic) + : _graphic(graphic), _physic(physic) {} + + void PropsPlayable::setControl(Window & window, Keyboard * keyboard) { + this->_profiler.set(keyboard); + this->_profiler.link(window); + } + + void PropsPlayable::setControl(Window & window, Mouse * mouse) { + this->_profiler.set(mouse); + this->_profiler.link(window); + } +} \ No newline at end of file diff --git a/source/kernel/front/props/PropsPlayable.hpp b/source/kernel/front/props/PropsPlayable.hpp new file mode 100644 index 0000000..8857cd2 --- /dev/null +++ b/source/kernel/front/props/PropsPlayable.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include <kernel/front/props/Props.hpp> +#include <kernel/front/component/graphic/Sprite.hpp> +#include <kernel/front/component/physic/Movable.hpp> + +#include <engine/io/Profiler.hpp> + +namespace megu { + class Window; +} + +namespace megu::kernel { + class PropsPlayable : public Prop { + public: + PropsPlayable(Sprite &, Movable &); + + void setControl(Window &, Keyboard *); + void setControl(Window &, Mouse *); + + virtual Graphical_Component * getGraphicComponent() {return &this->_graphic;} + virtual Physical_Component * getPhysicComponent() {return &this->_physic;} + + private: + Sprite & _graphic; + Movable & _physic; + Profiler _profiler; + }; +} \ No newline at end of file diff --git a/source/kernel/front/resolver/Resolver.hpp b/source/kernel/front/resolver/Resolver.hpp index 0e63f12..40ac293 100644 --- a/source/kernel/front/resolver/Resolver.hpp +++ b/source/kernel/front/resolver/Resolver.hpp @@ -12,7 +12,7 @@ namespace megu::kernel { inline ref_set<O> & components() {return this->_components;} void add(O &); - void erase(const Identifiable &); + void remove(const Identifiable &); std::optional<std::reference_wrapper<O>> get(const Identifiable &); virtual void resolve(Kernel &, E &, double) = 0; diff --git a/source/kernel/front/resolver/Resolver.tpp b/source/kernel/front/resolver/Resolver.tpp index 0a4beb0..89f265d 100644 --- a/source/kernel/front/resolver/Resolver.tpp +++ b/source/kernel/front/resolver/Resolver.tpp @@ -7,8 +7,9 @@ namespace megu::kernel { } template <class E, class O> - void Resolver<E, O>::erase(const Identifiable & c) { - this->_components.erase(c); + void Resolver<E, O>::remove(const Identifiable & c) { + auto it = std::find(this->_components.begin(), this->_components.end(), c); + this->_components.erase(it); } template <class E, class O> diff --git a/source/main.cpp b/source/main.cpp index 7b12b5b..b62fee2 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -9,52 +9,4 @@ int main(int argc, const char * argv[]) { std::cout << "Running..." << std::endl; return game.run(); -} - -/*int main(int argc, const char * argv[]) { - std::cout << "Program Init" << std::endl; - try { - megu::Window window; - window.open("Kernel Test", WINDOW_WIDTH, WINDOW_HEIGHT); - std::cout << "Window Init" << std::endl; - - megu::kernel::Kernel kernel(window); - std::cout << "Kernel Init" << std::endl; - - auto path = std::filesystem::path("assets/textures/Neera.png"); - megu::game::Object object(path); - - megu::game::Object object2(path); - object2.tmp_setPos(100, 0); - - std::cout << "Object Init" << std::endl; - kernel.add(&object2); - kernel.add(&object); - - double previousTime = megu::Window::Time(); - int frameCount = 0; - - std::cout << "Render Loop Init" << std::endl; - while(window.isOpen()) { - double currentTime = megu::Window::Time(); - frameCount++; - - if(currentTime - previousTime >= 1.0) { - window.setTitle(std::to_string(frameCount)); - - frameCount = 0; - previousTime = currentTime; - } - - window.pollEvents(); - kernel.step(); - } - std::cout << "Render Loop End" << std::endl; - } - catch(std::exception & error) { - std::cerr << error.what() << std::endl; - } - - std::cout << "Program End" << std::endl; - return EXIT_SUCCESS; -}*/ \ No newline at end of file +} \ No newline at end of file diff --git a/source/utility/Identifiable.cpp b/source/utility/Identifiable.cpp index 02c063b..8490b36 100644 --- a/source/utility/Identifiable.cpp +++ b/source/utility/Identifiable.cpp @@ -20,9 +20,9 @@ namespace megu { return this->_id == identifiable._id; } - bool Identifiable::operator!=(const Identifiable & identifiable) const { + /*bool Identifiable::operator!=(const Identifiable & identifiable) const { return !(*this == identifiable); - } + }*/ bool Identifiable::operator<=(const Identifiable & identifiable) const { return this->_id <= identifiable._id; diff --git a/source/utility/Identifiable.hpp b/source/utility/Identifiable.hpp index 11e91f5..5c1fc1b 100644 --- a/source/utility/Identifiable.hpp +++ b/source/utility/Identifiable.hpp @@ -15,7 +15,7 @@ namespace megu { inline void setId(size_t id) {this->_id = id;} bool operator==(const Identifiable &) const; - bool operator!=(const Identifiable &) const; + //bool operator!=(const Identifiable &) const; bool operator>=(const Identifiable &) const; bool operator<=(const Identifiable &) const; -- GitLab