linter
This commit is contained in:
@@ -55,14 +55,14 @@ void Player::update(float delta_time) {
|
||||
// Comprueba las entradas y modifica variables
|
||||
void Player::handleInput() {
|
||||
if (Input::get()->checkAction(InputAction::LEFT)) {
|
||||
wannaGo = Direction::LEFT;
|
||||
wanna_go_ = Direction::LEFT;
|
||||
} else if (Input::get()->checkAction(InputAction::RIGHT)) {
|
||||
wannaGo = Direction::RIGHT;
|
||||
wanna_go_ = Direction::RIGHT;
|
||||
} else {
|
||||
wannaGo = Direction::NONE;
|
||||
wanna_go_ = Direction::NONE;
|
||||
}
|
||||
|
||||
wannaJump = Input::get()->checkAction(InputAction::JUMP);
|
||||
wanna_jump_ = Input::get()->checkAction(InputAction::JUMP);
|
||||
}
|
||||
|
||||
// La lógica de movimiento está distribuida en move
|
||||
@@ -89,7 +89,7 @@ void Player::move(float delta_time) {
|
||||
}
|
||||
|
||||
void Player::handleConveyorBelts() {
|
||||
if (!auto_movement_ and isOnConveyorBelt() and wannaGo == Direction::NONE) {
|
||||
if (!auto_movement_ and isOnConveyorBelt() and wanna_go_ == Direction::NONE) {
|
||||
auto_movement_ = true;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ void Player::updateOnGround(float delta_time) {
|
||||
handleShouldFall(); // Verifica si debe caer (no tiene suelo)
|
||||
|
||||
// Verifica si el jugador quiere saltar
|
||||
if (wannaJump) { transitionToState(State::JUMPING); }
|
||||
if (wanna_jump_) { transitionToState(State::JUMPING); }
|
||||
}
|
||||
|
||||
// Actualización lógica del estado ON_SLOPE
|
||||
@@ -182,7 +182,7 @@ void Player::updateOnSlope(float delta_time) {
|
||||
// todas las condiciones de salida de la rampa (out of bounds, transición a superficie plana)
|
||||
|
||||
// Verifica si el jugador quiere saltar
|
||||
if (wannaJump) { transitionToState(State::JUMPING); }
|
||||
if (wanna_jump_) { transitionToState(State::JUMPING); }
|
||||
}
|
||||
|
||||
// Actualización lógica del estado JUMPING
|
||||
@@ -200,7 +200,7 @@ void Player::updateFalling(float delta_time) {
|
||||
|
||||
// Movimiento físico del estado ON_GROUND
|
||||
void Player::moveOnGround(float delta_time) {
|
||||
// Determinama cuál debe ser la velocidad a partir de automovement o de wannaGo
|
||||
// Determinama cuál debe ser la velocidad a partir de automovement o de wanna_go_
|
||||
updateVelocity();
|
||||
|
||||
if (vx_ == 0.0F) { return; }
|
||||
@@ -229,7 +229,7 @@ void Player::moveOnGround(float delta_time) {
|
||||
|
||||
// Movimiento físico del estado ON_SLOPE
|
||||
void Player::moveOnSlope(float delta_time) {
|
||||
// Determinama cuál debe ser la velocidad a partir de automovement o de wannaGo
|
||||
// Determinama cuál debe ser la velocidad a partir de automovement o de wanna_go_
|
||||
updateVelocity();
|
||||
|
||||
if (vx_ == 0.0F) { return; }
|
||||
@@ -636,35 +636,35 @@ void Player::initSounds() {
|
||||
|
||||
// Implementación de JumpSoundController::start
|
||||
void Player::JumpSoundController::start() {
|
||||
current_index_ = 0;
|
||||
elapsed_time_ = 0.0F;
|
||||
active_ = true;
|
||||
current_index = 0;
|
||||
elapsed_time = 0.0F;
|
||||
active = true;
|
||||
}
|
||||
|
||||
// Implementación de JumpSoundController::reset
|
||||
void Player::JumpSoundController::reset() {
|
||||
active_ = false;
|
||||
current_index_ = 0;
|
||||
elapsed_time_ = 0.0F;
|
||||
active = false;
|
||||
current_index = 0;
|
||||
elapsed_time = 0.0F;
|
||||
}
|
||||
|
||||
// Implementación de JumpSoundController::shouldPlay
|
||||
auto Player::JumpSoundController::shouldPlay(float delta_time, size_t& out_index) -> bool {
|
||||
if (!active_) {
|
||||
if (!active) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Acumula el tiempo transcurrido durante el salto
|
||||
elapsed_time_ += delta_time;
|
||||
elapsed_time += delta_time;
|
||||
|
||||
// Calcula qué sonido debería estar sonando según el tiempo
|
||||
size_t target_index = FIRST_SOUND + static_cast<size_t>(elapsed_time_ / SECONDS_PER_SOUND);
|
||||
size_t target_index = FIRST_SOUND + static_cast<size_t>(elapsed_time / SECONDS_PER_SOUND);
|
||||
target_index = std::min(target_index, LAST_SOUND);
|
||||
|
||||
// Reproduce si hemos avanzado a un nuevo sonido
|
||||
if (target_index > current_index_) {
|
||||
current_index_ = target_index;
|
||||
out_index = current_index_;
|
||||
if (target_index > current_index) {
|
||||
current_index = target_index;
|
||||
out_index = current_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -673,42 +673,42 @@ auto Player::JumpSoundController::shouldPlay(float delta_time, size_t& out_index
|
||||
|
||||
// Implementación de FallSoundController::start
|
||||
void Player::FallSoundController::start(float start_y) {
|
||||
current_index_ = 0;
|
||||
distance_traveled_ = 0.0F;
|
||||
last_y_ = start_y;
|
||||
active_ = true;
|
||||
current_index = 0;
|
||||
distance_traveled = 0.0F;
|
||||
last_y = start_y;
|
||||
active = true;
|
||||
}
|
||||
|
||||
// Implementación de FallSoundController::reset
|
||||
void Player::FallSoundController::reset() {
|
||||
active_ = false;
|
||||
current_index_ = 0;
|
||||
distance_traveled_ = 0.0F;
|
||||
active = false;
|
||||
current_index = 0;
|
||||
distance_traveled = 0.0F;
|
||||
}
|
||||
|
||||
// Implementación de FallSoundController::shouldPlay
|
||||
auto Player::FallSoundController::shouldPlay(float delta_time, float current_y, size_t& out_index) -> bool {
|
||||
(void)delta_time; // No usado actualmente, pero recibido por consistencia
|
||||
|
||||
if (!active_) {
|
||||
if (!active) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Acumula la distancia recorrida (solo hacia abajo)
|
||||
if (current_y > last_y_) {
|
||||
distance_traveled_ += (current_y - last_y_);
|
||||
if (current_y > last_y) {
|
||||
distance_traveled += (current_y - last_y);
|
||||
}
|
||||
last_y_ = current_y;
|
||||
last_y = current_y;
|
||||
|
||||
// Calcula qué sonido debería estar sonando según el intervalo
|
||||
size_t target_index = FIRST_SOUND + static_cast<size_t>(distance_traveled_ / PIXELS_PER_SOUND);
|
||||
size_t target_index = FIRST_SOUND + static_cast<size_t>(distance_traveled / PIXELS_PER_SOUND);
|
||||
|
||||
// El sonido a reproducir se limita a LAST_SOUND (13), pero el índice interno sigue creciendo
|
||||
size_t sound_to_play = std::min(target_index, LAST_SOUND);
|
||||
|
||||
// Reproduce si hemos avanzado a un nuevo índice (permite repetición de sonido 13)
|
||||
if (target_index > current_index_) {
|
||||
current_index_ = target_index; // Guardamos el índice real (puede ser > LAST_SOUND)
|
||||
if (target_index > current_index) {
|
||||
current_index = target_index; // Guardamos el índice real (puede ser > LAST_SOUND)
|
||||
out_index = sound_to_play; // Pero reproducimos LAST_SOUND cuando corresponde
|
||||
return true;
|
||||
}
|
||||
@@ -768,7 +768,7 @@ void Player::updateVelocity() {
|
||||
sprite_->setFlip(vx_ < 0.0F ? Flip::LEFT : Flip::RIGHT);
|
||||
} else {
|
||||
// El jugador tiene el control
|
||||
switch (wannaGo) {
|
||||
switch (wanna_go_) {
|
||||
case Direction::LEFT:
|
||||
vx_ = -HORIZONTAL_VELOCITY;
|
||||
sprite_->setFlip(Flip::LEFT);
|
||||
|
||||
Reference in New Issue
Block a user