Initial ideas

This commit is contained in:
Maximilian Giller 2023-06-02 20:24:04 +02:00
parent 543c9e9728
commit 075cb5977e
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,14 @@
#include "depth_renderer.hpp"
void DepthRenderer::addGameObject(const std::shared_ptr<GameObject>& gameObject)
{
// TODO: Subscribe to depth changes!
gameObjects.insert(gameObject);
}
void DepthRenderer::render(const std::shared_ptr<sf::RenderWindow> &window) const
{
for (const auto& gameObject : gameObjects) {
gameObject->draw(window.get());
}
}

View file

@ -0,0 +1,24 @@
#ifndef HOLESOME_DEPTH_RENDERER_HPP
#define HOLESOME_DEPTH_RENDERER_HPP
#include <set>
#include "game_object.h"
auto compareGameObjectDepth = [](const std::shared_ptr<GameObject>& a, const std::shared_ptr<GameObject>& b) { return a->coordinates->isometric().depth < b->coordinates->isometric().depth; };
class DepthRenderer
{
public:
DepthRenderer() = default;
void addGameObject(const std::shared_ptr<GameObject>& gameObject);
void render(const std::shared_ptr<sf::RenderWindow>& window) const;
private:
std::multiset<std::shared_ptr<GameObject>, decltype(compareGameObjectDepth)> gameObjects;
};
#endif //HOLESOME_DEPTH_RENDERER_HPP