diff --git a/data/lang/ba_BA.txt b/data/lang/ba_BA.txt index 7bc08f7..d938b42 100644 --- a/data/lang/ba_BA.txt +++ b/data/lang/ba_BA.txt @@ -68,7 +68,7 @@ VIDA EXTRA PREM UNA TECLA PER A TORNAR ## 23 - TITULO -PREM QUALSEVOL TECLA +PREM 1P PER A JUGAR ## 24 - MENU SELECCION DE IDIOMA ESPA{OL (ESPANYOL) diff --git a/source/background.cpp b/source/background.cpp index 40161b0..aea9a70 100644 --- a/source/background.cpp +++ b/source/background.cpp @@ -15,7 +15,6 @@ Background::Background(SDL_Renderer *renderer, Screen *screen, Asset *asset) transition = 0; counter = 0; rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; - srcRect = {0, rect.h - playArea.h, playArea.w, playArea.h}; srcRect = {playArea.x, rect.h - playArea.h, playArea.w, playArea.h}; dstRect = {0, 0, playArea.w, playArea.h}; base = rect.h; @@ -200,4 +199,16 @@ void Background::setPos(SDL_Rect rect) // Si cambian las medidas del destino, hay que cambiar las del origen para evitar deformar la imagen srcRect.w = rect.w; srcRect.h = rect.h; +} + +// Ajusta el valor de la variable +void Background::setSrcDest(SDL_Rect value) +{ + srcRect = value; +} + +// Ajusta el valor de la variable +void Background::setDstDest(SDL_Rect value) +{ + dstRect = value; } \ No newline at end of file diff --git a/source/background.h b/source/background.h index 569ccbb..657ef20 100644 --- a/source/background.h +++ b/source/background.h @@ -74,6 +74,12 @@ public: // Ajusta el valor de la variable void setTransition(float value); + + // Ajusta el valor de la variable + void setSrcDest(SDL_Rect value); + + // Ajusta el valor de la variable + void setDstDest(SDL_Rect value); }; #endif \ No newline at end of file diff --git a/source/const.h b/source/const.h index da5e79f..ef413d2 100644 --- a/source/const.h +++ b/source/const.h @@ -21,7 +21,8 @@ const int SCOREBOARD_X = 0; const int SCOREBOARD_Y = GAMECANVAS_HEIGHT - SCOREBOARD_HEIGHT; // Zona de juego -const SDL_Rect playArea = {10, 10, GAMECANVAS_WIDTH-20, GAMECANVAS_HEIGHT - SCOREBOARD_HEIGHT-20}; +const SDL_Rect windowArea = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; +const SDL_Rect playArea = {10, 10, GAMECANVAS_WIDTH - 20, GAMECANVAS_HEIGHT - SCOREBOARD_HEIGHT - 20}; const int PLAY_AREA_TOP = 0; const int PLAY_AREA_BOTTOM = playArea.h; const int PLAY_AREA_LEFT = 0; diff --git a/source/director.cpp b/source/director.cpp index 4119a5f..f6e727a 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -16,7 +16,7 @@ Director::Director(int argc, char *argv[]) { // Inicializa variables section = new section_t(); - section->name = SECTION_PROG_GAME; + section->name = SECTION_PROG_TITLE; // Inicializa las opciones del programa initOptions(); diff --git a/source/game.cpp b/source/game.cpp index b23b378..0d9fcf2 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -2723,7 +2723,7 @@ void Game::render() // Dibuja la zona de juego y el marcador SDL_RenderCopy(renderer, canvas, nullptr, &playArea); scoreboard->render(); - //renderSeparator(); + renderSeparator(); if ((deathCounter <= 150) && !players[0]->isAlive()) { diff --git a/source/game.h b/source/game.h index 17e034e..16dd40d 100644 --- a/source/game.h +++ b/source/game.h @@ -125,7 +125,7 @@ private: Input *input; // Manejador de entrada section_t *section; // Seccion actual dentro del juego Scoreboard *scoreboard; // Objeto para dibujar el marcador - Background *background; // Objetio para dibujar el fondo del juego + Background *background; // Objeto para dibujar el fondo del juego SDL_Texture *canvas; // Textura para dibujar la zona de juego std::vector players; // Vector con los jugadores diff --git a/source/title.cpp b/source/title.cpp index 03a4ab5..4113308 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -30,6 +30,13 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, text1 = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer); text2 = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer); + backgroundObj = new Background(renderer, screen, asset); + backgroundObj->setSrcDest(windowArea); + backgroundObj->setDstDest(windowArea); + backgroundObj->setCloudsSpeed(-0.5f); + backgroundObj->setGradientNumber(1); + backgroundObj->setTransition(0.8f); + // Sonidos crashSound = JA_LoadSound(asset->get("title.wav").c_str()); @@ -67,6 +74,8 @@ Title::~Title() delete text1; delete text2; + delete backgroundObj; + JA_DeleteSound(crashSound); JA_DeleteMusic(titleMusic); @@ -197,6 +206,9 @@ void Title::update() // Actualiza el contador de ticks ticks = SDL_GetTicks(); + backgroundObj->update(); + counter++; + switch (section->subsection) { // Sección 1 - Titulo desplazandose @@ -364,9 +376,10 @@ void Title::render() // Dibuja el tileado de fondo SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); + backgroundObj->render(); // Dibuja el degradado - gradient->render(); + // gradient->render(); // Dibuja los objetos coffeeBitmap->render(); @@ -396,9 +409,10 @@ void Title::render() // Dibuja el tileado de fondo SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); + backgroundObj->render(); // Dibuja el degradado - gradient->render(); + // gradient->render(); // Dibuja los objetos coffeeBitmap->setPosX(a + v[n / 3]); @@ -430,18 +444,23 @@ void Title::render() // Dibuja el tileado de fondo SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr); + backgroundObj->render(); // Dibuja el degradado - gradient->render(); + // gradient->render(); + + coffeeBitmap->render(); + crisisBitmap->render(); // Dibuja el polvillo del título dustBitmapR->render(); dustBitmapL->render(); // PRESS ANY KEY! - if ((counter % 50 > 14) && (menuVisible == false)) + //if ((counter % 50 > 14) && (menuVisible == false)) + if (counter % 50 > 14) { - text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor); + text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor); } // Fade diff --git a/source/title.h b/source/title.h index 1c0329a..93b5fc4 100644 --- a/source/title.h +++ b/source/title.h @@ -18,6 +18,7 @@ #include "instructions.h" #include "item.h" #include "lang.h" +#include "background.h" #ifndef TITLE_H #define TITLE_H @@ -45,6 +46,7 @@ private: Game *demoGame; // Objeto para lanzar la demo del juego SDL_Event *eventHandler; // Manejador de eventos section_t *section; // Indicador para el bucle del titulo + Background *backgroundObj; // Objeto para dibujar el fondo del juego Texture *dustTexture; // Textura con los graficos del polvo Texture *coffeeTexture; // Textura con los graficos de la palabra coffee