migrant input: ja compila, ja no peta... falta descomentar mig codi
This commit is contained in:
@@ -125,6 +125,7 @@ Game::~Game() {
|
||||
void Game::setResources() {
|
||||
// Texturas - Game_text
|
||||
{
|
||||
game_text_textures_.clear();
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_1000_points"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_2500_points"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_5000_points"));
|
||||
@@ -136,6 +137,7 @@ void Game::setResources() {
|
||||
|
||||
// Texturas - Items
|
||||
{
|
||||
item_textures_.clear();
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_points1_disk.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_points2_gavina.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_points3_pacmar.png"));
|
||||
@@ -145,6 +147,7 @@ void Game::setResources() {
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee_machine.png"));
|
||||
}
|
||||
|
||||
player_textures_.clear();
|
||||
// Texturas - Player1
|
||||
{
|
||||
std::vector<std::shared_ptr<Texture>> player_texture;
|
||||
@@ -163,12 +166,14 @@ void Game::setResources() {
|
||||
|
||||
// Animaciones -- Jugador
|
||||
{
|
||||
player_animations_.clear();
|
||||
player_animations_.emplace_back(Resource::get()->getAnimation("player.ani"));
|
||||
player_animations_.emplace_back(Resource::get()->getAnimation("player_power.ani"));
|
||||
}
|
||||
|
||||
// Animaciones -- Items
|
||||
{
|
||||
item_animations_.clear();
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_points1_disk.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_points2_gavina.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_points3_pacmar.ani"));
|
||||
@@ -1243,8 +1248,9 @@ void Game::checkInput() {
|
||||
// Verifica si alguno de los controladores ha solicitado una pausa y actualiza el estado de pausa del juego.
|
||||
void Game::checkPauseInput() {
|
||||
// Comprueba los mandos
|
||||
for (int i = 0; i < input_->getNumControllers(); ++i) {
|
||||
if (input_->checkAction(Input::Action::PAUSE, Input::DO_NOT_ALLOW_REPEAT, Input::Device::CONTROLLER, i)) {
|
||||
auto gamepads = input_->getGamepads();
|
||||
for (auto gamepad : gamepads) {
|
||||
if (input_->checkAction(Input::Action::PAUSE, Input::DO_NOT_ALLOW_REPEAT, Input::Device::CONTROLLER, gamepad)) {
|
||||
pause(!paused_);
|
||||
return;
|
||||
}
|
||||
@@ -1360,14 +1366,14 @@ void Game::handlePlayersInput() {
|
||||
|
||||
// Maneja las entradas de movimiento y disparo para un jugador en modo normal.
|
||||
void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player) {
|
||||
const auto &controller = Options::controllers.at(player->getController());
|
||||
const auto &controller = Options::controllers.at(0);
|
||||
|
||||
if (input_->checkAction(Input::Action::LEFT, Input::ALLOW_REPEAT, controller.type, controller.index)) {
|
||||
if (input_->checkAction(Input::Action::LEFT, Input::ALLOW_REPEAT, controller.type, controller.gamepad)) {
|
||||
player->setInput(Input::Action::LEFT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.left = 1;
|
||||
#endif
|
||||
} else if (input_->checkAction(Input::Action::RIGHT, Input::ALLOW_REPEAT, controller.type, controller.index)) {
|
||||
} else if (input_->checkAction(Input::Action::RIGHT, Input::ALLOW_REPEAT, controller.type, controller.gamepad)) {
|
||||
player->setInput(Input::Action::RIGHT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.right = 1;
|
||||
@@ -1380,23 +1386,23 @@ void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player) {
|
||||
}
|
||||
|
||||
const bool AUTOFIRE = player->isPowerUp() || Options::settings.autofire;
|
||||
handleFireInputs(player, AUTOFIRE, player->getController()); // Verifica y maneja todas las posibles entradas de disparo.
|
||||
handleFireInputs(player, AUTOFIRE); // Verifica y maneja todas las posibles entradas de disparo.
|
||||
}
|
||||
|
||||
// Procesa las entradas de disparo del jugador, permitiendo disparos automáticos si está habilitado.
|
||||
void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire, int controller_index) {
|
||||
const auto CONTROLLER = Options::controllers.at(player->getController());
|
||||
if (input_->checkAction(Input::Action::FIRE_CENTER, autofire, CONTROLLER.type, CONTROLLER.index)) {
|
||||
void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire) {
|
||||
const auto CONTROLLER = Options::controllers.at(0);
|
||||
if (input_->checkAction(Input::Action::FIRE_CENTER, autofire, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
handleFireInput(player, BulletType::UP);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire = 1;
|
||||
#endif
|
||||
} else if (input_->checkAction(Input::Action::FIRE_LEFT, autofire, CONTROLLER.type, CONTROLLER.index)) {
|
||||
} else if (input_->checkAction(Input::Action::FIRE_LEFT, autofire, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
handleFireInput(player, BulletType::LEFT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire_left = 1;
|
||||
#endif
|
||||
} else if (input_->checkAction(Input::Action::FIRE_RIGHT, autofire, CONTROLLER.type, CONTROLLER.index)) {
|
||||
} else if (input_->checkAction(Input::Action::FIRE_RIGHT, autofire, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
handleFireInput(player, BulletType::RIGHT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire_right = 1;
|
||||
@@ -1406,17 +1412,17 @@ void Game::handleFireInputs(const std::shared_ptr<Player> &player, bool autofire
|
||||
|
||||
// Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio.
|
||||
void Game::handlePlayerContinueInput(const std::shared_ptr<Player> &player) {
|
||||
const auto CONTROLLER = Options::controllers.at(player->getController());
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
||||
const auto CONTROLLER = Options::controllers.at(0);
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
player->setPlayingState(Player::State::RESPAWNING);
|
||||
player->addCredit();
|
||||
sendPlayerToTheFront(player);
|
||||
}
|
||||
|
||||
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) ||
|
||||
input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad) ||
|
||||
input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (player->getContinueCounter() < param.scoreboard.skip_countdown_value) {
|
||||
player->decContinueCounter();
|
||||
}
|
||||
@@ -1425,8 +1431,8 @@ void Game::handlePlayerContinueInput(const std::shared_ptr<Player> &player) {
|
||||
|
||||
// Maneja la continuación del jugador cuando no está jugando, permitiendo que continúe si se pulsa el botón de inicio.
|
||||
void Game::handlePlayerWaitingInput(const std::shared_ptr<Player> &player) {
|
||||
const auto CONTROLLER = Options::controllers.at(player->getController());
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
||||
const auto CONTROLLER = Options::controllers.at(0);
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
player->setPlayingState(Player::State::ENTERING_SCREEN);
|
||||
player->addCredit();
|
||||
sendPlayerToTheFront(player);
|
||||
@@ -1435,8 +1441,8 @@ void Game::handlePlayerWaitingInput(const std::shared_ptr<Player> &player) {
|
||||
|
||||
// Procesa las entradas para la introducción del nombre del jugador.
|
||||
void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
||||
const auto CONTROLLER = Options::controllers.at(player->getController());
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
||||
const auto CONTROLLER = Options::controllers.at(0);
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else if (player->getEnterNamePositionOverflow()) {
|
||||
@@ -1446,18 +1452,18 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
||||
} else {
|
||||
player->setInput(Input::Action::RIGHT);
|
||||
}
|
||||
} else if (input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
||||
} else if (input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else {
|
||||
player->setInput(Input::Action::LEFT);
|
||||
}
|
||||
} else if (input_->checkAction(Input::Action::UP, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
||||
} else if (input_->checkAction(Input::Action::UP, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
player->setInput(Input::Action::UP);
|
||||
} else if (input_->checkAction(Input::Action::DOWN, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
||||
} else if (input_->checkAction(Input::Action::DOWN, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
player->setInput(Input::Action::DOWN);
|
||||
} else if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index)) {
|
||||
} else if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.gamepad)) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else {
|
||||
|
||||
@@ -198,13 +198,13 @@ class Game {
|
||||
void checkPauseInput(); // Verifica solicitudes de pausa de controladores
|
||||
|
||||
// --- Entrada de jugadores normales ---
|
||||
void handlePlayersInput(); // Gestiona entrada de todos los jugadores
|
||||
void handleNormalPlayerInput(const std::shared_ptr<Player> &player); // Procesa entrada de un jugador específico
|
||||
void handleFireInput(const std::shared_ptr<Player> &player, BulletType bullet_type); // Gestiona disparo de jugador
|
||||
void handleFireInputs(const std::shared_ptr<Player> &player, bool autofire, int controller_index); // Procesa disparos automáticos
|
||||
void handlePlayerContinueInput(const std::shared_ptr<Player> &player); // Permite continuar al jugador
|
||||
void handlePlayerWaitingInput(const std::shared_ptr<Player> &player); // Permite (re)entrar al jugador
|
||||
void handleNameInput(const std::shared_ptr<Player> &player); // Gestiona entrada de nombre del jugador
|
||||
void handlePlayersInput(); // Gestiona entrada de todos los jugadores
|
||||
void handleNormalPlayerInput(const std::shared_ptr<Player> &player); // Procesa entrada de un jugador específico
|
||||
void handleFireInput(const std::shared_ptr<Player> &player, BulletType bullet_type); // Gestiona disparo de jugador
|
||||
void handleFireInputs(const std::shared_ptr<Player> &player, bool autofire); // Procesa disparos automáticos
|
||||
void handlePlayerContinueInput(const std::shared_ptr<Player> &player); // Permite continuar al jugador
|
||||
void handlePlayerWaitingInput(const std::shared_ptr<Player> &player); // Permite (re)entrar al jugador
|
||||
void handleNameInput(const std::shared_ptr<Player> &player); // Gestiona entrada de nombre del jugador
|
||||
|
||||
// --- Entrada en modo demo ---
|
||||
void demoHandleInput(); // Gestiona entrada durante el modo demostración
|
||||
|
||||
@@ -274,7 +274,7 @@ auto Title::isStartButtonPressed(const Options::GamepadOptions& controller) -> b
|
||||
Input::Action::START,
|
||||
Input::DO_NOT_ALLOW_REPEAT,
|
||||
controller.type,
|
||||
controller.index);
|
||||
controller.gamepad);
|
||||
}
|
||||
|
||||
void Title::handleStartButtonPress(const Options::GamepadOptions& controller) {
|
||||
@@ -357,12 +357,12 @@ void Title::showControllers() {
|
||||
}
|
||||
|
||||
// Genera el texto correspondiente
|
||||
for (size_t i = 0; i < NUM_CONTROLLERS; ++i) {
|
||||
const size_t INDEX = player_controller_index.at(i);
|
||||
if (Options::controllers.at(INDEX).plugged) {
|
||||
text.at(i) = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(i + 1) + ": " + Options::controllers.at(INDEX).name;
|
||||
}
|
||||
}
|
||||
//for (size_t i = 0; i < NUM_CONTROLLERS; ++i) {
|
||||
// const size_t INDEX = player_controller_index.at(i);
|
||||
// if (Options::controllers.at(INDEX).plugged) {
|
||||
// text.at(i) = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(i + 1) + ": " + Options::controllers.at(INDEX).name;
|
||||
// }
|
||||
//}
|
||||
|
||||
// Muestra la notificación
|
||||
Notifier::get()->show({text.at(0), text.at(1)});
|
||||
|
||||
Reference in New Issue
Block a user