Trabajando en el TITULO
This commit is contained in:
122
source/title.cpp
122
source/title.cpp
@@ -1,10 +1,9 @@
|
||||
#include "title.h"
|
||||
|
||||
// Constructor
|
||||
Title::Title(SDL_Window *window, SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang)
|
||||
Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t section)
|
||||
{
|
||||
// Copia las direcciones de los punteros
|
||||
mWindow = window;
|
||||
mRenderer = renderer;
|
||||
mScreen = screen;
|
||||
mInput = input;
|
||||
@@ -29,7 +28,6 @@ Title::Title(SDL_Window *window, SDL_Renderer *renderer, Screen *screen, Input *
|
||||
mText = new Text(mAsset->get("smb2.png"), mAsset->get("smb2.txt"), mRenderer);
|
||||
mText2 = new Text(mAsset->get("8bithud.png"), mAsset->get("8bithud.txt"), mRenderer);
|
||||
|
||||
|
||||
mMenu.title = new Menu(mRenderer, mAsset, mInput);
|
||||
mMenu.options = new Menu(mRenderer, mAsset, mInput);
|
||||
|
||||
@@ -39,81 +37,15 @@ Title::Title(SDL_Window *window, SDL_Renderer *renderer, Screen *screen, Input *
|
||||
{
|
||||
printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||
}
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Title::~Title()
|
||||
{
|
||||
mWindow = nullptr;
|
||||
mRenderer = nullptr;
|
||||
mScreen = nullptr;
|
||||
mInput = nullptr;
|
||||
mAsset = nullptr;
|
||||
mOptions = nullptr;
|
||||
mLang = nullptr;
|
||||
// Sonidos
|
||||
mSound = JA_LoadSound(mAsset->get("title.wav").c_str());
|
||||
|
||||
delete mEventHandler;
|
||||
mEventHandler = nullptr;
|
||||
|
||||
delete mText;
|
||||
mText = nullptr;
|
||||
|
||||
delete mText2;
|
||||
mText2 = nullptr;
|
||||
|
||||
delete mFade;
|
||||
mFade = nullptr;
|
||||
|
||||
mTitleTexture->unload();
|
||||
delete mTitleTexture;
|
||||
mTitleTexture = nullptr;
|
||||
|
||||
mItemsTexture->unload();
|
||||
delete mItemsTexture;
|
||||
mItemsTexture = nullptr;
|
||||
|
||||
delete mCoffeeBitmap;
|
||||
mCoffeeBitmap = nullptr;
|
||||
|
||||
delete mCrisisBitmap;
|
||||
mCrisisBitmap = nullptr;
|
||||
|
||||
delete mDustBitmapL;
|
||||
mDustBitmapL = nullptr;
|
||||
|
||||
delete mDustBitmapR;
|
||||
mDustBitmapR = nullptr;
|
||||
|
||||
delete mTile;
|
||||
mTile = nullptr;
|
||||
|
||||
delete mGradient;
|
||||
mGradient = nullptr;
|
||||
|
||||
delete mMenu.title;
|
||||
mMenu.title = nullptr;
|
||||
|
||||
delete mMenu.options;
|
||||
mMenu.options = nullptr;
|
||||
|
||||
mMenu.active = nullptr;
|
||||
|
||||
JA_DeleteSound(mSound);
|
||||
JA_DeleteMusic(mMusic);
|
||||
|
||||
SDL_DestroyTexture(mBackground);
|
||||
mBackground = nullptr;
|
||||
}
|
||||
|
||||
// Inicializa las variables necesarias para la sección 'Title'
|
||||
void Title::init(bool demo, Uint8 subsection)
|
||||
{
|
||||
// Carga los recursos
|
||||
loadMedia();
|
||||
// Musicas
|
||||
mMusic = JA_LoadMusic(mAsset->get("title.ogg").c_str());
|
||||
|
||||
// Inicializa variables
|
||||
mSection.name = PROG_SECTION_TITLE;
|
||||
mSection.subsection = subsection;
|
||||
mSection = section;
|
||||
mCounter = TITLE_COUNTER;
|
||||
mBackgroundCounter = 0;
|
||||
mBackgroundMode = rand() % 2;
|
||||
@@ -124,7 +56,7 @@ void Title::init(bool demo, Uint8 subsection)
|
||||
mTicks = 0;
|
||||
mTicksSpeed = 15;
|
||||
mFade->init(0x17, 0x17, 0x26);
|
||||
mDemo = demo;
|
||||
mDemo = false;
|
||||
|
||||
// Pone valores por defecto a las opciones de control
|
||||
mOptions->input[0].id = 0;
|
||||
@@ -233,7 +165,7 @@ void Title::init(bool demo, Uint8 subsection)
|
||||
mBackgroundWindow.h = GAME_HEIGHT;
|
||||
|
||||
// Inicializa los valores del vector con los valores del seno
|
||||
for (int i = 0; i < 360; i++)
|
||||
for (int i = 0; i < 360; ++i)
|
||||
{
|
||||
mSin[i] = SDL_sinf((float)i * 3.14f / 180.0f);
|
||||
}
|
||||
@@ -283,19 +215,32 @@ void Title::init(bool demo, Uint8 subsection)
|
||||
updateMenuLabels();
|
||||
}
|
||||
|
||||
// Carga los recursos necesarios para la sección 'Title'
|
||||
bool Title::loadMedia()
|
||||
// Destructor
|
||||
Title::~Title()
|
||||
{
|
||||
// Indicador de éxito en la carga
|
||||
bool success = true;
|
||||
mTitleTexture->unload();
|
||||
delete mTitleTexture;
|
||||
|
||||
// Sonidos
|
||||
mSound = JA_LoadSound(mAsset->get("title.wav").c_str());
|
||||
mItemsTexture->unload();
|
||||
delete mItemsTexture;
|
||||
|
||||
// Musicas
|
||||
mMusic = JA_LoadMusic(mAsset->get("title.ogg").c_str());
|
||||
delete mEventHandler;
|
||||
delete mText;
|
||||
delete mText2;
|
||||
delete mFade;
|
||||
delete mCoffeeBitmap;
|
||||
delete mCrisisBitmap;
|
||||
delete mDustBitmapL;
|
||||
delete mDustBitmapR;
|
||||
delete mTile;
|
||||
delete mGradient;
|
||||
delete mMenu.title;
|
||||
delete mMenu.options;
|
||||
|
||||
return success;
|
||||
JA_DeleteSound(mSound);
|
||||
JA_DeleteMusic(mMusic);
|
||||
|
||||
SDL_DestroyTexture(mBackground);
|
||||
}
|
||||
|
||||
// Cambia el valor de la variable de modo de pantalla completa
|
||||
@@ -505,10 +450,8 @@ void Title::applyOptions()
|
||||
}
|
||||
|
||||
// Bucle para el titulo del juego
|
||||
section_t Title::run(Uint8 subsection)
|
||||
section_t Title::run()
|
||||
{
|
||||
init(subsection);
|
||||
|
||||
while (mSection.name == PROG_SECTION_TITLE)
|
||||
{
|
||||
// Sección 1 - Titulo desplazandose
|
||||
@@ -683,7 +626,6 @@ section_t Title::run(Uint8 subsection)
|
||||
{
|
||||
runDemoGame();
|
||||
runInstructions(INSTRUCTIONS_MODE_AUTO);
|
||||
init(false);
|
||||
}
|
||||
else
|
||||
mSection.name = PROG_SECTION_LOGO;
|
||||
@@ -882,7 +824,6 @@ section_t Title::run(Uint8 subsection)
|
||||
{
|
||||
runDemoGame();
|
||||
runInstructions(INSTRUCTIONS_MODE_AUTO);
|
||||
init(false);
|
||||
}
|
||||
else
|
||||
mSection.name = PROG_SECTION_LOGO;
|
||||
@@ -893,7 +834,6 @@ section_t Title::run(Uint8 subsection)
|
||||
if (mSection.subsection == TITLE_SECTION_INSTRUCTIONS)
|
||||
{
|
||||
runInstructions(INSTRUCTIONS_MODE_AUTO);
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user