FIX: afegit StopChannel en lloc de PauseChannel en el destructor del Logo
Retocada la animació del logo del joc en Title
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "game_logo.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL
|
||||
#include <algorithm> // Para max
|
||||
#include "animated_sprite.h" // Para AnimatedSprite
|
||||
@@ -9,6 +10,8 @@
|
||||
#include "sprite.h" // Para Sprite
|
||||
#include "texture.h" // Para Texture
|
||||
|
||||
constexpr int ZOOM_FACTOR = 4;
|
||||
|
||||
// Constructor
|
||||
GameLogo::GameLogo(int x, int y)
|
||||
: dust_texture_(Resource::get()->getTexture("title_dust.png")),
|
||||
@@ -21,7 +24,7 @@ GameLogo::GameLogo(int x, int y)
|
||||
crisis_sprite_(std::make_unique<SmartSprite>(crisis_texture_)),
|
||||
arcade_edition_sprite_(std::make_unique<Sprite>(arcade_edition_texture_, (param.game.width - arcade_edition_texture_->getWidth()) / 2, param.title.arcade_edition_position, arcade_edition_texture_->getWidth(), arcade_edition_texture_->getHeight())),
|
||||
x_(x),
|
||||
y_(y) { }
|
||||
y_(y) {}
|
||||
|
||||
// Inicializa las variables
|
||||
void GameLogo::init()
|
||||
@@ -32,15 +35,8 @@ void GameLogo::init()
|
||||
// Variables
|
||||
coffee_crisis_status_ = Status::DISABLED;
|
||||
arcade_edition_status_ = Status::DISABLED;
|
||||
|
||||
shake_.desp = 1;
|
||||
shake_.delay = 2;
|
||||
shake_.lenght = 8;
|
||||
shake_.remaining = shake_.lenght;
|
||||
shake_.counter = shake_.delay;
|
||||
shake_.origin = xp;
|
||||
|
||||
zoom_ = 3.0f;
|
||||
shake_.init(1, 2, 8, xp);
|
||||
zoom_ = 3.0f * ZOOM_FACTOR;
|
||||
|
||||
// Inicializa el bitmap de 'Coffee'
|
||||
coffee_sprite_->setPosX(xp);
|
||||
@@ -122,7 +118,6 @@ void GameLogo::update()
|
||||
if (coffee_sprite_->hasFinished() && crisis_sprite_->hasFinished())
|
||||
{
|
||||
coffee_crisis_status_ = Status::SHAKING;
|
||||
arcade_edition_status_ = Status::MOVING;
|
||||
|
||||
// Reproduce el efecto sonoro
|
||||
JA_PlaySound(Resource::get()->getSound("title.wav"));
|
||||
@@ -133,7 +128,7 @@ void GameLogo::update()
|
||||
|
||||
case Status::SHAKING:
|
||||
{
|
||||
// Agita el logo
|
||||
// Agita "COFFEE CRISIS"
|
||||
if (shake_.remaining > 0)
|
||||
{
|
||||
if (shake_.counter > 0)
|
||||
@@ -154,6 +149,7 @@ void GameLogo::update()
|
||||
coffee_sprite_->setPosX(shake_.origin);
|
||||
crisis_sprite_->setPosX(shake_.origin + 15);
|
||||
coffee_crisis_status_ = Status::FINISHED;
|
||||
arcade_edition_status_ = Status::MOVING;
|
||||
}
|
||||
|
||||
dust_right_sprite_->update();
|
||||
@@ -178,12 +174,40 @@ void GameLogo::update()
|
||||
{
|
||||
case Status::MOVING:
|
||||
{
|
||||
zoom_ -= 0.1f;
|
||||
zoom_ -= 0.1f * ZOOM_FACTOR;
|
||||
arcade_edition_sprite_->setZoom(zoom_);
|
||||
if (zoom_ <= 1.0f)
|
||||
{
|
||||
arcade_edition_status_ = Status::FINISHED;
|
||||
arcade_edition_status_ = Status::SHAKING;
|
||||
zoom_ = 1.0f;
|
||||
arcade_edition_sprite_->setZoom(zoom_);
|
||||
shake_.init(1, 2, 8, arcade_edition_sprite_->getX());
|
||||
JA_PlaySound(Resource::get()->getSound("title.wav"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Status::SHAKING:
|
||||
{
|
||||
// Agita "ARCADE EDITION"
|
||||
if (shake_.remaining > 0)
|
||||
{
|
||||
if (shake_.counter > 0)
|
||||
{
|
||||
shake_.counter--;
|
||||
}
|
||||
else
|
||||
{
|
||||
shake_.counter = shake_.delay;
|
||||
const auto desp = shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp;
|
||||
arcade_edition_sprite_->setX(shake_.origin + desp);
|
||||
shake_.remaining--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
arcade_edition_sprite_->setX(shake_.origin);
|
||||
arcade_edition_status_ = Status::FINISHED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -191,6 +215,13 @@ void GameLogo::update()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (coffee_crisis_status_ == Status::FINISHED &&
|
||||
arcade_edition_status_ == Status::FINISHED &&
|
||||
post_finished_counter_ > 0)
|
||||
{
|
||||
--post_finished_counter_;
|
||||
}
|
||||
}
|
||||
|
||||
// Activa la clase
|
||||
@@ -203,7 +234,7 @@ void GameLogo::enable()
|
||||
// Indica si ha terminado la animación
|
||||
bool GameLogo::hasFinished() const
|
||||
{
|
||||
return coffee_crisis_status_ == Status::FINISHED && arcade_edition_status_ == Status::FINISHED;
|
||||
return post_finished_counter_ == 0;
|
||||
}
|
||||
|
||||
// Recarga las texturas
|
||||
|
||||
Reference in New Issue
Block a user