bug fix: en la tabla de puntuacions, no apareix la estreleta al completar el joc amb 1CC
bug fix: posant nom al completar el joc, si "passes" el mostrar el nom, mata al jugador en lloc de fer que se'n vaja Resol #92 i #98
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 872 B After Width: | Height: | Size: 882 B |
@@ -42,7 +42,7 @@ Director::Director(int argc, std::span<char *> argv) {
|
||||
Section::name = Section::Name::GAME;
|
||||
Section::options = Section::Options::GAME_PLAY_1P;
|
||||
#elif _DEBUG
|
||||
Section::name = Section::Name::GAME;
|
||||
Section::name = Section::Name::HI_SCORE_TABLE;
|
||||
Section::options = Section::Options::GAME_PLAY_1P;
|
||||
#else // NORMAL GAME
|
||||
Section::name = Section::Name::LOGO;
|
||||
|
||||
@@ -10,10 +10,10 @@ struct HiScoreEntry {
|
||||
bool one_credit_complete; // Indica si se ha conseguido 1CC
|
||||
|
||||
// Constructor
|
||||
explicit HiScoreEntry(const std::string &n = "", int s = 0, bool occ = false)
|
||||
: name(n.substr(0, 6)),
|
||||
score(s),
|
||||
one_credit_complete(occ) {}
|
||||
explicit HiScoreEntry(const std::string &name = "", int score = 0, bool one_credit_complete = false)
|
||||
: name(name.substr(0, 6)),
|
||||
score(score),
|
||||
one_credit_complete(one_credit_complete) {}
|
||||
};
|
||||
|
||||
// --- Tipos ---
|
||||
|
||||
@@ -595,6 +595,14 @@ void Player::update() {
|
||||
updateShowingName();
|
||||
}
|
||||
|
||||
void Player::passShowingName() {
|
||||
if (game_completed_) {
|
||||
setPlayingState(State::LEAVING_SCREEN);
|
||||
} else {
|
||||
setPlayingState(State::CONTINUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Incrementa la puntuación del jugador
|
||||
void Player::addScore(int score, int lowest_hi_score_entry) {
|
||||
if (isPlaying()) {
|
||||
|
||||
@@ -170,7 +170,7 @@ class Player {
|
||||
[[nodiscard]] static auto getWidth() -> int { return WIDTH; }
|
||||
[[nodiscard]] auto getPlayingState() const -> State { return playing_state_; }
|
||||
[[nodiscard]] auto getName() const -> const std::string & { return name_; }
|
||||
[[nodiscard]] auto get1CC() const -> bool { return game_completed_ && credits_used_ == 1; }
|
||||
[[nodiscard]] auto get1CC() const -> bool { return game_completed_ && credits_used_ <= 1; }
|
||||
[[nodiscard]] auto getEnterNamePositionOverflow() const -> bool { return enter_name_ ? enter_name_->getPositionOverflow() : false; }
|
||||
|
||||
// Setters inline
|
||||
@@ -186,6 +186,7 @@ class Player {
|
||||
void setWalkingState(State state) { walking_state_ = state; }
|
||||
|
||||
void addCredit();
|
||||
void passShowingName();
|
||||
void setGamepad(std::shared_ptr<Input::Gamepad> gamepad) { gamepad_ = std::move(gamepad); }
|
||||
[[nodiscard]] auto getGamepad() const -> std::shared_ptr<Input::Gamepad> { return gamepad_; }
|
||||
void setUsesKeyboard(bool value) { uses_keyboard_ = value; }
|
||||
|
||||
@@ -1373,17 +1373,27 @@ void Game::handleNormalPlayerInput(const std::shared_ptr<Player> &player) {
|
||||
|
||||
// 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) {
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (input_->checkAction(Input::Action::FIRE_CENTER, autofire, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
handleFireInput(player, BulletType::UP);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire = 1;
|
||||
#endif
|
||||
} else if (input_->checkAction(Input::Action::FIRE_LEFT, autofire, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, autofire, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
handleFireInput(player, BulletType::LEFT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire_left = 1;
|
||||
#endif
|
||||
} else if (input_->checkAction(Input::Action::FIRE_RIGHT, autofire, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (input_->checkAction(Input::Action::FIRE_RIGHT, autofire, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
handleFireInput(player, BulletType::RIGHT);
|
||||
#ifdef RECORDING
|
||||
demo_.keys.fire_right = 1;
|
||||
@@ -1397,6 +1407,7 @@ void Game::handlePlayerContinueInput(const std::shared_ptr<Player> &player) {
|
||||
player->setPlayingState(Player::State::RECOVER);
|
||||
player->addCredit();
|
||||
sendPlayerToTheFront(player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
||||
@@ -1422,39 +1433,53 @@ void Game::handlePlayerWaitingInput(const std::shared_ptr<Player> &player) {
|
||||
void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
||||
if (input_->checkAction(Input::Action::FIRE_LEFT, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else if (player->getEnterNamePositionOverflow()) {
|
||||
player->passShowingName();
|
||||
return;
|
||||
}
|
||||
if (player->getEnterNamePositionOverflow()) {
|
||||
player->setInput(Input::Action::START);
|
||||
player->setPlayingState(Player::State::SHOWING_NAME);
|
||||
playSound("service_menu_select.wav");
|
||||
updateHiScoreName();
|
||||
} else {
|
||||
player->setInput(Input::Action::RIGHT);
|
||||
playSound("service_menu_select.wav");
|
||||
return;
|
||||
}
|
||||
} else if (input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad()) ||
|
||||
player->setInput(Input::Action::RIGHT);
|
||||
playSound("service_menu_select.wav");
|
||||
return;
|
||||
}
|
||||
|
||||
if (input_->checkAction(Input::Action::FIRE_CENTER, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad()) ||
|
||||
input_->checkAction(Input::Action::FIRE_RIGHT, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else {
|
||||
player->setInput(Input::Action::LEFT);
|
||||
playSound("service_menu_back.wav");
|
||||
player->passShowingName();
|
||||
return;
|
||||
}
|
||||
} else if (input_->checkAction(Input::Action::UP, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setInput(Input::Action::LEFT);
|
||||
playSound("service_menu_back.wav");
|
||||
return;
|
||||
}
|
||||
|
||||
if (input_->checkAction(Input::Action::UP, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setInput(Input::Action::UP);
|
||||
playSound("service_menu_move.wav");
|
||||
} else if (input_->checkAction(Input::Action::DOWN, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (input_->checkAction(Input::Action::DOWN, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
player->setInput(Input::Action::DOWN);
|
||||
playSound("service_menu_move.wav");
|
||||
} else if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (input_->checkAction(Input::Action::START, Input::DO_NOT_ALLOW_REPEAT, player->getUsesKeyboard(), player->getGamepad())) {
|
||||
if (player->isShowingName()) {
|
||||
player->setPlayingState(Player::State::CONTINUE);
|
||||
} else {
|
||||
player->setInput(Input::Action::START);
|
||||
player->setPlayingState(Player::State::SHOWING_NAME);
|
||||
playSound("service_menu_select.wav");
|
||||
updateHiScoreName();
|
||||
player->passShowingName();
|
||||
return;
|
||||
}
|
||||
player->setInput(Input::Action::START);
|
||||
player->setPlayingState(Player::State::SHOWING_NAME);
|
||||
playSound("service_menu_select.wav");
|
||||
updateHiScoreName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1558,60 +1583,51 @@ void Game::initDifficultyVars() {
|
||||
// Inicializa los jugadores
|
||||
void Game::initPlayers(Player::Id player_id) {
|
||||
const int Y = param.game.play_area.rect.h - Player::HEIGHT + 1; // Se hunde un pixel para esconder el outline de los pies
|
||||
const Player::State STATE = demo_.enabled ? Player::State::PLAYING : Player::State::ENTERING_SCREEN;
|
||||
|
||||
// Crea al jugador uno y lo pone en modo espera
|
||||
Player::Config config_player1;
|
||||
config_player1.id = Player::Id::PLAYER1;
|
||||
config_player1.x = param.game.play_area.first_quarter_x - (Player::WIDTH / 2);
|
||||
config_player1.y = Y;
|
||||
config_player1.demo = demo_.enabled;
|
||||
config_player1.play_area = ¶m.game.play_area.rect;
|
||||
config_player1.texture = player_textures_.at(0);
|
||||
config_player1.animations = player_animations_;
|
||||
config_player1.hi_score_table = &Options::settings.hi_score_table;
|
||||
config_player1.glowing_entry = &Options::settings.glowing_entries.at(static_cast<int>(Player::Id::PLAYER1) - 1);
|
||||
config_player1.stage_info = stage_manager_.get();
|
||||
Player::Config config_player1{
|
||||
.id = Player::Id::PLAYER1,
|
||||
.x = param.game.play_area.first_quarter_x - (Player::WIDTH / 2),
|
||||
.y = Y,
|
||||
.demo = demo_.enabled,
|
||||
.play_area = ¶m.game.play_area.rect,
|
||||
.texture = player_textures_.at(0),
|
||||
.animations = player_animations_,
|
||||
.hi_score_table = &Options::settings.hi_score_table,
|
||||
.glowing_entry = &Options::settings.glowing_entries.at(static_cast<int>(Player::Id::PLAYER1) - 1),
|
||||
.stage_info = stage_manager_.get()};
|
||||
|
||||
auto player1 = std::make_unique<Player>(config_player1);
|
||||
player1->setScoreBoardPanel(Scoreboard::Id::LEFT);
|
||||
player1->setName(Lang::getText("[SCOREBOARD] 1"));
|
||||
player1->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).instance);
|
||||
player1->setUsesKeyboard(Player::Id::PLAYER1 == Options::keyboard.player_id);
|
||||
player1->setPlayingState(Player::State::WAITING);
|
||||
players_.push_back(std::move(player1));
|
||||
player1->setPlayingState((player_id == Player::Id::BOTH_PLAYERS || player_id == Player::Id::PLAYER1) ? STATE : Player::State::WAITING);
|
||||
|
||||
// Crea al jugador dos y lo pone en modo espera
|
||||
Player::Config config_player2;
|
||||
config_player2.id = Player::Id::PLAYER2;
|
||||
config_player2.x = param.game.play_area.third_quarter_x - (Player::WIDTH / 2);
|
||||
config_player2.y = Y;
|
||||
config_player2.demo = demo_.enabled;
|
||||
config_player2.play_area = ¶m.game.play_area.rect;
|
||||
config_player2.texture = player_textures_.at(1);
|
||||
config_player2.animations = player_animations_;
|
||||
config_player2.hi_score_table = &Options::settings.hi_score_table;
|
||||
config_player2.glowing_entry = &Options::settings.glowing_entries.at(static_cast<int>(Player::Id::PLAYER2) - 1);
|
||||
config_player2.stage_info = stage_manager_.get();
|
||||
Player::Config config_player2{
|
||||
.id = Player::Id::PLAYER2,
|
||||
.x = param.game.play_area.third_quarter_x - (Player::WIDTH / 2),
|
||||
.y = Y,
|
||||
.demo = demo_.enabled,
|
||||
.play_area = ¶m.game.play_area.rect,
|
||||
.texture = player_textures_.at(1),
|
||||
.animations = player_animations_,
|
||||
.hi_score_table = &Options::settings.hi_score_table,
|
||||
.glowing_entry = &Options::settings.glowing_entries.at(static_cast<int>(Player::Id::PLAYER2) - 1),
|
||||
.stage_info = stage_manager_.get()};
|
||||
|
||||
auto player2 = std::make_unique<Player>(config_player2);
|
||||
player2->setScoreBoardPanel(Scoreboard::Id::RIGHT);
|
||||
player2->setName(Lang::getText("[SCOREBOARD] 2"));
|
||||
player2->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).instance);
|
||||
player2->setUsesKeyboard(Player::Id::PLAYER2 == Options::keyboard.player_id);
|
||||
player2->setPlayingState(Player::State::WAITING);
|
||||
players_.push_back(std::move(player2));
|
||||
player2->setPlayingState((player_id == Player::Id::BOTH_PLAYERS || player_id == Player::Id::PLAYER2) ? STATE : Player::State::WAITING);
|
||||
|
||||
// Activa el jugador que coincide con el "player_id" o ambos si es "0"
|
||||
if (player_id == Player::Id::BOTH_PLAYERS) {
|
||||
// Activa ambos jugadores
|
||||
getPlayer(Player::Id::PLAYER1)->setPlayingState(demo_.enabled ? Player::State::PLAYING : Player::State::ENTERING_SCREEN);
|
||||
getPlayer(Player::Id::PLAYER2)->setPlayingState(demo_.enabled ? Player::State::PLAYING : Player::State::ENTERING_SCREEN);
|
||||
} else {
|
||||
// Activa el jugador elegido
|
||||
auto player = getPlayer(player_id);
|
||||
player->setPlayingState(demo_.enabled ? Player::State::PLAYING : Player::State::ENTERING_SCREEN);
|
||||
sendPlayerToTheFront(player);
|
||||
}
|
||||
// Añade los jugadores al vector de forma que el jugador 1 se pinte por delante del jugador 2
|
||||
players_.push_back(std::move(player2));
|
||||
players_.push_back(std::move(player1));
|
||||
|
||||
// Registra los jugadores en Options
|
||||
for (const auto &player : players_) {
|
||||
|
||||
Reference in New Issue
Block a user