canviats els núvols per els del Volcano
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user