From 2a0fa130f3ed26eeca12cd7587779040454aed7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9au?= <theau.baton@etu.univ-amu.fr> Date: Tue, 14 Jan 2025 23:38:30 +0100 Subject: [PATCH] Changing Props -> BasicProps --- assets/tilemap.png | Bin 4547 -> 4985 bytes .../graphics/front/object/TileArray.cpp | 4 +- .../graphics/front/object/TileArray.hpp | 2 +- source/game/Game.cpp | 7 --- source/game/back/GameObject.hpp | 9 ++++ source/game/back/message/Receiver.hpp | 17 +++++++ source/game/back/object/Terrain.hpp | 14 ++++++ source/game/object/Test.cpp | 43 +++++++++++++++--- source/game/object/Test.hpp | 8 ++-- .../back/{props => component}/Component.hpp | 0 .../back/{props => component}/Graphical.hpp | 1 + .../back/{props => component}/Physical.hpp | 4 +- source/kernel/back/engine/GraphicEngine.hpp | 2 +- source/kernel/back/engine/PhysicEngine.hpp | 2 +- source/kernel/back/props/Props.hpp | 17 ------- source/kernel/front/Kernel.cpp | 2 +- source/kernel/front/Kernel.hpp | 15 +++--- .../kernel/front/component/graphic/Sprite.hpp | 2 +- .../front/component/graphic/TileMap.cpp | 34 ++++++++++---- .../front/component/graphic/TileMap.hpp | 16 ++++--- .../kernel/front/component/physic/Fixed.hpp | 2 +- .../front/component/physic/FixedArray.cpp | 6 +++ .../front/component/physic/FixedArray.hpp | 6 ++- .../kernel/front/component/physic/Movable.hpp | 2 +- source/kernel/front/props/Props.hpp | 23 ++++++++++ source/kernel/front/props/PropsDynamic.cpp | 6 +++ source/kernel/front/props/PropsDynamic.hpp | 19 ++++++++ source/kernel/front/props/PropsStatic.cpp | 6 +++ source/kernel/front/props/PropsStatic.hpp | 19 ++++++++ source/kernel/front/props/PropsTileMap.cpp | 7 +++ source/kernel/front/props/PropsTileMap.hpp | 19 ++++++++ .../kernel/front/resolver/GraphicResolver.hpp | 5 +- .../kernel/front/resolver/PhysicResolver.hpp | 4 +- source/kernel/front/resolver/Resolver.hpp | 4 +- 34 files changed, 252 insertions(+), 75 deletions(-) create mode 100644 source/game/back/GameObject.hpp create mode 100644 source/game/back/message/Receiver.hpp create mode 100644 source/game/back/object/Terrain.hpp rename source/kernel/back/{props => component}/Component.hpp (100%) rename source/kernel/back/{props => component}/Graphical.hpp (94%) rename source/kernel/back/{props => component}/Physical.hpp (100%) delete mode 100644 source/kernel/back/props/Props.hpp create mode 100644 source/kernel/front/props/Props.hpp create mode 100644 source/kernel/front/props/PropsDynamic.cpp create mode 100644 source/kernel/front/props/PropsDynamic.hpp create mode 100644 source/kernel/front/props/PropsStatic.cpp create mode 100644 source/kernel/front/props/PropsStatic.hpp create mode 100644 source/kernel/front/props/PropsTileMap.cpp create mode 100644 source/kernel/front/props/PropsTileMap.hpp diff --git a/assets/tilemap.png b/assets/tilemap.png index b336765460a48008cfa66ca7a72ecdc290c9aa51..49ffb3925e40fe5195012608f088696ccd8bd4de 100644 GIT binary patch delta 4957 zcmX@C{8Md$XZ-;N2EGG~S=Tx_85o55JY5_^D&pSG)$fr#DR}I@6*~_ve-xKx1(#9x z!lfR89x96`FT8k?%gDr}Ta;C13!mgXp`;fEi(fpLIGKl+*IeP&m+<xb@8!P=Ej>T~ zd)Z%+|0R!SzFhUnKECw(p32?dV&7<mKiyw+`Cavj_q)a8<83SI|J^us@b~omvK{^B zBxl;6lZ!upSX_RseD?4E{dYrm#-5k|AEzHy#9qI^x$2$Z&s7>Cy26{)SA9?4DRk7m z_Ef~9YT+0c*^_BOPkyf#kH5Y;LdM8F=EJYI$M3%W{`FX3Saf#t$NlvmFP=L!>EHj) z8!`lEhdW%kxngl(q}c@yeY@8B5RHG6*{`#^9B+KR>F%3%_i9Z$_pkgnzw26K9DB8y z4fC1>LY&eM!yCHz=h@s^uQP>tZ~OhHPmNbQ&u4t5aOUOz^p89YZzeSLeYe^_ErWH- zOnHv}!!7#kZ|xe*Z~jldB*gHnB<IQF*3J*N1&+R3*m-bT%i9yhJ^${TOlE0_V^^-f zeMk5BVHJkERVCAYAK9?y_@#gM&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o9BHg z<0|GEMmx5?)&J`LK!U};(#T6*aq0>2FMrtUEyL3TS*91X$ume_ZA@=w$-W)`dVl@b z-CG@F51g;q_V{4MUfmZz`NJ5j^JPWV;}+{=%}8MmuQFSGJN}`6_14CKStlZ7@AY?9 z{Qp)IpmZZnphEWPLl1dd_nFVC>!<YoH15A1DA)J<%X3qq+6jBkDhB;{{`z`?@r%H{ zE2bR0viZDxtfd6^HkD0#<=kHfDE*&1yP&hmtA0IC3a@suS@tdV?7yO4O05@e>r}A! za;Y^D{CYEzG5T>;;7p@t!yRw!w!byeN?&ZV-L2a<d`auu$y@)~UijZ}`)_UZxx#9t z{|C8FNCi}xZFjuj$NRbJ(fZu_we>7-W-eP~H%lpsK|_xBs^jNlE-|NWefxg3eoA^u zYD8jiSmcxXe8vPucE&3apKttJA+uo4`M(ygcJkSLiog9&sGjS1_S?nk!Z(>#Gfv+& z^~8VfGOOZGE9UYY`~AD|OU|NAJX>$K+uLoc*nab0!MxOc@0YAyvPAdS*^l}5Q^Jo) zDeT!;_3Tc|BCBUx_^<s^=J+QqRDSg6v)$5r1azJ)-+yItYt7%-dfUhoufDxyerRLC z;q~Qf$=|;Xah10pP4e9IS+3w&o+Z12;w?SL_urW|ZCayOz<0o>D&F$_)YLi51u5qk zSNu?4{>C$pbDv)BYncYgFW>5oj=EX0C$I&7`?2$TV=;r)&D*aPFKj!<Xkql6L1oT; zX1m~X?-~Cm&tVR*+|NFT;rVyj2IbBFzc-wHwqLLz<fusQcM}E%1_n=8KbLh*2~7Yi Ceyw2u diff --git a/source/engine/graphics/front/object/TileArray.cpp b/source/engine/graphics/front/object/TileArray.cpp index 9e1d431..475635b 100644 --- a/source/engine/graphics/front/object/TileArray.cpp +++ b/source/engine/graphics/front/object/TileArray.cpp @@ -3,7 +3,7 @@ #include <iostream> namespace megu { - TileArray::TileArray(const std::filesystem::path & path, size_t width, size_t height, float size) + TileArray::TileArray(const std::filesystem::path & path, size_t width, size_t height, float size, size_t lenght) : _width(width), _height(height), _size(size) { megu::TextureBuffer buffer(path); this->_texture.store(buffer); @@ -14,7 +14,7 @@ namespace megu { for(size_t x = 0; x < width; ++x) { std::vector<glm::vec4> rows; for(size_t y = 0; y < height; ++y) { - rows.push_back({0.f, 0.f, twidth, theight}); + rows.push_back({0.f, this->_texture.height() - lenght, lenght, lenght}); } this->_uvs.push_back(rows); } diff --git a/source/engine/graphics/front/object/TileArray.hpp b/source/engine/graphics/front/object/TileArray.hpp index 94e66b7..c4191dc 100644 --- a/source/engine/graphics/front/object/TileArray.hpp +++ b/source/engine/graphics/front/object/TileArray.hpp @@ -13,7 +13,7 @@ namespace megu { class TileArray : public Quads { public: - TileArray(const std::filesystem::path &, size_t, size_t, float); + TileArray(const std::filesystem::path &, size_t, size_t, float, size_t); inline void setPosition(const Vec2 & pos) {this->_transformation.setPosition(pos.x, pos.y);} inline void setOrigine(const Vec2 & pos) {this->_transformation.setOrigine(pos.x, pos.y);} diff --git a/source/game/Game.cpp b/source/game/Game.cpp index b9c38e1..65d0899 100644 --- a/source/game/Game.cpp +++ b/source/game/Game.cpp @@ -20,16 +20,9 @@ namespace megu::game { FrameCounter counter; kernel::Kernel kernel(window); - - /* object */ auto path = std::filesystem::path("assets/textures/Neera.png"); megu::game::Object object(path); kernel.add(&object); - - /*megu::game::Object object2(path); - object2.tmp_setPos(20, 0); - kernel.add(&object2);*/ - /* ------ */ while(window.isOpen()) { counter.count(Window::Time()); diff --git a/source/game/back/GameObject.hpp b/source/game/back/GameObject.hpp new file mode 100644 index 0000000..a2c7fd7 --- /dev/null +++ b/source/game/back/GameObject.hpp @@ -0,0 +1,9 @@ +#pragma once + +namespace megu::game { + class GameObject { + public: + virtual void setup() = 0; + virtual void destroy() = 0; + }; +} \ No newline at end of file diff --git a/source/game/back/message/Receiver.hpp b/source/game/back/message/Receiver.hpp new file mode 100644 index 0000000..326864a --- /dev/null +++ b/source/game/back/message/Receiver.hpp @@ -0,0 +1,17 @@ +#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/Terrain.hpp b/source/game/back/object/Terrain.hpp new file mode 100644 index 0000000..0058a3c --- /dev/null +++ b/source/game/back/object/Terrain.hpp @@ -0,0 +1,14 @@ +#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/object/Test.cpp b/source/game/object/Test.cpp index f2c6e96..8433087 100644 --- a/source/game/object/Test.cpp +++ b/source/game/object/Test.cpp @@ -2,16 +2,45 @@ namespace megu::game { Object::Object(std::filesystem::path & path) - : _physic(0, 0, 64, 64), _graphic(path), _map("assets/tilemap.png", 2, 2, 16.f, 16) { + : _physic(0, 0, 64, 64), _graphic(path), _map("assets/tilemap.png", 8, 8, 8.f, 16, 0.125) { this->_graphic.setFrame({0.f, 0.f, 51.f, 98.f}); this->_graphic.setSize({51.f, 98.f}); - this->_map.setValue(0, 0, 1); - this->_map.setValue(1, 0, 2); - this->_map.setValue(0, 1, 1); - this->_map.setValue(1, 1, 1); + size_t tab[8][8] = { + {44, 45, 44, 47, 2, 1, 1, 1}, + {45, 45, 44, 47, 1, 1, 1, 1}, + {45, 44, 44, 47, 1, 1, 1, 1}, + {22, 22, 22, 23, 1, 1, 2, 1}, + {28, 28, 28, 29, 1, 1, 1, 1}, + { 1, 2, 1, 1, 1, 1, 1, 1}, + { 1, 2, 1, 1, 1, 1, 1, 1}, + { 1, 1, 1, 2, 1, 1, 1, 1} + }; - this->_map.addAnimation(0, 1, {18, 19, 20, 21}); - this->_map.addAnimation(1, 1, {18, 19, 20, 21}); + for(size_t i = 0; i < 8; ++i) { + for(size_t j = 0; j < 8; ++j) { + this->_map.setValue(j, i, tab[i][j]); + } + } + + this->_map.addAnimation(0, 6, {18, 18, 20, 21}); + this->_map.addAnimation(1, 6, {18, 18, 20, 21}); + this->_map.addAnimation(2, 6, {18, 18, 20, 21}); + this->_map.addAnimation(3, 6, {18, 18, 20, 21}); + this->_map.addAnimation(4, 6, {18, 18, 20, 21}); + this->_map.addAnimation(5, 6, {18, 18, 20, 21}); + this->_map.addAnimation(6, 6, {18, 18, 20, 21}); + this->_map.addAnimation(7, 6, {18, 18, 20, 21}); + + this->_map.addAnimation(0, 7, {24, 25, 26, 27}); + this->_map.addAnimation(1, 7, {24, 25, 26, 27}); + this->_map.addAnimation(2, 7, {24, 25, 26, 27}); + this->_map.addAnimation(3, 7, {24, 25, 26, 27}); + this->_map.addAnimation(4, 7, {24, 25, 26, 27}); + this->_map.addAnimation(5, 7, {24, 25, 26, 27}); + this->_map.addAnimation(6, 7, {24, 25, 26, 27}); + this->_map.addAnimation(7, 7, {24, 25, 26, 27}); + + this->_map.setSize({360 / 8, 360 / 8}); } } \ No newline at end of file diff --git a/source/game/object/Test.hpp b/source/game/object/Test.hpp index cd3854e..a7b123f 100644 --- a/source/game/object/Test.hpp +++ b/source/game/object/Test.hpp @@ -1,17 +1,17 @@ #pragma once -#include <kernel/back/props/Props.hpp> +#include <kernel/front/props/Props.hpp> #include <kernel/front/component/physic/Fixed.hpp> #include <kernel/front/component/graphic/Sprite.hpp> #include <kernel/front/component/graphic/TileMap.hpp> namespace megu::game { - class Object : public kernel::Props { + class Object : public kernel::Prop { public: Object(std::filesystem::path &); - inline kernel::Physical<kernel::PhysicEngine> * getPhysicComponent() override {return &this->_physic;} - inline kernel::Graphical<kernel::GraphicEngine> * getGraphicComponent() override {return &this->_map;} + inline kernel::Prop::Physical_Component * getPhysicComponent() override {return &this->_physic;} + inline kernel::Prop::Graphical_Component * getGraphicComponent() override {return &this->_map;} private: kernel::Fixed _physic; diff --git a/source/kernel/back/props/Component.hpp b/source/kernel/back/component/Component.hpp similarity index 100% rename from source/kernel/back/props/Component.hpp rename to source/kernel/back/component/Component.hpp diff --git a/source/kernel/back/props/Graphical.hpp b/source/kernel/back/component/Graphical.hpp similarity index 94% rename from source/kernel/back/props/Graphical.hpp rename to source/kernel/back/component/Graphical.hpp index 432e580..0354e05 100644 --- a/source/kernel/back/props/Graphical.hpp +++ b/source/kernel/back/component/Graphical.hpp @@ -1,6 +1,7 @@ #pragma once #include "Component.hpp" +#include <engine/utility/Priority.hpp> namespace megu::kernel { template <class Ge> diff --git a/source/kernel/back/props/Physical.hpp b/source/kernel/back/component/Physical.hpp similarity index 100% rename from source/kernel/back/props/Physical.hpp rename to source/kernel/back/component/Physical.hpp index 92d17ce..23028af 100644 --- a/source/kernel/back/props/Physical.hpp +++ b/source/kernel/back/component/Physical.hpp @@ -1,8 +1,8 @@ #pragma once -#include <functional> - #include "Component.hpp" + +#include <functional> #include <utility/Identifiable.hpp> namespace megu::kernel { diff --git a/source/kernel/back/engine/GraphicEngine.hpp b/source/kernel/back/engine/GraphicEngine.hpp index 41d8546..d0d9811 100644 --- a/source/kernel/back/engine/GraphicEngine.hpp +++ b/source/kernel/back/engine/GraphicEngine.hpp @@ -10,7 +10,7 @@ #include <engine/graphics/front/module/TileArray_Module.hpp> #include <engine/graphics/front/object/TileArray.hpp> -#include <kernel/back/props/Graphical.hpp> +#include <kernel/back/component/Graphical.hpp> namespace megu::kernel { class GraphicEngine : public Engine<megu::GraphicEngine, Graphical<GraphicEngine>, Renderable> { diff --git a/source/kernel/back/engine/PhysicEngine.hpp b/source/kernel/back/engine/PhysicEngine.hpp index 38919d9..7a7f441 100644 --- a/source/kernel/back/engine/PhysicEngine.hpp +++ b/source/kernel/back/engine/PhysicEngine.hpp @@ -3,7 +3,7 @@ #include "Engine.hpp" #include <engine/physic/front/engine/Engine.hpp> -#include <kernel/back/props/Physical.hpp> +#include <kernel/back/component/Physical.hpp> namespace megu::kernel { class PhysicEngine : public Engine<megu::PhysicEngine, Physical<PhysicEngine>, Tangible> { diff --git a/source/kernel/back/props/Props.hpp b/source/kernel/back/props/Props.hpp deleted file mode 100644 index 80dbe58..0000000 --- a/source/kernel/back/props/Props.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include <kernel/back/engine/GraphicEngine.hpp> -#include <kernel/back/engine/PhysicEngine.hpp> -#include <utility/Identifiable.hpp> - -#include "Physical.hpp" -#include "Graphical.hpp" - -namespace megu::kernel { - class Props : public Identifiable { - public: - virtual Physical<PhysicEngine> * getPhysicComponent() = 0; - virtual Graphical<GraphicEngine> * getGraphicComponent() = 0; - - }; -} \ No newline at end of file diff --git a/source/kernel/front/Kernel.cpp b/source/kernel/front/Kernel.cpp index 84cd925..e0a917b 100644 --- a/source/kernel/front/Kernel.cpp +++ b/source/kernel/front/Kernel.cpp @@ -24,7 +24,7 @@ namespace megu::kernel { this->_pResolver.resolve(*this, this->_pEngine, time); } - void Kernel::add(Props * props) { + void Kernel::add(Prop * props) { this->_props[props->id()] = props; auto * pComponent = props->getPhysicComponent(); if(pComponent != nullptr) { diff --git a/source/kernel/front/Kernel.hpp b/source/kernel/front/Kernel.hpp index 6a89a50..f6b7b7a 100644 --- a/source/kernel/front/Kernel.hpp +++ b/source/kernel/front/Kernel.hpp @@ -4,23 +4,24 @@ #include <engine/io/Window.hpp> -#include <kernel/back/engine/PhysicEngine.hpp> -#include <kernel/back/engine/GraphicEngine.hpp> -#include <kernel/back/props/Props.hpp> +#include <kernel/front/props/Props.hpp> -#include "resolver/PhysicResolver.hpp" #include "resolver/GraphicResolver.hpp" +#include "resolver/PhysicResolver.hpp" namespace megu::kernel { + class PhysicResolver; + class GraphicResolver; + class Kernel { public: Kernel(Window &); ~Kernel(); void step(); - void add(Props *); + void add(Prop *); - inline Identifiable_Map<Props> & props() {return this->_props;} + inline Identifiable_Map<Prop> & props() {return this->_props;} inline PhysicEngine & getPhysicEngine() {return this->_pEngine;} inline GraphicEngine & getGraphicEngine() {return this->_gEngine;} @@ -31,7 +32,7 @@ namespace megu::kernel { PhysicEngine _pEngine; GraphicEngine _gEngine; - Identifiable_Map<Props> _props; + Identifiable_Map<Prop> _props; PhysicResolver _pResolver; GraphicResolver _gResolver; }; diff --git a/source/kernel/front/component/graphic/Sprite.hpp b/source/kernel/front/component/graphic/Sprite.hpp index fbc9f16..5d1420f 100644 --- a/source/kernel/front/component/graphic/Sprite.hpp +++ b/source/kernel/front/component/graphic/Sprite.hpp @@ -5,7 +5,7 @@ #include <chrono> #include <kernel/back/engine/GraphicEngine.hpp> -#include <kernel/back/props/Graphical.hpp> +#include <kernel/back/component/Graphical.hpp> #include <kernel/back/linker/GraphicLinker.hpp> #include <engine/utility/ref_set.hpp> diff --git a/source/kernel/front/component/graphic/TileMap.cpp b/source/kernel/front/component/graphic/TileMap.cpp index 252c86f..83cd774 100644 --- a/source/kernel/front/component/graphic/TileMap.cpp +++ b/source/kernel/front/component/graphic/TileMap.cpp @@ -4,14 +4,17 @@ namespace megu::kernel { UniqueGraphicLinker<TileArray> Tilemap::_Linker = UniqueGraphicLinker<TileArray>(); Tilemap::Tilemap(const std::filesystem::path & path, size_t width, size_t height, float size, size_t lenght, double aUpdate) - : TileArray(path, width , height, size), _tileSize(lenght), _duration(aUpdate) { + : TileArray(path, width , height, size, lenght), _tileSize(lenght), _duration(aUpdate) { if(lenght % width != 0 && lenght % height != 0) { throw std::runtime_error("Tilemap dimension not matching tiles size."); } - for(size_t x = 0; x < this->texture().width() - this->_tileSize*2; x += this->_tileSize) { - for(size_t y = 0; y < this->texture().height() - this->_tileSize*2; y += this->_tileSize) { - this->_tilesPosition.push_back({y, x}); + size_t tileWidth = this->texture().width() / this->_tileSize; + size_t tileHeight = this->texture().height() / this->_tileSize; + + for(size_t y = 0; y < tileHeight; ++y) { + for(size_t x = 0; x < tileWidth; ++x) { + this->_tilesPosition.push_back({x * this->_tileSize, y * this->_tileSize}); } } @@ -28,10 +31,19 @@ namespace megu::kernel { Tilemap::_Linker.setModule(new TileArray_Module{}); } - this->setSize({width * size, height * size}); + //this->setSize({width * size, height * size}); } void Tilemap::setValue(size_t x, size_t y, size_t value) { + if(this->width() <= x || this->height() <= y) { + throw std::runtime_error("Set Tilemap coords out of range."); + } + + if(value >= this->_tilesPosition.size()) { + std::cerr << value << " for " << this->_tilesPosition.size() << std::endl; + throw std::runtime_error("Set Tilemap value out of range."); + } + TilePosition position = this->_tilesPosition[value]; glm::vec4 uv = {position.x, this->texture().height() - position.y - this->_tileSize, @@ -42,7 +54,12 @@ namespace megu::kernel { this->_tilesValue[x][y] = value; } - size_t Tilemap::getValue(size_t x, size_t y) { + size_t Tilemap::getValue(size_t x, size_t y) const { + TilePosition position = {x, y}; + if(this->_animations.contains(position)) { + return this->_animations.at(position).first.at(this->_animations.at(position).second); + } + if(this->_tilesValue.size() > x && this->_tilesValue[x].size() > y) { return this->_tilesValue[x][y]; } @@ -50,7 +67,9 @@ namespace megu::kernel { } void Tilemap::addAnimation(size_t x, size_t y, const std::vector<size_t> & ids) { - this->_animations[{x, y}] = std::pair<std::vector<size_t>, size_t>(ids, 0); + if(x < this->width() && y < this->height()) { + this->_animations[{x, y}] = std::pair<std::vector<size_t>, size_t>(ids, 0); + } } void Tilemap::removeAnimation(size_t x, size_t y) { @@ -58,7 +77,6 @@ namespace megu::kernel { } void Tilemap::update(double time) { - //... Peut-être des tiles animées si j'ai le temps 🙌 (spoiler non). if(this->_previous == 0.0) { this->_previous = time; } diff --git a/source/kernel/front/component/graphic/TileMap.hpp b/source/kernel/front/component/graphic/TileMap.hpp index 39f43c8..bdbc02b 100644 --- a/source/kernel/front/component/graphic/TileMap.hpp +++ b/source/kernel/front/component/graphic/TileMap.hpp @@ -4,7 +4,7 @@ #include <vector> #include <kernel/back/engine/GraphicEngine.hpp> -#include <kernel/back/props/Graphical.hpp> +#include <kernel/back/component/Graphical.hpp> #include <kernel/back/linker/UniqueLinker.hpp> #include <engine/graphics/front/object/TileArray.hpp> @@ -17,29 +17,31 @@ namespace megu::kernel { size_t x = 0; size_t y = 0; - friend bool operator<(const TilePosition & p1, const TilePosition & p2) { - if(p1.x == p2.x) { - return p1.y < p2.y; + bool operator<(const TilePosition & p) const { + if(this->x == p.x) { + return this->y < p.y; } - return p1.x < p1.y; + return this->y < p.y; } }; Tilemap(const std::filesystem::path &, size_t, size_t, float, size_t, double = 0.1); void setValue(size_t, size_t, size_t); - size_t getValue(size_t, size_t); + size_t getValue(size_t, size_t) const; void addAnimation(size_t, size_t, const std::vector<size_t> &); void removeAnimation(size_t, size_t); + const std::map<TilePosition, std::pair<std::vector<size_t>, size_t>, reference_sorter<TilePosition>> & animation() const {return this->_animations;} + void update(double) override; void apply(Kernel &, GraphicEngine &) override; private: std::vector<TilePosition> _tilesPosition; std::vector<std::vector<size_t>> _tilesValue; - std::map<TilePosition, std::pair<std::vector<size_t>, size_t>> _animations; + std::map<TilePosition, std::pair<std::vector<size_t>, size_t>, reference_sorter<TilePosition>> _animations; TileArray_Module _module; size_t _tileSize; double _duration; diff --git a/source/kernel/front/component/physic/Fixed.hpp b/source/kernel/front/component/physic/Fixed.hpp index 9439be8..14e086b 100644 --- a/source/kernel/front/component/physic/Fixed.hpp +++ b/source/kernel/front/component/physic/Fixed.hpp @@ -1,6 +1,6 @@ #pragma once -#include <kernel/back/props/Physical.hpp> +#include <kernel/back/component/Physical.hpp> #include <kernel/back/engine/PhysicEngine.hpp> #include <engine/physic/front/object/TangibleStatic.hpp> diff --git a/source/kernel/front/component/physic/FixedArray.cpp b/source/kernel/front/component/physic/FixedArray.cpp index 7482b8d..4272875 100644 --- a/source/kernel/front/component/physic/FixedArray.cpp +++ b/source/kernel/front/component/physic/FixedArray.cpp @@ -31,6 +31,12 @@ namespace megu::kernel { } } + void FixedArray::update_physic(double time) const { + if(this->_update != nullptr) { + this->_update(time); + } + } + void FixedArray::apply(Kernel & kernel, PhysicEngine & engine) { engine.get().push(0, *this); } diff --git a/source/kernel/front/component/physic/FixedArray.hpp b/source/kernel/front/component/physic/FixedArray.hpp index 473b06b..c506453 100644 --- a/source/kernel/front/component/physic/FixedArray.hpp +++ b/source/kernel/front/component/physic/FixedArray.hpp @@ -1,6 +1,6 @@ #pragma once -#include <kernel/back/props/Physical.hpp> +#include <kernel/back/component/Physical.hpp> #include <kernel/back/engine/PhysicEngine.hpp> #include <vector> #include <functional> @@ -15,7 +15,11 @@ namespace megu::kernel { void push(const Fixed &); void erase(const Fixed &); void erase(const Position &); + + void setCollideLambda(CollideLambda &); + void setUpdateLambda(UpdateLambda &); + void update_physic(double) const override; void on_collide(const Kernel &, const PhysicEngine &, Physical &, double) override; void apply(Kernel & k, PhysicEngine &) override; diff --git a/source/kernel/front/component/physic/Movable.hpp b/source/kernel/front/component/physic/Movable.hpp index f74c85b..2e83bf9 100644 --- a/source/kernel/front/component/physic/Movable.hpp +++ b/source/kernel/front/component/physic/Movable.hpp @@ -1,6 +1,6 @@ #pragma once -#include <kernel/back/props/Physical.hpp> +#include <kernel/back/component/Physical.hpp> #include <kernel/back/engine/PhysicEngine.hpp> #include <engine/physic/front/object/TangibleMovable.hpp> diff --git a/source/kernel/front/props/Props.hpp b/source/kernel/front/props/Props.hpp new file mode 100644 index 0000000..d86d795 --- /dev/null +++ b/source/kernel/front/props/Props.hpp @@ -0,0 +1,23 @@ +#pragma once + + +#include <utility/Identifiable.hpp> +#include <kernel/back/component/Physical.hpp> +#include <kernel/back/component/Graphical.hpp> + +#include <kernel/back/engine/PhysicEngine.hpp> +#include <kernel/back/engine/GraphicEngine.hpp> + +namespace megu::kernel { + template <class Pe, class Ge> + class BaseProps : virtual public Identifiable { + public: + using Graphical_Component = Graphical<Ge>; + using Physical_Component = Physical<Pe>; + + virtual Graphical_Component * getGraphicComponent() = 0; + virtual Physical_Component * getPhysicComponent() = 0; + }; + + using Prop = BaseProps<PhysicEngine, GraphicEngine>; +} \ No newline at end of file diff --git a/source/kernel/front/props/PropsDynamic.cpp b/source/kernel/front/props/PropsDynamic.cpp new file mode 100644 index 0000000..6d94db7 --- /dev/null +++ b/source/kernel/front/props/PropsDynamic.cpp @@ -0,0 +1,6 @@ +#include "PropsDynamic.hpp" + +namespace megu::kernel { + PropsDynamic::PropsDynamic(Sprite & sprite, Movable & movable) + : _graphic(sprite), _physic(movable) {} +} \ No newline at end of file diff --git a/source/kernel/front/props/PropsDynamic.hpp b/source/kernel/front/props/PropsDynamic.hpp new file mode 100644 index 0000000..b86d815 --- /dev/null +++ b/source/kernel/front/props/PropsDynamic.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include <kernel/front/props/Props.hpp> +#include <kernel/front/component/graphic/Sprite.hpp> +#include <kernel/front/component/physic/Movable.hpp> + +namespace megu::kernel { + class PropsDynamic : public Prop { + public: + PropsDynamic(Sprite &, Movable &); + + inline Prop::Graphical_Component * getGraphicComponent() {return &this->_graphic;} + inline Prop::Physical_Component * getPhysicComponent() {return &this->_physic;} + + private: + Sprite & _graphic; + Movable & _physic; + }; +} \ No newline at end of file diff --git a/source/kernel/front/props/PropsStatic.cpp b/source/kernel/front/props/PropsStatic.cpp new file mode 100644 index 0000000..e10f34f --- /dev/null +++ b/source/kernel/front/props/PropsStatic.cpp @@ -0,0 +1,6 @@ +#include "PropsStatic.hpp" + +namespace megu::kernel { + PropsStatic::PropsStatic(Sprite & sprite, Fixed & fixed) + : _graphic(sprite), _physic(fixed) {} +} \ No newline at end of file diff --git a/source/kernel/front/props/PropsStatic.hpp b/source/kernel/front/props/PropsStatic.hpp new file mode 100644 index 0000000..3210fcd --- /dev/null +++ b/source/kernel/front/props/PropsStatic.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include <kernel/front/props/Props.hpp> +#include <kernel/front/component/graphic/Sprite.hpp> +#include <kernel/front/component/physic/Fixed.hpp> + +namespace megu::kernel { + class PropsStatic : public Prop { + public: + PropsStatic(Sprite &, Fixed &); + + inline Prop::Graphical_Component * getGraphicComponent() override {return &this->_graphic;} + inline Prop::Physical_Component * getPhysicComponent() override {return &this->_physic;} + + private: + Sprite & _graphic; + Fixed & _physic; + }; +} \ No newline at end of file diff --git a/source/kernel/front/props/PropsTileMap.cpp b/source/kernel/front/props/PropsTileMap.cpp new file mode 100644 index 0000000..8ec7d35 --- /dev/null +++ b/source/kernel/front/props/PropsTileMap.cpp @@ -0,0 +1,7 @@ +#include "PropsTileMap.hpp" + +namespace megu::kernel { + PropsTileMap::PropsTileMap(Tilemap & tilemap, FixedArray & fixedarray) + : _graphic(tilemap), _physic(fixedarray) {} + +} \ No newline at end of file diff --git a/source/kernel/front/props/PropsTileMap.hpp b/source/kernel/front/props/PropsTileMap.hpp new file mode 100644 index 0000000..eee3f71 --- /dev/null +++ b/source/kernel/front/props/PropsTileMap.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include <kernel/front/props/Props.hpp> +#include <kernel/front/component/graphic/TileMap.hpp> +#include <kernel/front/component/physic/FixedArray.hpp> + +namespace megu::kernel { + class PropsTileMap : public Prop { + public: + PropsTileMap(Tilemap &, FixedArray &); + + inline Prop::Graphical_Component * getGraphicComponent() override {return &this->_graphic;} + inline Prop::Physical_Component * getPhysicComponent() override {return &this->_physic;} + + private: + Tilemap & _graphic; + FixedArray & _physic; + }; +} \ No newline at end of file diff --git a/source/kernel/front/resolver/GraphicResolver.hpp b/source/kernel/front/resolver/GraphicResolver.hpp index 7e2b541..8be90fa 100644 --- a/source/kernel/front/resolver/GraphicResolver.hpp +++ b/source/kernel/front/resolver/GraphicResolver.hpp @@ -2,10 +2,11 @@ #include "Resolver.hpp" #include <kernel/back/engine/GraphicEngine.hpp> -#include <kernel/back/props/Props.hpp> +#include <kernel/front/props/Props.hpp> namespace megu::kernel { - class GraphicResolver : public Resolver<GraphicEngine, Graphical<GraphicEngine>> { + class Kernel; + class GraphicResolver : public Resolver<GraphicEngine, Prop::Graphical_Component> { public: void resolve(Kernel &, GraphicEngine &, double) override; }; diff --git a/source/kernel/front/resolver/PhysicResolver.hpp b/source/kernel/front/resolver/PhysicResolver.hpp index 349c6de..40aaf15 100644 --- a/source/kernel/front/resolver/PhysicResolver.hpp +++ b/source/kernel/front/resolver/PhysicResolver.hpp @@ -2,10 +2,10 @@ #include "Resolver.hpp" #include <kernel/back/engine/PhysicEngine.hpp> -#include <kernel/back/props/Props.hpp> +#include <kernel/front/props/Props.hpp> namespace megu::kernel { - class PhysicResolver : public Resolver<PhysicEngine, Physical<PhysicEngine>> { + class PhysicResolver : public Resolver<PhysicEngine, Prop::Physical_Component> { public: void resolve(Kernel &, PhysicEngine &, double) override; }; diff --git a/source/kernel/front/resolver/Resolver.hpp b/source/kernel/front/resolver/Resolver.hpp index 35b4732..0e63f12 100644 --- a/source/kernel/front/resolver/Resolver.hpp +++ b/source/kernel/front/resolver/Resolver.hpp @@ -1,9 +1,9 @@ #pragma once +#include <optional> #include <utility/Identifiable.hpp> -#include <kernel/back/props/Component.hpp> #include <engine/utility/ref_set.hpp> -#include <optional> +#include <kernel/back/component/Component.hpp> namespace megu::kernel { template <class E, class O> -- GitLab