54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
// director.cpp
|
|
|
|
#include "director.hpp"
|
|
|
|
#include <cstdint>
|
|
|
|
#include "core/rendering/video.hpp"
|
|
#include "defaults.hpp"
|
|
#include "game/scenes/scenes.hpp"
|
|
#include "game/scenes/test.hpp"
|
|
|
|
Director::Director() {
|
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
|
"Game start!");
|
|
|
|
// Inicializa los subsistemas
|
|
video_ = std::make_unique<Video>(
|
|
Video::Config{
|
|
.fullscreen = Defaults::Video::FULLSCREEN,
|
|
.zoom = Defaults::Video::ZOOM,
|
|
.width = Defaults::Video::WIDTH,
|
|
.height = Defaults::Video::HEIGHT,
|
|
.window_caption = Defaults::App::NAME.data(),
|
|
.vsync = Defaults::Video::VSYNC});
|
|
timer_ = std::make_unique<Timer>();
|
|
event_manager_ = std::make_unique<EventManager>();
|
|
|
|
subsystems_.video = video_.get();
|
|
|
|
// Inicializa el contexto
|
|
context_.current_scene = Scenes::TEST;
|
|
context_.want_to_quit = false;
|
|
|
|
// Establece la escena inicial
|
|
scene_ = std::make_unique<Test>(subsystems_, context_);
|
|
}
|
|
|
|
Director::~Director() {
|
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
|
"Bye!");
|
|
SDL_Quit();
|
|
}
|
|
|
|
auto Director::iterate() -> int {
|
|
while (!context_.want_to_quit) {
|
|
scene_->render();
|
|
scene_->update(timer_->getDelta());
|
|
|
|
event_manager_->update();
|
|
context_.want_to_quit = event_manager_->wantToQuit();
|
|
}
|
|
|
|
return 0;
|
|
} |