Don melitonada la classe Asset
This commit is contained in:
@@ -1,6 +1,27 @@
|
|||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||||
|
Asset *Asset::asset = nullptr;
|
||||||
|
|
||||||
|
// [SINGLETON] Crearemos el objeto asset con esta función estática
|
||||||
|
void Asset::init(std::string executablePath)
|
||||||
|
{
|
||||||
|
Asset::asset = new Asset(executablePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto asset con esta función estática
|
||||||
|
void Asset::destroy()
|
||||||
|
{
|
||||||
|
delete Asset::asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él
|
||||||
|
Asset *Asset::get()
|
||||||
|
{
|
||||||
|
return Asset::asset;
|
||||||
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Asset::Asset(std::string executablePath)
|
Asset::Asset(std::string executablePath)
|
||||||
{
|
{
|
||||||
@@ -13,6 +34,12 @@ Asset::Asset(std::string executablePath)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
Asset::~Asset()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void Asset::add(std::string file, enum assetType type, bool required, bool absolute)
|
void Asset::add(std::string file, enum assetType type, bool required, bool absolute)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,13 +22,16 @@ enum assetType
|
|||||||
class Asset
|
class Asset
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// [SINGLETON] Objeto asset privado para Don Melitón
|
||||||
|
static Asset *asset;
|
||||||
|
|
||||||
// Estructura para definir un item
|
// Estructura para definir un item
|
||||||
struct item_t
|
struct item_t
|
||||||
{
|
{
|
||||||
std::string file; // Ruta del fichero desde la raiz del directorio
|
std::string file; // Ruta del fichero desde la raiz del directorio
|
||||||
enum assetType type; // Indica el tipo de recurso
|
enum assetType type; // Indica el tipo de recurso
|
||||||
bool required; // Indica si es un fichero que debe de existir
|
bool required; // Indica si es un fichero que debe de existir
|
||||||
//bool absolute; // Indica si la ruta que se ha proporcionado es una ruta absoluta
|
// bool absolute; // Indica si la ruta que se ha proporcionado es una ruta absoluta
|
||||||
};
|
};
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
@@ -43,10 +46,22 @@ private:
|
|||||||
// Devuelve el nombre del tipo de recurso
|
// Devuelve el nombre del tipo de recurso
|
||||||
std::string getTypeName(int type);
|
std::string getTypeName(int type);
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Asset(std::string path);
|
Asset(std::string path);
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Asset();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
||||||
|
static void init(std::string path);
|
||||||
|
|
||||||
|
// [SINGLETON] Destruiremos el objeto screen con esta función estática
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
|
// [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él
|
||||||
|
static Asset *get();
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void add(std::string file, enum assetType type, bool required = true, bool absolute = false);
|
void add(std::string file, enum assetType type, bool required = true, bool absolute = false);
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Background::Background(SDL_Renderer *renderer, Asset *asset)
|
Background::Background(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->asset = asset;
|
asset = Asset::get();
|
||||||
|
|
||||||
// Carga las texturas
|
// Carga las texturas
|
||||||
buildingsTexture = new Texture(renderer, asset->get("game_buildings.png"));
|
buildingsTexture = new Texture(renderer, asset->get("game_buildings.png"));
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Background(SDL_Renderer *renderer, Asset *asset);
|
Background(SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Background();
|
~Background();
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ Director::Director(int argc, char *argv[])
|
|||||||
createSystemFolder("jailgames/coffee_crisis_arcade_edition");
|
createSystemFolder("jailgames/coffee_crisis_arcade_edition");
|
||||||
|
|
||||||
// Crea el objeto que controla los ficheros de recursos
|
// Crea el objeto que controla los ficheros de recursos
|
||||||
asset = new Asset(executablePath);
|
Asset::init(executablePath);
|
||||||
|
asset = Asset::get();
|
||||||
|
|
||||||
// Si falta algún fichero no inicia el programa
|
// Si falta algún fichero no inicia el programa
|
||||||
if (!setFileList())
|
if (!setFileList())
|
||||||
@@ -72,7 +73,7 @@ Director::Director(int argc, char *argv[])
|
|||||||
input = new Input(asset->get("gamecontrollerdb.txt"));
|
input = new Input(asset->get("gamecontrollerdb.txt"));
|
||||||
initInput();
|
initInput();
|
||||||
|
|
||||||
Screen::Init(window, renderer, asset, input);
|
Screen::init(window, renderer, input);
|
||||||
screen = Screen::get();
|
screen = Screen::get();
|
||||||
|
|
||||||
// Carga los sonidos del juego
|
// Carga los sonidos del juego
|
||||||
@@ -86,9 +87,9 @@ Director::~Director()
|
|||||||
{
|
{
|
||||||
saveOptionsFile(asset->get("config.txt"));
|
saveOptionsFile(asset->get("config.txt"));
|
||||||
|
|
||||||
delete asset;
|
|
||||||
delete input;
|
delete input;
|
||||||
Screen::Destroy();
|
Asset::destroy();
|
||||||
|
Screen::destroy();
|
||||||
|
|
||||||
deleteSounds();
|
deleteSounds();
|
||||||
deleteMusics();
|
deleteMusics();
|
||||||
@@ -597,7 +598,7 @@ void Director::deleteMusics()
|
|||||||
// Ejecuta la sección con el logo
|
// Ejecuta la sección con el logo
|
||||||
void Director::runLogo()
|
void Director::runLogo()
|
||||||
{
|
{
|
||||||
logo = new Logo(asset, input);
|
logo = new Logo(input);
|
||||||
logo->run();
|
logo->run();
|
||||||
delete logo;
|
delete logo;
|
||||||
}
|
}
|
||||||
@@ -605,7 +606,7 @@ void Director::runLogo()
|
|||||||
// Ejecuta la sección con la secuencia de introducción
|
// Ejecuta la sección con la secuencia de introducción
|
||||||
void Director::runIntro()
|
void Director::runIntro()
|
||||||
{
|
{
|
||||||
intro = new Intro(asset, input, getMusic(musics, "intro.ogg"));
|
intro = new Intro(input, getMusic(musics, "intro.ogg"));
|
||||||
intro->run();
|
intro->run();
|
||||||
delete intro;
|
delete intro;
|
||||||
}
|
}
|
||||||
@@ -613,7 +614,7 @@ void Director::runIntro()
|
|||||||
// Ejecuta la sección con el titulo del juego
|
// Ejecuta la sección con el titulo del juego
|
||||||
void Director::runTitle()
|
void Director::runTitle()
|
||||||
{
|
{
|
||||||
title = new Title(asset, input, getMusic(musics, "title.ogg"));
|
title = new Title(input, getMusic(musics, "title.ogg"));
|
||||||
title->run();
|
title->run();
|
||||||
delete title;
|
delete title;
|
||||||
}
|
}
|
||||||
@@ -621,9 +622,9 @@ void Director::runTitle()
|
|||||||
// Ejecuta la sección donde se juega al juego
|
// Ejecuta la sección donde se juega al juego
|
||||||
void Director::runGame()
|
void Director::runGame()
|
||||||
{
|
{
|
||||||
const int playerID = section::options;
|
const int playerID = section::options == section::OPTIONS_GAME_PLAY_1P ? 1 : 2;
|
||||||
const int currentStage = 0;
|
const int currentStage = 0;
|
||||||
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, asset, input, getMusic(musics, "playing.ogg"));
|
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, input, getMusic(musics, "playing.ogg"));
|
||||||
game->run();
|
game->run();
|
||||||
delete game;
|
delete game;
|
||||||
}
|
}
|
||||||
@@ -631,7 +632,7 @@ void Director::runGame()
|
|||||||
// Ejecuta la sección donde se muestran las instrucciones
|
// Ejecuta la sección donde se muestran las instrucciones
|
||||||
void Director::runInstructions()
|
void Director::runInstructions()
|
||||||
{
|
{
|
||||||
instructions = new Instructions(asset, input, getMusic(musics, "title.ogg"));
|
instructions = new Instructions(input, getMusic(musics, "title.ogg"));
|
||||||
instructions->run();
|
instructions->run();
|
||||||
delete instructions;
|
delete instructions;
|
||||||
}
|
}
|
||||||
@@ -639,7 +640,7 @@ void Director::runInstructions()
|
|||||||
// Ejecuta la sección donde se muestra la tabla de puntuaciones
|
// Ejecuta la sección donde se muestra la tabla de puntuaciones
|
||||||
void Director::runHiScoreTable()
|
void Director::runHiScoreTable()
|
||||||
{
|
{
|
||||||
hiScoreTable = new HiScoreTable(asset, input, getMusic(musics, "title.ogg"));
|
hiScoreTable = new HiScoreTable(input, getMusic(musics, "title.ogg"));
|
||||||
hiScoreTable->run();
|
hiScoreTable->run();
|
||||||
delete hiScoreTable;
|
delete hiScoreTable;
|
||||||
}
|
}
|
||||||
@@ -649,7 +650,7 @@ void Director::runDemoGame()
|
|||||||
{
|
{
|
||||||
const int playerID = (rand() % 2) + 1;
|
const int playerID = (rand() % 2) + 1;
|
||||||
const int currentStage = 0;
|
const int currentStage = 0;
|
||||||
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, asset, input, nullptr);
|
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, input, nullptr);
|
||||||
demoGame->run();
|
demoGame->run();
|
||||||
delete demoGame;
|
delete demoGame;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
#define GAME_OVER_COUNTER 350
|
#define GAME_OVER_COUNTER 350
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(int playerID, int currentStage, bool demo, Asset *asset, Input *input, JA_Music_t *music)
|
Game::Game(int playerID, int currentStage, bool demo, Input *input, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
screen = Screen::get();
|
screen = Screen::get();
|
||||||
this->asset = asset;
|
asset = Asset::get();
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
renderer = screen->getRenderer();
|
renderer = screen->getRenderer();
|
||||||
@@ -23,8 +23,8 @@ Game::Game(int playerID, int currentStage, bool demo, Asset *asset, Input *input
|
|||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
fade = new Fade(renderer);
|
fade = new Fade(renderer);
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
scoreboard = new Scoreboard(renderer, asset);
|
scoreboard = new Scoreboard(renderer);
|
||||||
background = new Background(renderer, asset);
|
background = new Background(renderer);
|
||||||
explosions = new Explosions();
|
explosions = new Explosions();
|
||||||
enemyFormations = new EnemyFormations();
|
enemyFormations = new EnemyFormations();
|
||||||
|
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(int playerID, int currentStage, bool demo, Asset *asset, Input *input, JA_Music_t *music);
|
Game(int playerID, int currentStage, bool demo, Input *input, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
GameLogo::GameLogo(Asset *asset, int x, int y)
|
GameLogo::GameLogo(int x, int y)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
screen = Screen::get();
|
screen = Screen::get();
|
||||||
renderer = screen->getRenderer();
|
renderer = screen->getRenderer();
|
||||||
this->asset = asset;
|
asset = Asset::get();
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
GameLogo(Asset *asset, int x, int y);
|
GameLogo(int x, int y);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~GameLogo();
|
~GameLogo();
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
HiScoreTable::HiScoreTable(Asset *asset, Input *input, JA_Music_t *music)
|
HiScoreTable::HiScoreTable(Input *input, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
screen = Screen::get();
|
screen = Screen::get();
|
||||||
this->asset = asset;
|
asset = Asset::get();
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
renderer = screen->getRenderer();
|
renderer = screen->getRenderer();
|
||||||
@@ -16,7 +16,7 @@ HiScoreTable::HiScoreTable(Asset *asset, Input *input, JA_Music_t *music)
|
|||||||
// Objetos
|
// Objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
fade = new Fade(renderer);
|
fade = new Fade(renderer);
|
||||||
background = new Background(renderer, asset);
|
background = new Background(renderer);
|
||||||
text = new Text(asset->get("smb2.gif"), asset->get("smb2.txt"), renderer);
|
text = new Text(asset->get("smb2.gif"), asset->get("smb2.txt"), renderer);
|
||||||
|
|
||||||
// Crea un backbuffer para el renderizador
|
// Crea un backbuffer para el renderizador
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
HiScoreTable(Asset *asset, Input *input, JA_Music_t *music);
|
HiScoreTable(Input *input, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~HiScoreTable();
|
~HiScoreTable();
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Instructions::Instructions(Asset *asset, Input *input, JA_Music_t *music)
|
Instructions::Instructions(Input *input, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
screen = Screen::get();
|
|
||||||
this->asset = asset;
|
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
|
screen = Screen::get();
|
||||||
|
asset = Asset::get();
|
||||||
renderer = screen->getRenderer();
|
renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Crea objetos
|
// Crea objetos
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Instructions(Asset *asset, Input *input, JA_Music_t *music);
|
Instructions(Input *input, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Instructions();
|
~Instructions();
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro::Intro(Asset *asset, Input *input, JA_Music_t *music)
|
Intro::Intro(Input *input, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
screen = Screen::get();
|
|
||||||
this->asset = asset;
|
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
|
asset = Asset::get();
|
||||||
|
screen = Screen::get();
|
||||||
SDL_Renderer *renderer = screen->getRenderer();
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro(Asset *asset, Input *input, JA_Music_t *music);
|
Intro(Input *input, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Intro();
|
~Intro();
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(Asset *asset, Input *input)
|
Logo::Logo(Input *input)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
screen = Screen::get();
|
|
||||||
this->asset = asset;
|
|
||||||
this->input = input;
|
this->input = input;
|
||||||
|
screen = Screen::get();
|
||||||
|
asset = Asset::get();
|
||||||
SDL_Renderer *renderer = screen->getRenderer();
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo(Asset *asset, Input *input);
|
Logo(Input *input);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Logo();
|
~Logo();
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Scoreboard::Scoreboard(SDL_Renderer *renderer, Asset *asset)
|
Scoreboard::Scoreboard(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->asset = asset;
|
asset = Asset::get();
|
||||||
|
|
||||||
// Inicializa punteros
|
// Inicializa punteros
|
||||||
gamePowerMeterTexture = nullptr;
|
gamePowerMeterTexture = nullptr;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Scoreboard(SDL_Renderer *renderer, Asset *asset);
|
Scoreboard(SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Scoreboard();
|
~Scoreboard();
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
Screen *Screen::screen = nullptr;
|
Screen *Screen::screen = nullptr;
|
||||||
|
|
||||||
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
||||||
void Screen::Init(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input)
|
void Screen::init(SDL_Window *window, SDL_Renderer *renderer, Input *input)
|
||||||
{
|
{
|
||||||
Screen::screen = new Screen(window, renderer, asset, input);
|
Screen::screen = new Screen(window, renderer, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [SINGLETON] Destruiremos el objeto screen con esta función estática
|
// [SINGLETON] Destruiremos el objeto screen con esta función estática
|
||||||
void Screen::Destroy()
|
void Screen::destroy()
|
||||||
{
|
{
|
||||||
delete Screen::screen;
|
delete Screen::screen;
|
||||||
}
|
}
|
||||||
@@ -31,13 +31,13 @@ Screen *Screen::get()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input)
|
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Input *input)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
this->window = window;
|
this->window = window;
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->asset = asset;
|
|
||||||
this->input = input;
|
this->input = input;
|
||||||
|
asset = Asset::get();
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
SDL_GetRendererOutputSize(renderer, &windowWidth, &windowHeight);
|
SDL_GetRendererOutputSize(renderer, &windowWidth, &windowHeight);
|
||||||
|
|||||||
@@ -81,17 +81,17 @@ private:
|
|||||||
// [SINGLETON] Ahora el constructor y el destructor son privados, para no poder crear objetos screen desde fuera
|
// [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, Asset *asset, Input *input);
|
Screen(SDL_Window *window, SDL_Renderer *renderer, Input *input);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Screen();
|
~Screen();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
||||||
static void Init(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input);
|
static void init(SDL_Window *window, SDL_Renderer *renderer, Input *input);
|
||||||
|
|
||||||
// [SINGLETON] Destruiremos el objeto screen con esta función estática
|
// [SINGLETON] Destruiremos el objeto screen 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 screen y podemos trabajar con él
|
||||||
static Screen *get();
|
static Screen *get();
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Title::Title(Asset *asset, Input *input, JA_Music_t *music)
|
Title::Title(Input *input, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia las direcciones de los punteros y objetos
|
// Copia las direcciones de los punteros y objetos
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->asset = asset;
|
|
||||||
this->music = music;
|
this->music = music;
|
||||||
|
asset = Asset::get();
|
||||||
screen = Screen::get();
|
screen = Screen::get();
|
||||||
SDL_Renderer *renderer = screen->getRenderer();
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ Title::Title(Asset *asset, Input *input, JA_Music_t *music)
|
|||||||
|
|
||||||
tiledbg = new Tiledbg(asset->get("title_bg_tile.png"), {0, 0, param.game.width, param.game.height}, TILED_MODE_RANDOM);
|
tiledbg = new Tiledbg(asset->get("title_bg_tile.png"), {0, 0, param.game.width, param.game.height}, TILED_MODE_RANDOM);
|
||||||
|
|
||||||
gameLogo = new GameLogo(asset, param.game.gameArea.centerX, param.title.titleCCPosition);
|
gameLogo = new GameLogo(param.game.gameArea.centerX, param.title.titleCCPosition);
|
||||||
gameLogo->enable();
|
gameLogo->enable();
|
||||||
|
|
||||||
defineButtons = new DefineButtons(input, text2);
|
defineButtons = new DefineButtons(input, text2);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Title(Asset *asset, Input *input, JA_Music_t *music);
|
Title(Input *input, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Title();
|
~Title();
|
||||||
|
|||||||
Reference in New Issue
Block a user