diff --git a/assets/tilemap.png b/assets/tilemap.png index b336765460a48008cfa66ca7a72ecdc290c9aa51..49ffb3925e40fe5195012608f088696ccd8bd4de 100644 Binary files a/assets/tilemap.png and b/assets/tilemap.png differ diff --git a/source/engine/graphics/front/object/TileArray.cpp b/source/engine/graphics/front/object/TileArray.cpp index 9e1d4310a176bfb62bee19378e003a42fc6ce60a..475635b88783b1fe8b956d43f45d4e7fd15689b7 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 94e66b7858bca37a1e04ee36db955f7e63c090d8..c4191dc76ff1e2a79032889a7ab51104cf693088 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 b9c38e1c3c5e66585bcc6f710341838a0fa1189a..65d0899ba9fc8e5715ae10866d4b6b56e5e317ef 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 0000000000000000000000000000000000000000..a2c7fd743cefee7b97c9a961212e07f2eee1db0d --- /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 0000000000000000000000000000000000000000..326864a5c5d4d2e83e8a0795398efa405bc0c701 --- /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 0000000000000000000000000000000000000000..0058a3c29eac18546dc1eeeb1665439567a213fa --- /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 f2c6e96403b9b3c8bbab5b5eb985d7c5fc2e1aaf..8433087c2e2b919b4a0b4d45ca97aa2a6e267aa4 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 cd3854e79afa448ea19b23e72057695d22a4d2c9..a7b123f7d5dbbdfd8e4d920c9ccd74622246ff83 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 432e580d3050d5fef7d931cef2870e05e39caa00..0354e05f9e2b6ed89651a0b5bf15adbcd4ec45d5 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 92d17ce587f14bd678b1acf8f7e197c93edee22f..23028afe98a9de12cdd9d9bd5d685b1ac71a8bd1 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 41d8546172642a711035f6f5920a9db5fc32f471..d0d9811639d9bbf26f98a36a92af82969d68c016 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 38919d9583c54140134e9884d1bc475b1cd3e534..7a7f441e83dc878fec796d33bcd1eefee65688a0 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 80dbe5838d0f074d36ca63ab5a4389ccbef855ee..0000000000000000000000000000000000000000 --- 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 84cd925eb218d45048fd9056c2800a3af6290099..e0a917b1347466f9fa4767289a06eaaa85cea1a8 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 6a89a5063d744501372ac2bbc15fbebebb1e44cd..f6b7b7ab1af7a36e2f0d9a82af03056ae074010c 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 fbc9f1624166f1bc5067b8e55fb7631f956c8731..5d1420fe79bf821e1db8fb633c94f4c8f3875703 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 252c86febc0ed9e19759c805c3b42ea032e1b67a..83cd774011a25a2cf4fccbb408d0befbb0970a80 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 39f43c8d99dc92008f3dcc7fac8425fdead63982..bdbc02b043cb5284e96e337882b3ac95759a478d 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 9439be8a1cda62037de3440aff74cc4bf191478e..14e086b9367f7d46b0b41e98ae373db1be3a0547 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 7482b8daf87be9e443040387d46f2d6c7b477d45..427287505bf5493d6f5566773358bc6649e2722b 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 473b06ba38213184153cbacd95ff1519881927d2..c506453abbc56f5542c424f42c3acef95d015ac0 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 f74c85b15059d12dade4c44e1b3b8816491a8ecc..2e83bf9c9935970d04b3c96cb9b7f019e150349f 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 0000000000000000000000000000000000000000..d86d795c2f1bd9e8649fa8b44b77e87ba7624486 --- /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 0000000000000000000000000000000000000000..6d94db7ddc138673bbc4de9f3db321792dc1a26f --- /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 0000000000000000000000000000000000000000..b86d8155d8b4c8c869104028adccc02712f2c481 --- /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 0000000000000000000000000000000000000000..e10f34f3552c23b20aaa71603774c2a31bb8b5ff --- /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 0000000000000000000000000000000000000000..3210fcdfbe1b7f60b055768fc91eddaa5c0ac5d5 --- /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 0000000000000000000000000000000000000000..8ec7d35254127f697d93d44211bf2406bee8f96d --- /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 0000000000000000000000000000000000000000..eee3f716a81f363364e8c6981a3001f67522090d --- /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 7e2b54131757d688e6df70575aba411c63f5eec7..8be90fa12220cf26f616e24db38ddb3da4b90e6e 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 349c6de7ea426d426e2e56417a48acaa4c3cb7f9..40aaf1566d9fd3d977e42719ee6be4211f8a50ab 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 35b4732383d513041f05ccab6b0d9e01e8a92b66..0e63f12074d32ddbe48436810f4eb263d53fe9ab 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>