game fix: la velocitat dels globos dins de la fase actual muntava al primer globo explotat
game fix: al trencar una powerball ja no eixien mes globos style: renombrades variables i funcions
This commit is contained in:
@@ -626,13 +626,12 @@ void Game::handleItemDrop(std::shared_ptr<Balloon> balloon, std::shared_ptr<Play
|
||||
|
||||
// Maneja la destrucción del globo y puntuación
|
||||
void Game::handleBalloonDestruction(std::shared_ptr<Balloon> balloon, std::shared_ptr<Player> player) {
|
||||
evaluateAndSetMenace();
|
||||
|
||||
if (player->isPlaying()) {
|
||||
auto const SCORE = balloon_manager_->popBalloon(balloon) * player->getScoreMultiplier() * difficulty_score_multiplier_;
|
||||
player->addScore(SCORE, Options::settings.hi_score_table.back().score);
|
||||
player->incScoreMultiplier();
|
||||
}
|
||||
setMenace();
|
||||
updateHiScore();
|
||||
}
|
||||
|
||||
@@ -1022,7 +1021,7 @@ void Game::run() {
|
||||
checkInput();
|
||||
#endif
|
||||
update();
|
||||
checkEvents(); // Tiene que ir antes del render
|
||||
handleEvents(); // Tiene que ir antes del render
|
||||
render();
|
||||
}
|
||||
}
|
||||
@@ -1083,7 +1082,7 @@ void Game::initPaths() {
|
||||
// Actualiza las variables de ayuda
|
||||
void Game::updateHelper() {
|
||||
// Solo ofrece ayuda cuando la amenaza es elevada
|
||||
if (menace_current_ > 15) {
|
||||
if (menace_ > 15) {
|
||||
helper_.need_coffee = true;
|
||||
helper_.need_coffee_machine = true;
|
||||
for (const auto &player : players_) {
|
||||
@@ -1128,7 +1127,7 @@ auto Game::allPlayersAreNotPlaying() -> bool {
|
||||
}
|
||||
|
||||
// Comprueba los eventos que hay en cola
|
||||
void Game::checkEvents() {
|
||||
void Game::handleEvents() {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
@@ -1145,9 +1144,9 @@ void Game::checkEvents() {
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
checkDebugEvents(event);
|
||||
handleDebugEvents(event);
|
||||
#endif
|
||||
GlobalEvents::check(event);
|
||||
GlobalEvents::handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1705,7 +1704,7 @@ void Game::updateGameStateFadeIn() {
|
||||
if (fade_in_->hasEnded()) {
|
||||
setState(State::ENTERING_PLAYER);
|
||||
balloon_manager_->createTwoBigBalloons();
|
||||
evaluateAndSetMenace();
|
||||
setMenace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1791,15 +1790,16 @@ void Game::updateMenace() {
|
||||
// Aumenta el nivel de amenaza en función del progreso de la fase
|
||||
menace_threshold_ = stage.getMinMenace() + (difference * fraction);
|
||||
|
||||
if (menace_current_ < menace_threshold_) {
|
||||
if (menace_ < menace_threshold_) {
|
||||
balloon_manager_->deployRandomFormation(stage_manager_->getCurrentStageIndex());
|
||||
evaluateAndSetMenace();
|
||||
setMenace();
|
||||
}
|
||||
std::cout << "MT: " << menace_threshold_ << " | MC: " << menace_ << std::endl;
|
||||
}
|
||||
|
||||
// Calcula y establece el valor de amenaza en funcion de los globos activos
|
||||
void Game::evaluateAndSetMenace() {
|
||||
menace_current_ = balloon_manager_->getMenace();
|
||||
void Game::setMenace() {
|
||||
menace_ = balloon_manager_->getMenace();
|
||||
}
|
||||
|
||||
// Actualiza la velocidad de los globos en funcion del poder acumulado de la fase
|
||||
@@ -1808,8 +1808,7 @@ void Game::checkAndUpdateBalloonSpeed() {
|
||||
return;
|
||||
}
|
||||
|
||||
// const float PERCENT = static_cast<float>(Stage::power) / Stage::get(Stage::number).power_to_complete;
|
||||
const float PERCENT = stage_manager_->getCurrentStageProgressPercentage();
|
||||
const float PERCENT = stage_manager_->getCurrentStageProgressFraction();
|
||||
constexpr std::array<float, 4> THRESHOLDS = {0.2F, 0.4F, 0.6F, 0.8F};
|
||||
|
||||
for (size_t i = 0; i < std::size(THRESHOLDS); ++i) {
|
||||
@@ -1883,13 +1882,13 @@ void Game::onPauseStateChanged(bool is_paused) {
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Comprueba los eventos en el modo DEBUG
|
||||
void Game::checkDebugEvents(const SDL_Event &event) {
|
||||
void Game::handleDebugEvents(const SDL_Event &event) {
|
||||
static int formation_id_ = 0;
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
|
||||
switch (event.key.key) {
|
||||
case SDLK_1: // Crea una powerball
|
||||
{
|
||||
// balloon_manager_->createPowerBall();
|
||||
balloon_manager_->createPowerBall();
|
||||
// throwCoffee(players_.at(0)->getPosX() + (players_.at(0)->getWidth() / 2), players_.at(0)->getPosY() + (players_.at(0)->getHeight() / 2));
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user