diff --git a/source/core/eventmanager.hpp b/source/core/eventmanager.hpp new file mode 100644 index 0000000..9516537 --- /dev/null +++ b/source/core/eventmanager.hpp @@ -0,0 +1,27 @@ +// eventmanager.hpp + +#include + +class EventManager { + public: + void update() { + SDL_Event event; + + while (SDL_PollEvent(&event)) { + if (event.type == SDL_EVENT_QUIT || + event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED) { + if (!quit) { + quit = true; + SDL_LogInfo( + SDL_LOG_CATEGORY_APPLICATION, + "Someone wants to quit!"); + } + } + } + } + + auto wantToQuit() -> bool { return quit; } + + private: + bool quit{false}; +}; \ No newline at end of file diff --git a/source/core/rendering/video.cpp b/source/core/rendering/video.cpp index 6e45a84..22d2ada 100644 --- a/source/core/rendering/video.cpp +++ b/source/core/rendering/video.cpp @@ -30,7 +30,7 @@ auto Video::initSDL() -> int { return 1; } - window_ = SDL_CreateWindow("Mi ventana", config_.width, config_.height, 0); + window_ = SDL_CreateWindow(config_.window_caption.c_str(), config_.width, config_.height, 0); if (window_ == nullptr) { SDL_Log("No se pudo crear la ventana: %s", SDL_GetError()); cleanup(); @@ -46,8 +46,8 @@ auto Video::initSDL() -> int { return 1; } - // SDL_SetRenderVSync(renderer_, config_.vsync ? 1 : 0); - // SDL_SetRenderLogicalPresentation(renderer_, GameCanvas::WIDTH, GameCanvas::HEIGHT, toSdlPresentation(config_.scaling_mode)); + SDL_SetRenderVSync(renderer_, config_.vsync ? 1 : 0); + SDL_SetRenderLogicalPresentation(renderer_, config_.width * config_.zoom, config_.height * config_.zoom, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE); game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, config_.width, config_.height); if (game_texture_ == nullptr) { diff --git a/source/core/rendering/video.hpp b/source/core/rendering/video.hpp index cfbe439..00b429d 100644 --- a/source/core/rendering/video.hpp +++ b/source/core/rendering/video.hpp @@ -3,14 +3,17 @@ #pragma once #include +#include class Video { public: struct Config { bool fullscreen{false}; - float zoom{1.0F}; + float zoom{2.0F}; float width{320.0F}; float height{240.0F}; + std::string window_caption{}; + bool vsync{true}; }; Video(Config config); diff --git a/source/game/context.hpp b/source/game/context.hpp new file mode 100644 index 0000000..8f723f7 --- /dev/null +++ b/source/game/context.hpp @@ -0,0 +1,10 @@ +// context.hpp + +#pragma once + +enum class Scenes; + +struct Context { + Scenes current_scene; + bool want_to_quit{false}; +}; diff --git a/source/game/defaults.hpp b/source/game/defaults.hpp index 9d18006..7ca8414 100644 --- a/source/game/defaults.hpp +++ b/source/game/defaults.hpp @@ -2,9 +2,16 @@ #pragma once +#include + namespace Defaults::Video { constexpr int ZOOM = 3; constexpr bool FULLSCREEN = false; constexpr float WIDTH = 320.0F; constexpr float HEIGHT = 240.0F; -} // namespace Defaults::Video \ No newline at end of file + constexpr bool VSYNC = true; +} // namespace Defaults::Video + +namespace Defaults::App { + constexpr std::string_view NAME = "Spectrum Engine"; +} // namespace Defaults::App \ No newline at end of file diff --git a/source/game/director.cpp b/source/game/director.cpp index 69e2e90..c578975 100644 --- a/source/game/director.cpp +++ b/source/game/director.cpp @@ -16,17 +16,23 @@ Director::Director() { // Inicializa los subsistemas video_ = std::make_unique