Input: mogudes structs, enums i consts a la part publica

This commit is contained in:
2025-07-30 08:53:57 +02:00
parent 677feb3afe
commit 989f081a25
14 changed files with 302 additions and 275 deletions

View File

@@ -66,19 +66,19 @@ void Player::init() {
shiftSprite();
// Selecciona un frame para pintar
//player_sprite_->setCurrentAnimation("stand");
// player_sprite_->setCurrentAnimation("stand");
}
// Actua en consecuencia de la entrada recibida
void Player::setInput(InputAction input) {
void Player::setInput(Input::Action action) {
switch (playing_state_) {
case State::PLAYING: {
setInputPlaying(input);
setInputPlaying(action);
break;
}
case State::ENTERING_NAME:
case State::ENTERING_NAME_GAME_COMPLETED: {
setInputEnteringName(input);
setInputEnteringName(action);
break;
}
default:
@@ -87,27 +87,27 @@ void Player::setInput(InputAction input) {
}
// Procesa inputs para cuando está jugando
void Player::setInputPlaying(InputAction input) {
switch (input) {
case InputAction::LEFT: {
void Player::setInputPlaying(Input::Action action) {
switch (action) {
case Input::Action::LEFT: {
vel_x_ = -BASE_SPEED;
setWalkingState(State::WALKING_LEFT);
break;
}
case InputAction::RIGHT: {
case Input::Action::RIGHT: {
vel_x_ = BASE_SPEED;
setWalkingState(State::WALKING_RIGHT);
break;
}
case InputAction::FIRE_CENTER: {
case Input::Action::FIRE_CENTER: {
setFiringState(State::FIRING_UP);
break;
}
case InputAction::FIRE_LEFT: {
case Input::Action::FIRE_LEFT: {
setFiringState(State::FIRING_LEFT);
break;
}
case InputAction::FIRE_RIGHT: {
case Input::Action::FIRE_RIGHT: {
setFiringState(State::FIRING_RIGHT);
break;
}
@@ -120,21 +120,21 @@ void Player::setInputPlaying(InputAction input) {
}
// Procesa inputs para cuando está introduciendo el nombre
void Player::setInputEnteringName(InputAction input) {
switch (input) {
case InputAction::LEFT:
void Player::setInputEnteringName(Input::Action action) {
switch (action) {
case Input::Action::LEFT:
enter_name_->decPosition();
break;
case InputAction::RIGHT:
case Input::Action::RIGHT:
enter_name_->incPosition();
break;
case InputAction::UP:
case Input::Action::UP:
enter_name_->incIndex();
break;
case InputAction::DOWN:
case Input::Action::DOWN:
enter_name_->decIndex();
break;
case InputAction::START:
case Input::Action::START:
last_enter_name_ = getRecordName();
break;
default:
@@ -288,7 +288,7 @@ void Player::handleEnteringScreen() {
}
void Player::handlePlayer1Entering() {
setInputPlaying(InputAction::RIGHT);
setInputPlaying(Input::Action::RIGHT);
pos_x_ += vel_x_;
if (pos_x_ > default_pos_x_) {
pos_x_ = default_pos_x_;
@@ -297,7 +297,7 @@ void Player::handlePlayer1Entering() {
}
void Player::handlePlayer2Entering() {
setInputPlaying(InputAction::LEFT);
setInputPlaying(Input::Action::LEFT);
pos_x_ += vel_x_;
if (pos_x_ < default_pos_x_) {
pos_x_ = default_pos_x_;
@@ -351,10 +351,10 @@ void Player::updateWalkingStateForCredits() {
void Player::setInputBasedOnPlayerId() {
switch (id_) {
case 1:
setInputPlaying(InputAction::LEFT);
setInputPlaying(Input::Action::LEFT);
break;
case 2:
setInputPlaying(InputAction::RIGHT);
setInputPlaying(Input::Action::RIGHT);
break;
default:
break;