magic numbers: game.cpp

This commit is contained in:
2025-09-17 14:20:13 +02:00
parent ae30c9b34f
commit cb7b290818
3 changed files with 138 additions and 108 deletions

View File

@@ -150,7 +150,7 @@ class Player {
[[nodiscard]] auto isTitleHidden() const -> bool { return playing_state_ == State::TITLE_HIDDEN; }
// Getters
[[nodiscard]] auto canFire() const -> bool { return cant_fire_counter_ <= 0; }
[[nodiscard]] auto canFire() const -> bool { return cant_fire_time_accumulator_ <= 0; }
[[nodiscard]] auto hasExtraHit() const -> bool { return extra_hit_; }
[[nodiscard]] auto isCooling() const -> bool { return firing_state_ == State::COOLING_LEFT || firing_state_ == State::COOLING_UP || firing_state_ == State::COOLING_RIGHT; }
[[nodiscard]] auto isRecoiling() const -> bool { return firing_state_ == State::RECOILING_LEFT || firing_state_ == State::RECOILING_UP || firing_state_ == State::RECOILING_RIGHT; }
@@ -180,7 +180,10 @@ class Player {
// Setters inline
void setController(int index) { controller_index_ = index; }
void setCantFireCounter(int counter) { recoiling_state_duration_ = cant_fire_counter_ = counter; }
void setCantFireCounter(int counter) {
recoiling_state_duration_ = cant_fire_counter_ = counter;
cant_fire_time_accumulator_ = static_cast<float>(counter) / 60.0f * 1000.0f; // Convert frames to milliseconds
}
void setFiringState(State state) { firing_state_ = state; }
void setInvulnerableCounter(int value) { invulnerable_counter_ = value; }
void setName(const std::string &name) { name_ = name; }