Working on title cosmetics

This commit is contained in:
2021-08-27 16:48:10 +02:00
parent c12a7dc885
commit acbdcf2fc1
2 changed files with 20 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ Title::Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::stri
mDustBitmapL = new AnimatedSprite();
mDustBitmapR = new AnimatedSprite();
mTile = new Sprite();
mGradient = new Sprite();
mText = new Text(mFileList[48], mTextTexture, mRenderer);
mMenu.title = new Menu(mRenderer, mText, mInput, mFileList);
mMenu.options = new Menu(mRenderer, mText, mInput, mFileList);
@@ -74,6 +75,9 @@ Title::~Title()
delete mTile;
mTile = nullptr;
delete mGradient;
mGradient = nullptr;
delete mMenu.title;
mMenu.title = nullptr;
@@ -191,6 +195,10 @@ void Title::init(bool demo, Uint8 subsection)
mDustBitmapL->setAnimationFrames(0, 5, 160 + (mDustBitmapL->getWidth() * 5), 66, mDustBitmapL->getWidth(), mDustBitmapL->getHeight());
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
for (int i = 0; i < TITLE_TOTAL_EVENTS; i++)
mEvents[i] = EVENT_WAITING;
@@ -394,6 +402,9 @@ section_t Title::run(Uint8 subsection)
// Dibuja el tileado de fondo
SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, NULL);
// Dibuja el degradado
mGradient->render();
// Dibuja los objetos
mCoffeeBitmap->render();
mCrisisBitmap->render();
@@ -443,6 +454,9 @@ section_t Title::run(Uint8 subsection)
// Dibuja el tileado de fondo
SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, NULL);
// Dibuja el degradado
mGradient->render();
// Dibuja los objetos
mCoffeeBitmap->setPosX(a + v[n / 3]);
mCrisisBitmap->setPosX(b + v[n / 3]);
@@ -642,8 +656,13 @@ section_t Title::run(Uint8 subsection)
// Limpia la pantalla
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255);
SDL_RenderClear(mRenderer);
// Dibuja el tileado de fondo
SDL_RenderCopy(mRenderer, mBackground, &mBackgroundWindow, NULL);
// Dibuja el degradado
mGradient->render();
// Dibuja los objetos
mCoffeeBitmap->render();
mCrisisBitmap->render();

View File

@@ -36,11 +36,11 @@ private:
SDL_Event *mEventHandler; // Manejador de eventos
SDL_Rect mBackgroundWindow; // Ventana visible para la textura de fondo del titulo
SDL_Renderer *mRenderer; // El renderizador de la ventana
//SDL_Texture *mBackbuffer; // Textura para usar como backbuffer
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
std::string *mFileList; // Lista de ficheros
std::string *mTextStrings; // Vector con los textos del juego
Uint16 mBackgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo