GamepadManager::swapPlayers() ja notifica als jugadors

This commit is contained in:
2025-08-10 09:35:12 +02:00
parent 3f34f80661
commit 8eb8e07e0a
4 changed files with 76 additions and 55 deletions

View File

@@ -122,71 +122,60 @@ Game::~Game() {
Scoreboard::destroy();
SDL_DestroyTexture(canvas_);
// Desregistra los jugadores de Options
// Desregistra los jugadores de Options
Options::keyboard.clearPlayers();
Options::gamepad_manager.clearPlayers();
}
// Asigna texturas y animaciones
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"));
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_powerup"));
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_one_hit"));
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_stop"));
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_100000_points"));
}
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"));
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_powerup"));
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_one_hit"));
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_stop"));
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_100000_points"));
// 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"));
item_textures_.emplace_back(Resource::get()->getTexture("item_clock.png"));
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee.png"));
item_textures_.emplace_back(Resource::get()->getTexture("item_debian.png"));
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee_machine.png"));
}
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"));
item_textures_.emplace_back(Resource::get()->getTexture("item_clock.png"));
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee.png"));
item_textures_.emplace_back(Resource::get()->getTexture("item_debian.png"));
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee_machine.png"));
player_textures_.clear();
// Texturas - Player1
{
std::vector<std::shared_ptr<Texture>> player_texture;
player_texture.emplace_back(Resource::get()->getTexture("player1.gif"));
player_texture.emplace_back(Resource::get()->getTexture("player1_power.png"));
player_textures_.push_back(player_texture);
}
std::vector<std::shared_ptr<Texture>> player1_textures;
player1_textures.emplace_back(Resource::get()->getTexture("player1.gif"));
player1_textures.emplace_back(Resource::get()->getTexture("player1_power.png"));
player_textures_.push_back(player1_textures);
// Texturas - Player2
{
std::vector<std::shared_ptr<Texture>> player_texture;
player_texture.emplace_back(Resource::get()->getTexture("player2.gif"));
player_texture.emplace_back(Resource::get()->getTexture("player2_power.png"));
player_textures_.push_back(player_texture);
}
std::vector<std::shared_ptr<Texture>> player2_textures;
player2_textures.emplace_back(Resource::get()->getTexture("player2.gif"));
player2_textures.emplace_back(Resource::get()->getTexture("player2_power.png"));
player_textures_.push_back(player2_textures);
// Animaciones -- Jugador
{
player_animations_.clear();
player_animations_.emplace_back(Resource::get()->getAnimation("player.ani"));
player_animations_.emplace_back(Resource::get()->getAnimation("player_power.ani"));
}
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"));
item_animations_.emplace_back(Resource::get()->getAnimation("item_clock.ani"));
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee.ani"));
item_animations_.emplace_back(Resource::get()->getAnimation("item_debian.ani"));
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee_machine.ani"));
}
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"));
item_animations_.emplace_back(Resource::get()->getAnimation("item_clock.ani"));
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee.ani"));
item_animations_.emplace_back(Resource::get()->getAnimation("item_debian.ani"));
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee_machine.ani"));
}
// Actualiza el valor de hiScore en caso necesario
@@ -1642,8 +1631,10 @@ void Game::initPlayers(Player::Id player_id) {
}
// Registra los jugadores en Options
Options::keyboard.addPlayer(players_.at(0));
Options::keyboard.addPlayer(players_.at(1));
for (auto player : players_) {
Options::keyboard.addPlayer(player);
Options::gamepad_manager.addPlayer(player);
}
}
// Hace sonar la música