Modificada la estructura on es guarden els datos de la demo
This commit is contained in:
@@ -6,35 +6,36 @@
|
||||
#include "moving_sprite.h" // for MovingSprite
|
||||
#include "param.h" // for param
|
||||
#include "resource.h" // for Resource
|
||||
#include "sprite.h" // for Sprite
|
||||
#include "texture.h" // for Texture
|
||||
#include "screen.h"
|
||||
#include "sprite.h" // for Sprite
|
||||
#include "texture.h" // for Texture
|
||||
|
||||
// Constructor
|
||||
Background::Background(SDL_Renderer *renderer)
|
||||
: renderer_(renderer),
|
||||
Background::Background()
|
||||
: renderer_(Screen::get()->getRenderer()),
|
||||
|
||||
buildings_texture_(Resource::get()->getTexture("game_buildings.png")),
|
||||
top_clouds_texture_(Resource::get()->getTexture("game_clouds1.png")),
|
||||
bottom_clouds_texture_(Resource::get()->getTexture("game_clouds2.png")),
|
||||
grass_texture_(Resource::get()->getTexture("game_grass.png")),
|
||||
gradients_texture_(Resource::get()->getTexture("game_sky_colors.png"))
|
||||
gradients_texture_(Resource::get()->getTexture("game_sky_colors.png")),
|
||||
|
||||
gradient_number_(0),
|
||||
alpha_(0),
|
||||
clouds_speed_(0),
|
||||
transition_(0),
|
||||
counter_(0),
|
||||
rect_({0, 0, gradients_texture_->getWidth() / 2, gradients_texture_->getHeight() / 2}),
|
||||
src_rect_({0, 0, 320, 240}),
|
||||
dst_rect_({0, 0, 320, 240}),
|
||||
base_(rect_.h),
|
||||
color_({param.background.attenuate_color.r, param.background.attenuate_color.g, param.background.attenuate_color.b}),
|
||||
alpha_color_text_(param.background.attenuate_alpha),
|
||||
alpha_color_text_temp_(param.background.attenuate_alpha)
|
||||
|
||||
{
|
||||
// Inicializa variables
|
||||
{
|
||||
gradient_number_ = 0;
|
||||
alpha_ = 0;
|
||||
clouds_speed_ = 0;
|
||||
transition_ = 0;
|
||||
counter_ = 0;
|
||||
|
||||
rect_ = {0, 0, gradients_texture_->getWidth() / 2, gradients_texture_->getHeight() / 2};
|
||||
src_rect_ = {0, 0, 320, 240};
|
||||
dst_rect_ = {0, 0, 320, 240};
|
||||
|
||||
base_ = rect_.h;
|
||||
color_ = {param.background.attenuate_color.r, param.background.attenuate_color.g, param.background.attenuate_color.b};
|
||||
alpha_color_text_ = alpha_color_text_temp_ = param.background.attenuate_alpha;
|
||||
|
||||
gradient_rect_[0] = {0, 0, rect_.w, rect_.h};
|
||||
gradient_rect_[1] = {rect_.w, 0, rect_.w, rect_.h};
|
||||
gradient_rect_[2] = {0, rect_.h, rect_.w, rect_.h};
|
||||
@@ -87,11 +88,11 @@ Background::Background(SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
// Crea la textura para componer el fondo
|
||||
canvas_ = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, rect_.w, rect_.h);
|
||||
canvas_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, rect_.w, rect_.h);
|
||||
SDL_SetTextureBlendMode(canvas_, SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Crea la textura para atenuar el fondo
|
||||
color_texture_ = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, rect_.w, rect_.h);
|
||||
color_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, rect_.w, rect_.h);
|
||||
SDL_SetTextureBlendMode(color_texture_, SDL_BLENDMODE_BLEND);
|
||||
setColor(color_);
|
||||
SDL_SetTextureAlphaMod(color_texture_, alpha_color_text_);
|
||||
@@ -120,7 +121,7 @@ void Background::update()
|
||||
alpha_ = std::max((255 - (int)(255 * transition_)), 0);
|
||||
|
||||
// Incrementa el contador
|
||||
counter_++;
|
||||
++counter_;
|
||||
|
||||
// Compone todos los elementos del fondo en la textura
|
||||
fillCanvas();
|
||||
|
||||
Reference in New Issue
Block a user