canviats els núvols per els del Volcano

This commit is contained in:
2024-07-27 10:07:27 +02:00
parent fe361f455a
commit 7501b4936f
12 changed files with 51 additions and 57 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 935 B

BIN
data/gfx/game_clouds1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
data/gfx/game_clouds2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@@ -29,26 +29,31 @@ Background::Background(SDL_Renderer *renderer, Screen *screen, Asset *asset, par
// Carga las texturas
buildingsTexture = new Texture(renderer, asset->get("game_buildings.png"));
cloudsTexture = new Texture(renderer, asset->get("game_clouds.png"));
clouds1Texture = new Texture(renderer, asset->get("game_clouds1.png"));
clouds2Texture = new Texture(renderer, asset->get("game_clouds2.png"));
grassTexture = new Texture(renderer, asset->get("game_grass.png"));
gradientsTexture = new Texture(renderer, asset->get("game_sky_colors.png"));
// Crea los sprites
const int cloudsHeight = base - 196;
clouds1A = new MovingSprite(0, cloudsHeight, rect.w, 52, -0.4f, 0.0f, 0.0f, 0.0f, cloudsTexture, renderer);
clouds1B = new MovingSprite(rect.w, cloudsHeight, rect.w, 52, -0.4f, 0.0f, 0.0f, 0.0f, cloudsTexture, renderer);
clouds2A = new MovingSprite(0, cloudsHeight + 57, rect.w, 32, -0.2f, 0.0f, 0.0f, 0.0f, cloudsTexture, renderer);
clouds2B = new MovingSprite(rect.w, cloudsHeight + 57, rect.w, 32, -0.2f, 0.0f, 0.0f, 0.0f, cloudsTexture, renderer);
const int clouds1y = base - 165;
const int clouds2y = base - 101;
const float clouds1speed = 0.1f;
const float clouds2speed = 0.05f;
clouds1A = new MovingSprite(0, clouds1y, rect.w, clouds1Texture->getHeight(), -clouds1speed, 0.0f, 0.0f, 0.0f, clouds1Texture, renderer);
clouds1B = new MovingSprite(rect.w, clouds1y, rect.w, clouds1Texture->getHeight(), -clouds1speed, 0.0f, 0.0f, 0.0f, clouds1Texture, renderer);
buildingsSprite = new Sprite(0, 0, rect.w, 135, buildingsTexture, renderer);
clouds2A = new MovingSprite(0, clouds2y, rect.w, clouds2Texture->getHeight(), -clouds2speed, 0.0f, 0.0f, 0.0f, clouds2Texture, renderer);
clouds2B = new MovingSprite(rect.w, clouds2y, rect.w, clouds2Texture->getHeight(), -clouds2speed, 0.0f, 0.0f, 0.0f, clouds2Texture, renderer);
buildingsSprite = new Sprite(0, 0, buildingsTexture->getWidth(), buildingsTexture->getHeight(), buildingsTexture, renderer);
gradientSprite = new Sprite(0, 0, rect.w, rect.h, gradientsTexture, renderer);
grassSprite = new Sprite(0, 0, 320, 10, grassTexture, renderer);
grassSprite = new Sprite(0, 0, grassTexture->getWidth(), grassTexture->getHeight() / 2, grassTexture, renderer);
// Inicializa objetos
clouds1A->setSpriteClip(0, 0, cloudsTexture->getWidth(), 52);
clouds1B->setSpriteClip(0, 0, cloudsTexture->getWidth(), 52);
clouds2A->setSpriteClip(0, 52, cloudsTexture->getWidth(), 32);
clouds2B->setSpriteClip(0, 52, cloudsTexture->getWidth(), 32);
clouds1A->setSpriteClip(0, 0, clouds1Texture->getWidth(), clouds1Texture->getHeight());
clouds1B->setSpriteClip(0, 0, clouds1Texture->getWidth(), clouds1Texture->getHeight());
clouds2A->setSpriteClip(0, 0, clouds2Texture->getWidth(), clouds2Texture->getHeight());
clouds2B->setSpriteClip(0, 0, clouds2Texture->getWidth(), clouds2Texture->getHeight());
buildingsSprite->setPosY(base - buildingsSprite->getHeight());
grassSprite->setPosY(base - grassSprite->getHeight());
@@ -57,25 +62,19 @@ Background::Background(SDL_Renderer *renderer, Screen *screen, Asset *asset, par
SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND);
// Crea la textura para atenuar el fondo
colorText = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, rect.w, rect.h);
SDL_SetTextureBlendMode(colorText, SDL_BLENDMODE_BLEND);
colorTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, rect.w, rect.h);
SDL_SetTextureBlendMode(colorTexture, SDL_BLENDMODE_BLEND);
setColor(color);
SDL_SetTextureAlphaMod(colorText, alphaColorText);
SDL_SetTextureAlphaMod(colorTexture, alphaColorText);
}
// Destructor
Background::~Background()
{
buildingsTexture->unload();
delete buildingsTexture;
cloudsTexture->unload();
delete cloudsTexture;
grassTexture->unload();
delete clouds1Texture;
delete clouds2Texture;
delete grassTexture;
gradientsTexture->unload();
delete gradientsTexture;
delete clouds1A;
@@ -86,7 +85,7 @@ Background::~Background()
delete gradientSprite;
delete grassSprite;
SDL_DestroyTexture(canvas);
SDL_DestroyTexture(colorText);
SDL_DestroyTexture(colorTexture);
}
// Actualiza la lógica del objeto
@@ -150,14 +149,15 @@ void Background::render()
SDL_RenderCopy(renderer, canvas, &srcRect, &dstRect);
// Atenuación
SDL_RenderCopy(renderer, colorText, &srcRect, &dstRect);
SDL_RenderCopy(renderer, colorTexture, &srcRect, &dstRect);
}
// Vuelve a cargar las texturas
void Background::reloadTextures()
{
buildingsTexture->reLoad();
cloudsTexture->reLoad();
clouds1Texture->reLoad();
clouds2Texture->reLoad();
grassTexture->reLoad();
gradientsTexture->reLoad();
}
@@ -209,7 +209,7 @@ void Background::setColor(color_t color)
// Colorea la textura
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
SDL_SetRenderTarget(renderer, colorText);
SDL_SetRenderTarget(renderer, colorTexture);
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 255);
SDL_RenderClear(renderer);
@@ -237,7 +237,7 @@ void Background::updateAlphaColorText()
else
{
alphaColorText > alphaColorTextTemp ? alphaColorTextTemp++ : alphaColorTextTemp--;
SDL_SetTextureAlphaMod(colorText, alphaColorTextTemp);
SDL_SetTextureAlphaMod(colorTexture, alphaColorTextTemp);
}
}

