Afegit global_events.cpp
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#include "texture.h" // Para Texture
|
||||
#include "tiled_bg.h" // Para TiledBG, TiledBGMode
|
||||
#include "utils.h" // Para Color, shdw_txt_color, Zone, no_color
|
||||
#include "mouse.h"
|
||||
#include "global_events.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <vector>
|
||||
@@ -236,20 +236,20 @@ void Instructions::update()
|
||||
view_.y = std::max(0, param.game.height - counter_ + 100);
|
||||
|
||||
// Verifica si view_.y == 0 y gestiona el temporizador
|
||||
if (view_.y == 0)
|
||||
{
|
||||
if (!start_delay_triggered_)
|
||||
{
|
||||
// Activa el temporizador si no ha sido activado
|
||||
start_delay_triggered_ = true;
|
||||
start_delay_time_ = SDL_GetTicks();
|
||||
}
|
||||
else if (SDL_GetTicks() - start_delay_time_ >= 4000)
|
||||
{
|
||||
// Han pasado tres segundos, mover líneas
|
||||
all_lines_off_screen_ = moveLines(lines_, 320, 1.0f, 5);
|
||||
}
|
||||
}
|
||||
if (view_.y == 0)
|
||||
{
|
||||
if (!start_delay_triggered_)
|
||||
{
|
||||
// Activa el temporizador si no ha sido activado
|
||||
start_delay_triggered_ = true;
|
||||
start_delay_time_ = SDL_GetTicks();
|
||||
}
|
||||
else if (SDL_GetTicks() - start_delay_time_ >= 4000)
|
||||
{
|
||||
// Han pasado tres segundos, mover líneas
|
||||
all_lines_off_screen_ = moveLines(lines_, 320, 1.0f, 5);
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el mosaico de fondo
|
||||
tiled_bg_->update();
|
||||
@@ -293,43 +293,13 @@ void Instructions::render()
|
||||
Screen::get()->render();
|
||||
}
|
||||
|
||||
// Recarga todas las texturas
|
||||
void Instructions::reloadTextures()
|
||||
{
|
||||
for (auto &texture : item_textures_)
|
||||
{
|
||||
texture->reLoad();
|
||||
}
|
||||
text_->reLoadTexture();
|
||||
fillTexture();
|
||||
}
|
||||
|
||||
// Comprueba los eventos
|
||||
void Instructions::checkEvents()
|
||||
{
|
||||
// Comprueba los eventos que hay en la cola
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
// Evento de salida de la aplicación
|
||||
if (event.type == SDL_QUIT)
|
||||
{
|
||||
section::name = section::Name::QUIT;
|
||||
section::options = section::Options::QUIT_FROM_EVENT;
|
||||
break;
|
||||
}
|
||||
|
||||
// Comprueba si se ha cambiado el tamaño de la ventana
|
||||
else if (event.type == SDL_WINDOWEVENT)
|
||||
{
|
||||
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||
{
|
||||
reloadTextures();
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el cursor
|
||||
Mouse::handleEvent(event);
|
||||
globalEvents::check(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user