diff --git a/source/input.cpp b/source/input.cpp index c83a9e2..f61a770 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -9,22 +9,22 @@ #include // Para unordered_map, operator==, _Node_cons... #include // Para pair -// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado +// [SINGLETON] Input *Input::input_ = nullptr; -// [SINGLETON] Crearemos el objeto input con esta función estática +// [SINGLETON] Crearemos el objeto con esta función estática void Input::init(const std::string &game_controller_db_path) { Input::input_ = new Input(game_controller_db_path); } -// [SINGLETON] Destruiremos el objeto input con esta función estática +// [SINGLETON] Destruiremos el objeto con esta función estática void Input::destroy() { delete Input::input_; } -// [SINGLETON] Con este método obtenemos el objeto input y podemos trabajar con él +// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él Input *Input::get() { return Input::input_; diff --git a/source/input.h b/source/input.h index 678f988..f7f340c 100644 --- a/source/input.h +++ b/source/input.h @@ -64,7 +64,7 @@ enum class InputDeviceToUse : int class Input { private: - // [SINGLETON] Objeto screen privado para Don Melitón + // [SINGLETON] Objeto privado static Input *input_; struct KeyBindings @@ -109,13 +109,13 @@ private: ~Input() = default; public: - // [SINGLETON] Crearemos el objeto screen con esta función estática + // [SINGLETON] Crearemos el objeto con esta función estática static void init(const std::string &game_controller_db_path); - // [SINGLETON] Destruiremos el objeto screen con esta función estática + // [SINGLETON] Destruiremos el objeto con esta función estática static void destroy(); - // [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él + // [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él static Input *get(); // Asigna inputs a teclas diff --git a/source/screen.cpp b/source/screen.cpp index 8cd5380..9b6dde0 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -20,22 +20,22 @@ #include "jail_shader.h" // para init, render #endif -// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado +// [SINGLETON] Screen *Screen::screen_ = nullptr; -// [SINGLETON] Crearemos el objeto screen con esta función estática +// [SINGLETON] Crearemos el objeto con esta función estática void Screen::init(SDL_Window *window, SDL_Renderer *renderer) { Screen::screen_ = new Screen(window, renderer); } -// [SINGLETON] Destruiremos el objeto screen con esta función estática +// [SINGLETON] Destruiremos el objeto con esta función estática void Screen::destroy() { delete Screen::screen_; } -// [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él +// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él Screen *Screen::get() { return Screen::screen_; @@ -363,12 +363,6 @@ void Screen::attenuate(bool value) attenuate_effect_ = value; } -// Obtiene el puntero al renderizador -SDL_Renderer *Screen::getRenderer() -{ - return renderer_; -} - // Calcula los frames por segundo void Screen::updateFPS() { diff --git a/source/screen.h b/source/screen.h index 19fc15e..03ef08a 100644 --- a/source/screen.h +++ b/source/screen.h @@ -24,7 +24,7 @@ enum class ScreenVideoMode : int class Screen { private: - // [SINGLETON] Objeto screen privado para Don Melitón + // [SINGLETON] Objeto privado static Screen *screen_; // Objetos y punteros @@ -116,8 +116,6 @@ private: // Selecciona y ejecuta el método de renderizado adecuado basado en la configuración de shaders void renderScreen(); - // [SINGLETON] Ahora el constructor y el destructor son privados, para no poder crear objetos screen desde fuera - // Constructor Screen(SDL_Window *window, SDL_Renderer *renderer); @@ -125,13 +123,13 @@ private: ~Screen(); public: - // [SINGLETON] Crearemos el objeto screen con esta función estática + // [SINGLETON] Crearemos el objeto con esta función estática static void init(SDL_Window *window, SDL_Renderer *renderer); - // [SINGLETON] Destruiremos el objeto screen con esta función estática + // [SINGLETON] Destruiremos el objeto con esta función estática static void destroy(); - // [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él + // [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él static Screen *get(); // Actualiza la lógica de la clase @@ -182,6 +180,6 @@ public: // Atenua la pantalla void attenuate(bool value); - // Obtiene el puntero al renderizador - SDL_Renderer *getRenderer(); + // Getters + SDL_Renderer *getRenderer() { return renderer_; } }; \ No newline at end of file