style: modificat el desplaçament de la llista de logros
This commit is contained in:
@@ -32,6 +32,7 @@ Title::Title()
|
||||
menu_text_(Resource::get()->getText("gauntlet")),
|
||||
first_active_letter_(0),
|
||||
last_active_letter_(0),
|
||||
cheevos_scroll_velocity_(0.0F),
|
||||
state_time_(0.0F),
|
||||
fade_accumulator_(0.0F),
|
||||
exit_scene_(SceneManager::Scene::GAME),
|
||||
@@ -175,12 +176,6 @@ void Title::handleInput(float delta_time) {
|
||||
break;
|
||||
|
||||
case State::CHEEVOS_MENU:
|
||||
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);
|
||||
}
|
||||
|
||||
if (Input::get()->checkAction(InputAction::ACCEPT, Input::DO_NOT_ALLOW_REPEAT) ||
|
||||
Input::get()->checkAction(InputAction::CANCEL, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
resetCheevosScroll();
|
||||
@@ -358,6 +353,45 @@ void Title::updateMainMenu(float delta_time) {
|
||||
void Title::updateCheevosMenu(float delta_time) {
|
||||
// Actualiza la marquesina (sigue visible en fondo)
|
||||
updateMarquee(delta_time);
|
||||
|
||||
// Determina la velocidad objetivo basada en el input
|
||||
float target_velocity = 0.0F;
|
||||
if (Input::get()->checkAction(InputAction::RIGHT, Input::ALLOW_REPEAT)) {
|
||||
target_velocity = CHEEVOS_SCROLL_MAX_SPEED; // Scroll hacia abajo
|
||||
} else if (Input::get()->checkAction(InputAction::LEFT, Input::ALLOW_REPEAT)) {
|
||||
target_velocity = -CHEEVOS_SCROLL_MAX_SPEED; // Scroll hacia arriba
|
||||
}
|
||||
|
||||
// Interpola suavemente la velocidad actual hacia la velocidad objetivo
|
||||
if (target_velocity != 0.0F) {
|
||||
// Acelerando hacia la velocidad objetivo
|
||||
const float ACCELERATION_STEP = CHEEVOS_SCROLL_ACCELERATION * delta_time;
|
||||
if (cheevos_scroll_velocity_ < target_velocity) {
|
||||
cheevos_scroll_velocity_ = std::min(cheevos_scroll_velocity_ + ACCELERATION_STEP, target_velocity);
|
||||
} else if (cheevos_scroll_velocity_ > target_velocity) {
|
||||
cheevos_scroll_velocity_ = std::max(cheevos_scroll_velocity_ - ACCELERATION_STEP, target_velocity);
|
||||
}
|
||||
} else {
|
||||
// Desacelerando hacia 0
|
||||
const float DECELERATION_STEP = CHEEVOS_SCROLL_DECELERATION * delta_time;
|
||||
if (cheevos_scroll_velocity_ > 0.0F) {
|
||||
cheevos_scroll_velocity_ = std::max(cheevos_scroll_velocity_ - DECELERATION_STEP, 0.0F);
|
||||
} else if (cheevos_scroll_velocity_ < 0.0F) {
|
||||
cheevos_scroll_velocity_ = std::min(cheevos_scroll_velocity_ + DECELERATION_STEP, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
// Aplica la velocidad actual al scroll position
|
||||
if (cheevos_scroll_velocity_ != 0.0F) {
|
||||
cheevos_surface_view_.y += cheevos_scroll_velocity_ * delta_time;
|
||||
|
||||
// Ajusta los límites
|
||||
const float BOTTOM = cheevos_surface_->getHeight() - cheevos_surface_view_.h;
|
||||
cheevos_surface_view_.y = std::clamp(cheevos_surface_view_.y, 0.0F, BOTTOM);
|
||||
|
||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||
}
|
||||
|
||||
// No incrementar state_time_ (no timeout en este estado)
|
||||
}
|
||||
|
||||
@@ -407,23 +441,6 @@ void Title::run() {
|
||||
}
|
||||
}
|
||||
|
||||
// Desplaza la lista de logros
|
||||
void Title::moveCheevosList(int direction, float delta_time) {
|
||||
// Calcula el desplazamiento basado en tiempo
|
||||
const float DISPLACEMENT = CHEEVOS_SCROLL_SPEED * delta_time;
|
||||
|
||||
// Modifica la posición de la ventana de vista
|
||||
cheevos_surface_view_.y = direction == 0
|
||||
? cheevos_surface_view_.y - DISPLACEMENT
|
||||
: cheevos_surface_view_.y + DISPLACEMENT;
|
||||
|
||||
// Ajusta los limites
|
||||
const float BOTTOM = cheevos_surface_->getHeight() - cheevos_surface_view_.h;
|
||||
cheevos_surface_view_.y = std::clamp(cheevos_surface_view_.y, 0.0F, BOTTOM);
|
||||
|
||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||
}
|
||||
|
||||
// Crea y rellena la textura para mostrar los logros
|
||||
void Title::createCheevosTexture() {
|
||||
// Define la zona central del menu (entre el logo y la marquesina)
|
||||
@@ -482,6 +499,7 @@ void Title::createCheevosTexture() {
|
||||
// Resetea el scroll de la lista de logros
|
||||
void Title::resetCheevosScroll() {
|
||||
cheevos_surface_view_.y = 0;
|
||||
cheevos_scroll_velocity_ = 0.0F;
|
||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user