diff --git a/src/game/depth_renderer.cpp b/src/game/depth_renderer.cpp new file mode 100644 index 0000000..3dced1a --- /dev/null +++ b/src/game/depth_renderer.cpp @@ -0,0 +1,14 @@ +#include "depth_renderer.hpp" + +void DepthRenderer::addGameObject(const std::shared_ptr& gameObject) +{ + // TODO: Subscribe to depth changes! + gameObjects.insert(gameObject); +} + +void DepthRenderer::render(const std::shared_ptr &window) const +{ + for (const auto& gameObject : gameObjects) { + gameObject->draw(window.get()); + } +} diff --git a/src/game/depth_renderer.hpp b/src/game/depth_renderer.hpp new file mode 100644 index 0000000..0ac31b9 --- /dev/null +++ b/src/game/depth_renderer.hpp @@ -0,0 +1,24 @@ +#ifndef HOLESOME_DEPTH_RENDERER_HPP +#define HOLESOME_DEPTH_RENDERER_HPP + + +#include +#include "game_object.h" + +auto compareGameObjectDepth = [](const std::shared_ptr& a, const std::shared_ptr& b) { return a->coordinates->isometric().depth < b->coordinates->isometric().depth; }; + +class DepthRenderer +{ +public: + DepthRenderer() = default; + + void addGameObject(const std::shared_ptr& gameObject); + + void render(const std::shared_ptr& window) const; + +private: + std::multiset, decltype(compareGameObjectDepth)> gameObjects; +}; + + +#endif //HOLESOME_DEPTH_RENDERER_HPP