canvi de pc
This commit is contained in:
@@ -9,22 +9,22 @@
|
|||||||
#include <unordered_map> // Para unordered_map, operator==, _Node_cons...
|
#include <unordered_map> // Para unordered_map, operator==, _Node_cons...
|
||||||
#include <utility> // Para pair
|
#include <utility> // Para pair
|
||||||
|
|
||||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
// [SINGLETON]
|
||||||
Input *Input::input_ = nullptr;
|
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)
|
void Input::init(const std::string &game_controller_db_path)
|
||||||
{
|
{
|
||||||
Input::input_ = new Input(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()
|
void Input::destroy()
|
||||||
{
|
{
|
||||||
delete Input::input_;
|
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()
|
Input *Input::get()
|
||||||
{
|
{
|
||||||
return Input::input_;
|
return Input::input_;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ enum class InputDeviceToUse : int
|
|||||||
class Input
|
class Input
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// [SINGLETON] Objeto screen privado para Don Melitón
|
// [SINGLETON] Objeto privado
|
||||||
static Input *input_;
|
static Input *input_;
|
||||||
|
|
||||||
struct KeyBindings
|
struct KeyBindings
|
||||||
@@ -109,13 +109,13 @@ private:
|
|||||||
~Input() = default;
|
~Input() = default;
|
||||||
|
|
||||||
public:
|
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);
|
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();
|
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();
|
static Input *get();
|
||||||
|
|
||||||
// Asigna inputs a teclas
|
// Asigna inputs a teclas
|
||||||
|
|||||||
@@ -20,22 +20,22 @@
|
|||||||
#include "jail_shader.h" // para init, render
|
#include "jail_shader.h" // para init, render
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
// [SINGLETON]
|
||||||
Screen *Screen::screen_ = nullptr;
|
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)
|
void Screen::init(SDL_Window *window, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
Screen::screen_ = new Screen(window, 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()
|
void Screen::destroy()
|
||||||
{
|
{
|
||||||
delete Screen::screen_;
|
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()
|
Screen *Screen::get()
|
||||||
{
|
{
|
||||||
return Screen::screen_;
|
return Screen::screen_;
|
||||||
@@ -363,12 +363,6 @@ void Screen::attenuate(bool value)
|
|||||||
attenuate_effect_ = value;
|
attenuate_effect_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el puntero al renderizador
|
|
||||||
SDL_Renderer *Screen::getRenderer()
|
|
||||||
{
|
|
||||||
return renderer_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calcula los frames por segundo
|
// Calcula los frames por segundo
|
||||||
void Screen::updateFPS()
|
void Screen::updateFPS()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ enum class ScreenVideoMode : int
|
|||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// [SINGLETON] Objeto screen privado para Don Melitón
|
// [SINGLETON] Objeto privado
|
||||||
static Screen *screen_;
|
static Screen *screen_;
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
@@ -116,8 +116,6 @@ private:
|
|||||||
// Selecciona y ejecuta el método de renderizado adecuado basado en la configuración de shaders
|
// Selecciona y ejecuta el método de renderizado adecuado basado en la configuración de shaders
|
||||||
void renderScreen();
|
void renderScreen();
|
||||||
|
|
||||||
// [SINGLETON] Ahora el constructor y el destructor son privados, para no poder crear objetos screen desde fuera
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Screen(SDL_Window *window, SDL_Renderer *renderer);
|
Screen(SDL_Window *window, SDL_Renderer *renderer);
|
||||||
|
|
||||||
@@ -125,13 +123,13 @@ private:
|
|||||||
~Screen();
|
~Screen();
|
||||||
|
|
||||||
public:
|
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);
|
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();
|
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();
|
static Screen *get();
|
||||||
|
|
||||||
// Actualiza la lógica de la clase
|
// Actualiza la lógica de la clase
|
||||||
@@ -182,6 +180,6 @@ public:
|
|||||||
// Atenua la pantalla
|
// Atenua la pantalla
|
||||||
void attenuate(bool value);
|
void attenuate(bool value);
|
||||||
|
|
||||||
// Obtiene el puntero al renderizador
|
// Getters
|
||||||
SDL_Renderer *getRenderer();
|
SDL_Renderer *getRenderer() { return renderer_; }
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user