He fet un "manolete" i he pasat a c++ i smartpointers la cárrega de surfaces desde gif. Sembla que no ha petat res
Precárrega i asignació de paletes a les textures Ara si algú toca una paleta, que siga conscient que la textura es compartida durant tot el joc
This commit is contained in:
@@ -24,51 +24,43 @@ struct JA_Music_t; // lines 17-17
|
||||
|
||||
// Constructor
|
||||
Title::Title()
|
||||
: text1_(std::make_unique<Text>(Resource::get()->getTexture("smb2.gif"), Resource::get()->getTextFile("smb2.txt"))),
|
||||
text2_(std::make_unique<Text>(Resource::get()->getTexture("8bithud.png"), Resource::get()->getTextFile("8bithud.txt"))),
|
||||
fade_(std::make_unique<Fade>()),
|
||||
tiled_bg_(std::make_unique<TiledBG>((SDL_Rect){0, 0, param.game.width, param.game.height}, TiledBGMode::RANDOM)),
|
||||
game_logo_(std::make_unique<GameLogo>(param.game.game_area.center_x, param.title.title_c_c_position)),
|
||||
mini_logo_texture_(Resource::get()->getTexture("logo_jailgames_mini.png")),
|
||||
mini_logo_sprite_(std::make_unique<Sprite>(mini_logo_texture_, param.game.game_area.center_x - mini_logo_texture_->getWidth() / 2, 0, mini_logo_texture_->getWidth(), mini_logo_texture_->getHeight())),
|
||||
define_buttons_(std::make_unique<DefineButtons>(std::move(text2_))),
|
||||
counter_(0),
|
||||
ticks_(0),
|
||||
demo_(true),
|
||||
next_section_(section::Name::GAME),
|
||||
post_fade_(0),
|
||||
num_controllers_(Input::get()->getNumControllers())
|
||||
{
|
||||
// Reserva memoria y crea los objetos
|
||||
fade_ = std::make_unique<Fade>();
|
||||
|
||||
text1_ = std::make_unique<Text>(Resource::get()->getTexture("smb2.gif"), Resource::get()->getTextFile("smb2.txt"));
|
||||
text1_->addPalette(Asset::get()->get("smb2_pal1.gif"));
|
||||
text1_->setPalette(1);
|
||||
text2_ = std::make_unique<Text>(Resource::get()->getTexture("8bithud.png"), Resource::get()->getTextFile("8bithud.txt"));
|
||||
|
||||
mini_logo_texture_ = Resource::get()->getTexture("logo_jailgames_mini.png");
|
||||
mini_logo_sprite_ = std::make_unique<Sprite>(mini_logo_texture_, param.game.game_area.center_x - mini_logo_texture_->getWidth() / 2, 0, mini_logo_texture_->getWidth(), mini_logo_texture_->getHeight());
|
||||
|
||||
tiled_bg_ = std::make_unique<TiledBG>((SDL_Rect){0, 0, param.game.width, param.game.height}, TiledBGMode::RANDOM);
|
||||
|
||||
game_logo_ = std::make_unique<GameLogo>(param.game.game_area.center_x, param.title.title_c_c_position);
|
||||
// Configura objetos
|
||||
game_logo_->enable();
|
||||
|
||||
define_buttons_ = std::make_unique<DefineButtons>(std::move(text2_));
|
||||
|
||||
// Inicializa los valores
|
||||
init();
|
||||
}
|
||||
|
||||
// Inicializa los valores de las variables
|
||||
void Title::init()
|
||||
{
|
||||
// Inicializa variables
|
||||
section::options = section::Options::TITLE_1;
|
||||
counter_ = 0;
|
||||
next_section_ = section::Name::GAME;
|
||||
post_fade_ = 0;
|
||||
ticks_ = 0;
|
||||
ticks_speed_ = 15;
|
||||
fade_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
||||
fade_->setType(FadeType::RANDOM_SQUARE);
|
||||
fade_->setPost(param.fade.post_duration);
|
||||
demo_ = true;
|
||||
num_controllers_ = Input::get()->getNumControllers();
|
||||
Resource::get()->getTexture("smb2.gif")->setPalette(1);
|
||||
|
||||
// Asigna valores a otras variables
|
||||
section::options = section::Options::TITLE_1;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Title::~Title()
|
||||
{
|
||||
Resource::get()->getTexture("smb2.gif")->setPalette(0);
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void Title::update()
|
||||
{
|
||||
// Calcula la lógica de los objetos
|
||||
if (SDL_GetTicks() - ticks_ > ticks_speed_)
|
||||
if (SDL_GetTicks() - ticks_ > TICKS_SPEED_)
|
||||
{
|
||||
// Actualiza el contador de ticks_
|
||||
ticks_ = SDL_GetTicks();
|
||||
|
||||
Reference in New Issue
Block a user