diff --git a/source/title.cpp b/source/title.cpp index 62b4c91..dd69503 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -1,14 +1,14 @@ #include "title.h" // Constructor -Title::Title(SDL_Window *window, SDL_Renderer *renderer, Screen *screen, Input *input, Asset *mAsset, options_t *options, Lang *lang) +Title::Title(SDL_Window *window, SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang) { // Copia las direcciones de los punteros mWindow = window; mRenderer = renderer; mScreen = screen; mInput = input; - this->mAsset = mAsset; + mAsset = asset; mOptions = options; mLang = lang; @@ -24,12 +24,14 @@ Title::Title(SDL_Window *window, SDL_Renderer *renderer, Screen *screen, Input * mDustBitmapL = new AnimatedSprite(mTitleTexture, mRenderer); mDustBitmapR = new AnimatedSprite(mTitleTexture, mRenderer); - mTile = new Sprite(); - mGradient = new Sprite(); + mTile = new Sprite({0, 0, 64, 64}, mTitleTexture, mRenderer); + mGradient = new Sprite({0, 0, 256, 192}, mTitleTexture, mRenderer); 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(this->mRenderer, this->mInput, this->mAsset); - mMenu.options = new Menu(mRenderer, mInput, mAsset); + + + mMenu.title = new Menu(mRenderer, mAsset, mInput); + mMenu.options = new Menu(mRenderer, mAsset, mInput); // Crea la textura para el mosaico de fondo mBackground = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH * 2, GAME_HEIGHT * 2); @@ -217,7 +219,6 @@ void Title::init(bool demo, Uint8 subsection) mDustBitmapL->setAnimationFrames(0, 6, 160 + (mDustBitmapL->getWidth() * 6), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight()); // Inicializa el sprite con el degradado - mGradient->init(0, 0, 256, 192, mTitleTexture, mRenderer); mGradient->setSpriteClip(0, 96, 256, 192); // Inicializa el vector de eventos de la pantalla de titulo @@ -610,8 +611,8 @@ section_t Title::run(Uint8 subsection) mCrisisBitmap->setPosX(b + v[n / 3]); mCoffeeBitmap->render(); mCrisisBitmap->render(); - mDustBitmapR->animate(0); - mDustBitmapL->animate(0); + mDustBitmapR->animate(); + mDustBitmapL->animate(); mDustBitmapR->render(); mDustBitmapL->render(); @@ -861,8 +862,8 @@ section_t Title::run(Uint8 subsection) mMenu.active->render(); } - mDustBitmapR->animate(0); - mDustBitmapL->animate(0); + mDustBitmapR->animate(); + mDustBitmapL->animate(); mDustBitmapR->render(); mDustBitmapL->render(); @@ -975,7 +976,6 @@ void Title::createTiledBackground() SDL_SetRenderDrawColor(mRenderer, 0x43, 0x43, 0x4F, 0xFF); SDL_RenderClear(mRenderer); - mTile->init(0, 0, 64, 64, mTitleTexture, mRenderer); mTile->setSpriteClip(192, 0, 64, 64); for (int i = 0; i < 8; i++) for (int j = 0; j < 6; j++) diff --git a/source/title.h b/source/title.h index 6e9445c..dd5e5bc 100644 --- a/source/title.h +++ b/source/title.h @@ -36,39 +36,39 @@ private: SDL_Window *mWindow; // Ventana de la aplicación SDL_Renderer *mRenderer; // El renderizador de la ventana Screen *mScreen; // Objeto encargado de dibujar en pantalla + Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos + Input *mInput; // Objeto para leer las entradas de teclado o mando + Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas + SDL_Event *mEventHandler; // Manejador de eventos AnimatedSprite *mDustBitmapL; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo AnimatedSprite *mDustBitmapR; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo - bool mMenuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente - float mSin[360]; // Vector con los valores del seno precalculados JA_Music mMusic; // Musica para el titulo JA_Sound mSound; // Sonido con el impacto del título LTexture *mItemsTexture; // Textura con los gráficos de los items para las instrucciones LTexture *mTitleTexture; // Textura con los graficos para el titulo - SDL_Event *mEventHandler; // Manejador de eventos SDL_Rect mBackgroundWindow; // Ventana visible para la textura de fondo del titulo SDL_Texture *mBackground; // Textura dibujar el fondo del titulo SmartSprite *mCoffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo SmartSprite *mCrisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo Sprite *mTile; // Sprite para dibujar el fondo de pantalla del título Sprite *mGradient; // Sprite para dibujar el degradado del titulo - Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos - Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas + Text *mText; // Objeto de texto para poder escribir textos en pantalla + Text *mText2; // Objeto de texto para poder escribir textos en pantalla + Fade *mFade; // Objeto para realizar fundidos en pantalla + Instructions *mInstructions; // Objeto para la sección de las instrucciones + Game *mDemoGame; // Objeto para lanzar la demo del juego Uint16 mBackgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo Uint16 mCounter; // Temporizador para la pantalla de titulo Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa Uint8 mBackgroundMode; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo Uint8 mEvents[TITLE_TOTAL_EVENTS]; // Vector para coordinar los eventos de la pantalla de titulo + float mSin[360]; // Vector con los valores del seno precalculados + bool mMenuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente bool mDemo; // Indica si el modo demo estará activo section_t mSection; // Indicador para el bucle del titulo section_t mNextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa - Text *mText; // Objeto de texto para poder escribir textos en pantalla - Text *mText2; // Objeto de texto para poder escribir textos en pantalla - Fade *mFade; // Objeto para realizar fundidos en pantalla Uint8 mPostFade; // Opción a realizar cuando termina el fundido - Input *mInput; // Objeto para leer las entradas de teclado o mando - Instructions *mInstructions; // Objeto para la sección de las instrucciones - Game *mDemoGame; // Objeto para lanzar la demo del juego struct menu_t { @@ -113,7 +113,7 @@ private: public: // Constructor - Title(SDL_Window *window, SDL_Renderer *renderer, Screen *screen, Input *input, Asset *mAsset, options_t *options, Lang *lang); + Title(SDL_Window *window, SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang); // Destructor ~Title();