treball en curs: correccions de tidy
This commit is contained in:
+25
-25
@@ -23,20 +23,20 @@ constexpr int END_LOGO = 200;
|
||||
// Constructor
|
||||
Logo::Logo(SDL_Renderer *renderer, Section *section) {
|
||||
// Copia la dirección de los objetos
|
||||
this->renderer = renderer;
|
||||
this->section = section;
|
||||
this->renderer_ = renderer;
|
||||
this->section_ = section;
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
eventHandler = new SDL_Event();
|
||||
texture = Resource::get()->getTexture("logo.png");
|
||||
sprite = new Sprite(14, 75, 226, 44, texture, renderer);
|
||||
event_handler_ = new SDL_Event();
|
||||
texture_ = Resource::get()->getTexture("logo.png");
|
||||
sprite_ = new Sprite(14, 75, 226, 44, texture_, renderer);
|
||||
|
||||
// Inicializa variables
|
||||
counter = 0;
|
||||
counter_ = 0;
|
||||
section->name = SECTION_PROG_LOGO;
|
||||
section->subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
ticks_ = 0;
|
||||
ticks_speed_ = 15;
|
||||
|
||||
Audio::get()->stopMusic();
|
||||
}
|
||||
@@ -44,15 +44,15 @@ Logo::Logo(SDL_Renderer *renderer, Section *section) {
|
||||
// Destructor
|
||||
Logo::~Logo() {
|
||||
// texture es propiedad de Resource — no liberar aquí.
|
||||
delete sprite;
|
||||
delete eventHandler;
|
||||
delete sprite_;
|
||||
delete event_handler_;
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado el logo
|
||||
void Logo::checkLogoEnd() {
|
||||
if (counter >= END_LOGO + 20) {
|
||||
section->name = SECTION_PROG_INTRO;
|
||||
section->subsection = 0;
|
||||
if (counter_ >= END_LOGO + 20) {
|
||||
section_->name = SECTION_PROG_INTRO;
|
||||
section_->subsection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,26 +60,26 @@ void Logo::checkLogoEnd() {
|
||||
void Logo::checkInput() {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
section_->name = SECTION_PROG_QUIT;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (GlobalInputs::handle()) { return; }
|
||||
|
||||
if (Input::get()->checkInput(input_pause, REPEAT_FALSE) || Input::get()->checkInput(input_accept, REPEAT_FALSE) || Input::get()->checkInput(input_fire_left, REPEAT_FALSE) || Input::get()->checkInput(input_fire_center, REPEAT_FALSE) || Input::get()->checkInput(input_fire_right, REPEAT_FALSE)) {
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
section_->name = SECTION_PROG_TITLE;
|
||||
section_->subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja el fade
|
||||
void Logo::renderFade() {
|
||||
// Dibuja el fade
|
||||
if (counter >= INIT_FADE) {
|
||||
const float step = (float)(counter - INIT_FADE) / (float)(END_LOGO - INIT_FADE);
|
||||
if (counter_ >= INIT_FADE) {
|
||||
const float step = (float)(counter_ - INIT_FADE) / (float)(END_LOGO - INIT_FADE);
|
||||
const int alpha = std::min((int)(255 * step), 255);
|
||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, alpha);
|
||||
SDL_RenderFillRect(renderer, nullptr);
|
||||
SDL_SetRenderDrawColor(renderer_, bgColor.r, bgColor.g, bgColor.b, alpha);
|
||||
SDL_RenderFillRect(renderer_, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,12 +88,12 @@ void Logo::update() {
|
||||
Audio::update();
|
||||
checkInput();
|
||||
|
||||
if (SDL_GetTicks() - ticks > ticksSpeed) {
|
||||
if (SDL_GetTicks() - ticks_ > ticks_speed_) {
|
||||
// Actualiza el contador de ticks
|
||||
ticks = SDL_GetTicks();
|
||||
ticks_ = SDL_GetTicks();
|
||||
|
||||
// Actualiza el contador
|
||||
counter++;
|
||||
counter_++;
|
||||
|
||||
// Comprueba si ha terminado el logo
|
||||
checkLogoEnd();
|
||||
@@ -109,7 +109,7 @@ void Logo::render() {
|
||||
Screen::get()->clean({238, 238, 238});
|
||||
|
||||
// Dibuja los objetos
|
||||
sprite->render();
|
||||
sprite_->render();
|
||||
|
||||
// Dibuja el fade
|
||||
renderFade();
|
||||
@@ -122,7 +122,7 @@ void Logo::render() {
|
||||
void Logo::run() {
|
||||
Audio::get()->stopMusic();
|
||||
|
||||
while (section->name == SECTION_PROG_LOGO) {
|
||||
while (section_->name == SECTION_PROG_LOGO) {
|
||||
iterate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user