migrat Input a la ultima versió
cohesionats tots els metodes update de les escenes
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
|
||||
#include <algorithm> // Para clamp
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input, InputAction, INPUT_DO_NOT_ALLOW_REPEAT, REP...
|
||||
#include "core/input/input.hpp" // Para Input, InputAction, Input::DO_NOT_ALLOW_REPEAT, REP...
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
@@ -30,8 +31,7 @@ Title::Title()
|
||||
first_active_letter_(0),
|
||||
last_active_letter_(0),
|
||||
state_time_(0.0F),
|
||||
fade_accumulator_(0.0F),
|
||||
current_delta_(0.0F) {
|
||||
fade_accumulator_(0.0F) {
|
||||
// Inicializa variables
|
||||
state_ = SceneManager::options == SceneManager::Options::TITLE_WITH_LOADING_SCREEN ? State::SHOW_LOADING_SCREEN : State::SHOW_MENU;
|
||||
SceneManager::current = SceneManager::Scene::TITLE;
|
||||
@@ -72,10 +72,10 @@ void Title::initMarquee() {
|
||||
}
|
||||
|
||||
// Comprueba el manejador de eventos
|
||||
void Title::checkEvents() {
|
||||
void Title::handleEvents() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
GlobalEvents::check(event);
|
||||
GlobalEvents::handle(event);
|
||||
|
||||
// Solo se comprueban estas teclas si no está activo el menu de logros
|
||||
if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
@@ -99,24 +99,26 @@ void Title::checkEvents() {
|
||||
}
|
||||
|
||||
// Comprueba las entradas
|
||||
void Title::checkInput() {
|
||||
void Title::handleInput(float delta_time) {
|
||||
Input::get()->update();
|
||||
|
||||
if (show_cheevos_) {
|
||||
if (Input::get()->checkInput(InputAction::DOWN, INPUT_ALLOW_REPEAT)) {
|
||||
moveCheevosList(1, current_delta_);
|
||||
} else if (Input::get()->checkInput(InputAction::UP, INPUT_ALLOW_REPEAT)) {
|
||||
moveCheevosList(0, current_delta_);
|
||||
} else if (Input::get()->checkInput(InputAction::ACCEPT, INPUT_DO_NOT_ALLOW_REPEAT)) {
|
||||
if (Input::get()->checkAction(InputAction::RIGHT, Input::ALLOW_REPEAT)) {
|
||||
moveCheevosList(1, delta_time);
|
||||
} else if (Input::get()->checkAction(InputAction::LEFT, Input::ALLOW_REPEAT)) {
|
||||
moveCheevosList(0, delta_time);
|
||||
} else if (Input::get()->checkAction(InputAction::ACCEPT, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
hideCheevosList();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input::get()->checkInput(InputAction::ACCEPT, INPUT_DO_NOT_ALLOW_REPEAT)) {
|
||||
if (Input::get()->checkAction(InputAction::ACCEPT, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
if (state_ == State::SHOW_LOADING_SCREEN) {
|
||||
transitionToState(State::FADE_LOADING_SCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
GlobalInputs::check();
|
||||
GlobalInputs::handle();
|
||||
}
|
||||
|
||||
// Actualiza la marquesina
|
||||
@@ -169,16 +171,15 @@ void Title::renderMarquee() {
|
||||
// Actualiza las variables
|
||||
void Title::update() {
|
||||
// Obtener delta time
|
||||
current_delta_ = delta_timer_->tick();
|
||||
const float DELTA_TIME = delta_timer_->tick();
|
||||
|
||||
// Comprueba las entradas
|
||||
checkInput();
|
||||
handleEvents(); // Comprueba los eventos
|
||||
handleInput(DELTA_TIME); // Comprueba las entradas
|
||||
|
||||
// Actualiza la pantalla
|
||||
Screen::get()->update(current_delta_);
|
||||
updateState(DELTA_TIME); // Actualiza el estado actual
|
||||
|
||||
// Actualiza el estado actual
|
||||
updateState(current_delta_);
|
||||
Audio::get()->update(); // Actualiza el objeto Audio
|
||||
Screen::get()->update(DELTA_TIME); // Actualiza el objeto Screen
|
||||
}
|
||||
|
||||
// Actualiza el estado actual
|
||||
@@ -263,7 +264,6 @@ void Title::render() {
|
||||
void Title::run() {
|
||||
while (SceneManager::current == SceneManager::Scene::TITLE) {
|
||||
update();
|
||||
checkEvents();
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user