Las clases text y menu ya acceden a resource

This commit is contained in:
2022-10-27 12:43:28 +02:00
parent 4133dfd7c9
commit 9d9d9d92f2
13 changed files with 51 additions and 26 deletions

View File

@@ -30,13 +30,13 @@ Director::Director(std::string path)
initJailAudio();
// Crea los objetos
resource = new Resource(renderer, asset, options);
input = new Input(asset->get("gamecontrollerdb.txt"));
initInput();
screen = new Screen(window, renderer, options, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
screen->setBorderColor(borderColor);
screen->setVideoMode(options->fullScreenMode);
resource = new Resource(renderer, asset, options);
debug = new Debug(renderer, screen, asset);
debug = new Debug(renderer, screen, resource, asset);
music = JA_LoadMusic(asset->get("title.ogg").c_str());
}
@@ -51,6 +51,7 @@ Director::~Director()
delete input;
delete screen;
delete debug;
delete resource;
JA_DeleteMusic(music);
SDL_DestroyRenderer(renderer);
@@ -205,6 +206,7 @@ void Director::loadResources(section_t section)
std::vector<std::string> textureList;
textureList.push_back("loading_screen_color.png");
textureList.push_back("loading_screen_color_zxarne.png");
textureList.push_back("smb2.png");
resource->loadTextures(textureList);
}
@@ -213,6 +215,7 @@ void Director::loadResources(section_t section)
{
std::vector<std::string> textureList;
textureList.push_back("shine.png");
textureList.push_back("smb2.png");
resource->loadTextures(textureList);
}
@@ -775,6 +778,8 @@ void Director::setSection(section_t section)
// Ejecuta la seccion de juego con el logo
void Director::runLogo()
{
std::cout << std::endl
<< "* SECTION: LOGO" << std::endl;
loadResources(section);
logo = new Logo(renderer, screen, resource, asset, options, section.subsection);
setSection(logo->run());
@@ -785,6 +790,8 @@ void Director::runLogo()
// Ejecuta la seccion de juego de la introducción
void Director::runIntro()
{
std::cout << std::endl
<< "* SECTION: INTRO" << std::endl;
loadResources(section);
intro = new Intro(renderer, screen, resource, asset, options);
setSection(intro->run());
@@ -795,6 +802,8 @@ void Director::runIntro()
// Ejecuta la seccion de juego con el titulo y los menus
void Director::runTitle()
{
std::cout << std::endl
<< "* SECTION: TITLE" << std::endl;
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
JA_PlayMusic(music);
@@ -809,6 +818,8 @@ void Director::runTitle()
// Ejecuta la seccion de los creditos del juego
void Director::runCredits()
{
std::cout << std::endl
<< "* SECTION: CREDITS" << std::endl;
loadResources(section);
credits = new Credits(renderer, screen, resource, asset, options);
setSection(credits->run());
@@ -819,6 +830,8 @@ void Director::runCredits()
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
void Director::runDemo()
{
std::cout << std::endl
<< "* SECTION: DEMO" << std::endl;
loadResources(section);
demo = new Demo(renderer, screen, resource, asset, options, debug);
setSection(demo->run());
@@ -829,6 +842,8 @@ void Director::runDemo()
// Ejecuta la seccion de juego donde se juega
void Director::runGame()
{
std::cout << std::endl
<< "* SECTION: GAME" << std::endl;
JA_StopMusic();
loadResources(section);
game = new Game(renderer, screen, resource, asset, options, input, debug);