Files
LightYears/LightYearsEngine/include/framework/Application.h
2025-09-05 11:00:14 -05:00

42 lines
880 B
C++

#pragma once
#include "World.h"
#include "framework/Core.h"
#include <SFML/Graphics.hpp>
namespace ly {
class Application {
public:
Application(unsigned int windowWidth, unsigned int windowHeight, const std::string& title, sf::Uint32 style);
void Run();
template <typename WorldType>
weak<World> LoadWorld();
private:
void TickInternal(float deltaTime);
void RenderInternal();
virtual void Render();
virtual void Tick(float deltaTime);
sf::RenderWindow mWindow;
float mTargetFrameRate;
sf::Clock mTickClock;
sf::Clock mCleanCycleClock;
float mCleanCycleInterval;
shared<World> currentWorld;
};
template <typename WorldType>
inline weak<World> Application::LoadWorld() {
shared<WorldType> newWorld{new WorldType{this}};
currentWorld = newWorld;
currentWorld->BeginPlayInternal();
return newWorld;
}
} // namespace ly