Añadido el objeto background al titulo
This commit is contained in:
@@ -68,7 +68,7 @@ VIDA EXTRA
|
|||||||
PREM UNA TECLA PER A TORNAR
|
PREM UNA TECLA PER A TORNAR
|
||||||
|
|
||||||
## 23 - TITULO
|
## 23 - TITULO
|
||||||
PREM QUALSEVOL TECLA
|
PREM 1P PER A JUGAR
|
||||||
|
|
||||||
## 24 - MENU SELECCION DE IDIOMA
|
## 24 - MENU SELECCION DE IDIOMA
|
||||||
ESPA{OL (ESPANYOL)
|
ESPA{OL (ESPANYOL)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ Background::Background(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
transition = 0;
|
transition = 0;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
|
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};
|
srcRect = {playArea.x, rect.h - playArea.h, playArea.w, playArea.h};
|
||||||
dstRect = {0, 0, playArea.w, playArea.h};
|
dstRect = {0, 0, playArea.w, playArea.h};
|
||||||
base = rect.h;
|
base = rect.h;
|
||||||
@@ -201,3 +200,15 @@ void Background::setPos(SDL_Rect rect)
|
|||||||
srcRect.w = rect.w;
|
srcRect.w = rect.w;
|
||||||
srcRect.h = rect.h;
|
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
|
// Ajusta el valor de la variable
|
||||||
void setTransition(float value);
|
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
|
#endif
|
||||||
@@ -21,6 +21,7 @@ const int SCOREBOARD_X = 0;
|
|||||||
const int SCOREBOARD_Y = GAMECANVAS_HEIGHT - SCOREBOARD_HEIGHT;
|
const int SCOREBOARD_Y = GAMECANVAS_HEIGHT - SCOREBOARD_HEIGHT;
|
||||||
|
|
||||||
// Zona de juego
|
// Zona de juego
|
||||||
|
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 SDL_Rect playArea = {10, 10, GAMECANVAS_WIDTH - 20, GAMECANVAS_HEIGHT - SCOREBOARD_HEIGHT - 20};
|
||||||
const int PLAY_AREA_TOP = 0;
|
const int PLAY_AREA_TOP = 0;
|
||||||
const int PLAY_AREA_BOTTOM = playArea.h;
|
const int PLAY_AREA_BOTTOM = playArea.h;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Director::Director(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
section = new section_t();
|
section = new section_t();
|
||||||
section->name = SECTION_PROG_GAME;
|
section->name = SECTION_PROG_TITLE;
|
||||||
|
|
||||||
// Inicializa las opciones del programa
|
// Inicializa las opciones del programa
|
||||||
initOptions();
|
initOptions();
|
||||||
|
|||||||
@@ -2723,7 +2723,7 @@ void Game::render()
|
|||||||
// Dibuja la zona de juego y el marcador
|
// Dibuja la zona de juego y el marcador
|
||||||
SDL_RenderCopy(renderer, canvas, nullptr, &playArea);
|
SDL_RenderCopy(renderer, canvas, nullptr, &playArea);
|
||||||
scoreboard->render();
|
scoreboard->render();
|
||||||
//renderSeparator();
|
renderSeparator();
|
||||||
|
|
||||||
if ((deathCounter <= 150) && !players[0]->isAlive())
|
if ((deathCounter <= 150) && !players[0]->isAlive())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ private:
|
|||||||
Input *input; // Manejador de entrada
|
Input *input; // Manejador de entrada
|
||||||
section_t *section; // Seccion actual dentro del juego
|
section_t *section; // Seccion actual dentro del juego
|
||||||
Scoreboard *scoreboard; // Objeto para dibujar el marcador
|
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
|
SDL_Texture *canvas; // Textura para dibujar la zona de juego
|
||||||
|
|
||||||
std::vector<Player *> players; // Vector con los jugadores
|
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);
|
text1 = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||||
text2 = new Text(asset->get("8bithud.png"), asset->get("8bithud.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
|
// Sonidos
|
||||||
crashSound = JA_LoadSound(asset->get("title.wav").c_str());
|
crashSound = JA_LoadSound(asset->get("title.wav").c_str());
|
||||||
|
|
||||||
@@ -67,6 +74,8 @@ Title::~Title()
|
|||||||
delete text1;
|
delete text1;
|
||||||
delete text2;
|
delete text2;
|
||||||
|
|
||||||
|
delete backgroundObj;
|
||||||
|
|
||||||
JA_DeleteSound(crashSound);
|
JA_DeleteSound(crashSound);
|
||||||
JA_DeleteMusic(titleMusic);
|
JA_DeleteMusic(titleMusic);
|
||||||
|
|
||||||
@@ -197,6 +206,9 @@ void Title::update()
|
|||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks = SDL_GetTicks();
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
|
backgroundObj->update();
|
||||||
|
counter++;
|
||||||
|
|
||||||
switch (section->subsection)
|
switch (section->subsection)
|
||||||
{
|
{
|
||||||
// Sección 1 - Titulo desplazandose
|
// Sección 1 - Titulo desplazandose
|
||||||
@@ -364,9 +376,10 @@ void Title::render()
|
|||||||
|
|
||||||
// Dibuja el tileado de fondo
|
// Dibuja el tileado de fondo
|
||||||
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
||||||
|
backgroundObj->render();
|
||||||
|
|
||||||
// Dibuja el degradado
|
// Dibuja el degradado
|
||||||
gradient->render();
|
// gradient->render();
|
||||||
|
|
||||||
// Dibuja los objetos
|
// Dibuja los objetos
|
||||||
coffeeBitmap->render();
|
coffeeBitmap->render();
|
||||||
@@ -396,9 +409,10 @@ void Title::render()
|
|||||||
|
|
||||||
// Dibuja el tileado de fondo
|
// Dibuja el tileado de fondo
|
||||||
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
||||||
|
backgroundObj->render();
|
||||||
|
|
||||||
// Dibuja el degradado
|
// Dibuja el degradado
|
||||||
gradient->render();
|
// gradient->render();
|
||||||
|
|
||||||
// Dibuja los objetos
|
// Dibuja los objetos
|
||||||
coffeeBitmap->setPosX(a + v[n / 3]);
|
coffeeBitmap->setPosX(a + v[n / 3]);
|
||||||
@@ -430,18 +444,23 @@ void Title::render()
|
|||||||
|
|
||||||
// Dibuja el tileado de fondo
|
// Dibuja el tileado de fondo
|
||||||
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
SDL_RenderCopy(renderer, background, &backgroundWindow, nullptr);
|
||||||
|
backgroundObj->render();
|
||||||
|
|
||||||
// Dibuja el degradado
|
// Dibuja el degradado
|
||||||
gradient->render();
|
// gradient->render();
|
||||||
|
|
||||||
|
coffeeBitmap->render();
|
||||||
|
crisisBitmap->render();
|
||||||
|
|
||||||
// Dibuja el polvillo del título
|
// Dibuja el polvillo del título
|
||||||
dustBitmapR->render();
|
dustBitmapR->render();
|
||||||
dustBitmapL->render();
|
dustBitmapL->render();
|
||||||
|
|
||||||
// PRESS ANY KEY!
|
// 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
|
// Fade
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "instructions.h"
|
#include "instructions.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
#include "background.h"
|
||||||
|
|
||||||
#ifndef TITLE_H
|
#ifndef TITLE_H
|
||||||
#define TITLE_H
|
#define TITLE_H
|
||||||
@@ -45,6 +46,7 @@ private:
|
|||||||
Game *demoGame; // Objeto para lanzar la demo del juego
|
Game *demoGame; // Objeto para lanzar la demo del juego
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
section_t *section; // Indicador para el bucle del titulo
|
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 *dustTexture; // Textura con los graficos del polvo
|
||||||
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
||||||
|
|||||||
Reference in New Issue
Block a user