Files
DemoGame/include/Engine/Globals.h
Redacted fd98c308f5 Threaded ticks
TODO make movable objects use velocity so rendering still looks smooth when things move
2025-01-08 00:58:27 -05:00

38 lines
826 B
C++

#pragma once
#include <Engine/types/Scene.h>
#include <Engine/types/GameWindow.h>
namespace Globals {
using namespace Engine;
inline std::vector<Scene*> SceneList{};
inline Scene* CurrentScene = nullptr;
inline DemoGameWindow* Window = nullptr;
inline void ChangeScene(Scene* scene)
{
if (CurrentScene != nullptr)
CurrentScene->Unload();
CurrentScene = scene;
if (CurrentScene != nullptr) {
CurrentScene->Init();
CurrentScene->Run();
}
}
inline bool ChangeScene (const std::string& scene_name)
{
Scene* scene = nullptr;
for (auto* s : SceneList)
if (s->GetName() == scene_name)
scene = s;
if (scene)
ChangeScene(scene);
return scene;
}
}