Añadido el objeto background al titulo
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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<Player *> players; // Vector con los jugadores
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user