style: ja pots mouret pel carrusel de posar nom mantenint la direccio apretada (ja no vas lletra a lletra)

This commit is contained in:
2025-10-22 19:55:02 +02:00
parent ce54b10abb
commit ef1a514c9b
3 changed files with 23 additions and 10 deletions

View File

@@ -9,6 +9,7 @@
#include "animated_sprite.hpp" // Para AnimatedSprite
#include "asset.hpp" // Para Asset
#include "audio.hpp" // Para Audio
#include "cooldown.hpp" // Para Cooldown
#include "input.hpp" // Para Input
#include "input_types.hpp" // Para InputAction
#include "manage_hiscore_table.hpp" // Para ManageHiScoreTable, HiScoreEntry
@@ -22,6 +23,7 @@ Player::Player(const Config& config)
: player_sprite_(std::make_unique<AnimatedSprite>(config.texture.at(0), config.animations.at(0))),
power_sprite_(std::make_unique<AnimatedSprite>(config.texture.at(4), config.animations.at(1))),
enter_name_(std::make_unique<EnterName>()),
cooldown_(std::make_unique<Cooldown>(0.300F, 0.140F)),
hi_score_table_(config.hi_score_table),
glowing_entry_(config.glowing_entry),
stage_info_(config.stage_info),
@@ -150,15 +152,19 @@ void Player::setInputEnteringName(Input::Action action) {
}
break;
case Input::Action::RIGHT:
if (!enter_name_->nameIsFull()) {
enter_name_->incIndex();
playSound("service_menu_move.wav");
if (!isShowingName() && !enter_name_->nameIsFull()) {
if (cooldown_->tryConsumeOnHeld()) {
enter_name_->incIndex();
playSound("service_menu_move.wav");
}
}
break;
case Input::Action::LEFT:
if (!enter_name_->nameIsFull()) {
enter_name_->decIndex();
playSound("service_menu_move.wav");
if (!isShowingName() && !enter_name_->nameIsFull()) {
if (cooldown_->tryConsumeOnHeld()) {
enter_name_->decIndex();
playSound("service_menu_move.wav");
}
}
break;
case Input::Action::START:
@@ -171,6 +177,7 @@ void Player::setInputEnteringName(Input::Action action) {
}
break;
default:
cooldown_->onReleased();
break;
}
name_entry_idle_time_accumulator_ = 0.0F;
@@ -543,6 +550,7 @@ void Player::update(float delta_time) {
updateContinueCounter(delta_time); // Sistema de continue
updateEnterNameCounter(delta_time); // Sistema de name entry
updateShowingName(delta_time); // Sistema de showing name
cooldown_->update(delta_time);
}
void Player::passShowingName() {

View File

@@ -9,8 +9,9 @@
#include <utility> // Para move, pair
#include <vector> // Para vector
#include "animated_sprite.hpp" // for AnimatedSprite
#include "bullet.hpp" // for Bullet
#include "animated_sprite.hpp" // for AnimatedSprite
#include "bullet.hpp" // for Bullet
#include "cooldown.hpp"
#include "enter_name.hpp" // for EnterName
#include "input.hpp" // for Input
#include "manage_hiscore_table.hpp" // for Table
@@ -249,6 +250,7 @@ class Player {
std::unique_ptr<AnimatedSprite> player_sprite_; // Sprite para dibujar el jugador
std::unique_ptr<AnimatedSprite> power_sprite_; // Sprite para dibujar el aura del jugador con el poder a tope
std::unique_ptr<EnterName> enter_name_; // Clase utilizada para introducir el nombre
std::unique_ptr<Cooldown> cooldown_ = nullptr; // Objeto para gestionar cooldowns de teclado
std::shared_ptr<Input::Gamepad> gamepad_ = nullptr; // Dispositivo asociado
Table* hi_score_table_ = nullptr; // Tabla de máximas puntuaciones
int* glowing_entry_ = nullptr; // Entrada de la tabla de puntuaciones para hacerla brillar

View File

@@ -1448,12 +1448,12 @@ void Game::handleNameInput(const std::shared_ptr<Player>& player) {
return;
}
if (input_->checkAction(Input::Action::LEFT, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
if (input_->checkAction(Input::Action::LEFT, Input::ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
player->setInput(Input::Action::LEFT);
return;
}
if (input_->checkAction(Input::Action::RIGHT, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
if (input_->checkAction(Input::Action::RIGHT, Input::ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
player->setInput(Input::Action::RIGHT);
return;
}
@@ -1461,7 +1461,10 @@ void Game::handleNameInput(const std::shared_ptr<Player>& player) {
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
player->setInput(Input::Action::START);
updateHiScoreName();
return;
}
player->setInput(Input::Action::NONE);
}
// Inicializa las variables para el modo DEMO