A small game engine for 2D games based of Raylib
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
534 B

пре 11 месеци
  1. #pragma once
  2. #include <memory>
  3. #include <vector>
  4. #include <chrono>
  5. #include "entity.h"
  6. namespace ant::core {
  7. struct scene {
  8. static std::shared_ptr<scene> current;
  9. std::vector<std::shared_ptr<entity>> root_nodes;
  10. void update(std::chrono::duration<double> delta_time) {
  11. for (auto &elem: root_nodes) {
  12. elem->update(delta_time);
  13. }
  14. }
  15. void render() {
  16. for (auto &elem: root_nodes | std::views::filter([](const std::shared_ptr<entity>& elem){return elem->visibility_flag();})) {
  17. elem->render();
  18. }
  19. }
  20. };
  21. }