View File

@@ -15,7 +15,8 @@ private:
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Texture *buildingsTexture; // Textura con los edificios de fondo
Texture *cloudsTexture; // Textura con las nubes de fondo
Texture *clouds1Texture; // Textura con las nubes de fondo
Texture *clouds2Texture; // Textura con las nubes de fondo
Texture *grassTexture; // Textura con la hierba del suelo
Texture *gradientsTexture; // Textura con los diferentes colores de fondo del juego
@@ -29,7 +30,7 @@ private:
Sprite *grassSprite; // Sprite para la hierba
SDL_Texture *canvas; // Textura para componer el fondo
SDL_Texture *colorText; // Textura para atenuar el fondo
SDL_Texture *colorTexture; // Textura para atenuar el fondo
param_t *param; // Puntero con todos los parametros del programa

View File

@@ -331,7 +331,8 @@ bool Director::setFileList()
asset->add(prefix + "/data/gfx/bullet.png", t_bitmap);
asset->add(prefix + "/data/gfx/game_buildings.png", t_bitmap);
asset->add(prefix + "/data/gfx/game_clouds.png", t_bitmap);
asset->add(prefix + "/data/gfx/game_clouds1.png", t_bitmap);
asset->add(prefix + "/data/gfx/game_clouds2.png", t_bitmap);
asset->add(prefix + "/data/gfx/game_grass.png", t_bitmap);
asset->add(prefix + "/data/gfx/game_power_meter.png", t_bitmap);
asset->add(prefix + "/data/gfx/game_sky_colors.png", t_bitmap);

View File

@@ -2697,10 +2697,12 @@ void Game::updateBackground()
}
// Calcula la velocidad en función de los globos explotados y el total de globos a explotar para acabar el juego
const float speed = (-0.2f) + (-3.00f * ((float)balloonsPopped / (float)totalPowerToCompleteGame));
const float cloudsInitialSpeed = 0.05f;
const float cloudsFinalSpeed = 2.00f - cloudsInitialSpeed;
const float cloudsSpeed = (-cloudsInitialSpeed) + (-cloudsFinalSpeed * ((float)balloonsPopped / (float)totalPowerToCompleteGame));
background->setCloudsSpeed(cloudsSpeed);
// Aplica la velocidad calculada para las nubes
background->setCloudsSpeed(speed);
// Calcula la transición de los diferentes fondos
const float gradientNumber = std::min(((float)balloonsPopped / 1250.0f), 3.0f);
const float percent = gradientNumber - (int)gradientNumber;
background->setGradientNumber((int)gradientNumber);
@@ -2710,7 +2712,7 @@ void Game::updateBackground()
background->update();
}
// Dibuja la linea que separa la zona ade juego del marcador
// Dibuja la linea que separa la zona de juego del marcador
void Game::renderSeparator()
{
// Dibuja la linea que separa el marcador de la zona de juego

View File

@@ -52,10 +52,11 @@ void GameLogo::init()
{
const int xp = x - coffeeBitmap->getWidth() / 2;
const int desp = getInitialVerticalDesp();
// Variables
status = disabled;
shake.desp = 1;
shake.delay = 3;
shake.delay = 2;
shake.lenght = 8;
shake.remaining = shake.lenght;
shake.counter = shake.delay;
@@ -138,7 +139,7 @@ void GameLogo::update()
status = shaking;
// Pantallazo blanco
screen->flash(flashColor, 5);
//screen->flash(flashColor, 10);
// Reproduce el efecto sonoro
JA_PlaySound(crashSound);

View File

@@ -36,7 +36,7 @@ HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset,
// Inicializa objetos
background->setSrcDest(windowArea);
background->setDstDest(windowArea);
background->setCloudsSpeed(-0.5f);
background->setCloudsSpeed(-0.1f);
background->setGradientNumber(1);
background->setTransition(0.8f);
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);

View File

@@ -26,13 +26,6 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
miniLogoTexture = new Texture(renderer, asset->get("logo_jailgames_mini.png"));
miniLogoSprite = new Sprite(GAMECANVAS_CENTER_X - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture, renderer);
background = new Background(renderer, screen, asset, param);
background->setSrcDest(windowArea);
background->setDstDest(windowArea);
background->setCloudsSpeed(-0.5f);
background->setGradientNumber(1);
background->setTransition(0.8f);
tiledbg = new Tiledbg(renderer, screen, asset, {0, 0, param->gameWidth, param->gameHeight}, TILED_MODE_RANDOM);
gameLogo = new GameLogo(renderer, screen, asset, param, GAMECANVAS_CENTER_X, param->titleCC);
@@ -54,11 +47,9 @@ Title::~Title()
delete text1;
delete text2;
miniLogoTexture->unload();
delete miniLogoTexture;
delete miniLogoSprite;
delete background;
delete tiledbg;
delete gameLogo;
delete defineButtons;
@@ -90,9 +81,6 @@ void Title::update()
// Actualiza el contador de ticks
ticks = SDL_GetTicks();
// Actualiza el objeto 'background'
background->update();
// Actualiza el objeto 'defineButtons'
defineButtons->update();
@@ -174,7 +162,6 @@ void Title::render()
// Dibuja el mosacico de fondo
tiledbg->render();
// background->render();
// Dibuja el logo con el título del juego
gameLogo->render();
@@ -198,6 +185,7 @@ void Title::render()
text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, pos2, TEXT_COPYRIGHT, 1, noColor, 1, shadow);
}
// Define Buttons
defineButtons->render();
// Fade
@@ -253,9 +241,12 @@ void Title::checkInput()
const int index = input->checkAnyButtonPressed();
if (index)
{
if (section->subsection == SUBSECTION_TITLE_2)
{// No se puede empezar a jugar durante la animación del titulo
fade->activate();
postFade = index;
}
}
// Comprueba el teclado para salir
if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))

View File

@@ -17,7 +17,6 @@
#include "instructions.h"
#include "item.h"
#include "lang.h"
#include "background.h"
#include "tiledbg.h"
#include "game_logo.h"
#include "define_buttons.h"
@@ -37,7 +36,6 @@ private:
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
SDL_Event *eventHandler; // Manejador de eventos
section_t *section; // Indicador para el bucle del titulo
Background *background; // Objeto para dibujar el fondo del juego
Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo
GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego
Texture *miniLogoTexture; // Textura con el logo de JailGames mini