Ja no se que he tocat i qué no, cosetes del malo nou

This commit is contained in:
2025-01-25 18:47:06 +01:00
parent d3183237df
commit f39e65afaf
3 changed files with 17 additions and 10 deletions

View File

@@ -102,6 +102,8 @@ void Tabe::enable()
{
enabled_ = true;
has_bonus_ = true;
hit_counter_ = 0;
number_of_hits_ = 0;
y_ = param.game.game_area.rect.y + 20.0f;
// Establece una dirección aleatoria
@@ -164,7 +166,8 @@ void Tabe::setState(TabeState state)
case TabeState::HIT:
sprite_->setCurrentAnimation("hit");
hit_counter = 5;
hit_counter_ = 5;
++number_of_hits_;
break;
default:
@@ -178,8 +181,8 @@ void Tabe::updateState()
{
if (state_ == TabeState::HIT)
{
--hit_counter;
if (hit_counter == 0)
--hit_counter_;
if (hit_counter_ == 0)
{
setState(TabeState::FLY);
}
@@ -189,7 +192,7 @@ void Tabe::updateState()
// Intenta obtener el bonus
bool Tabe::tryToGetBonus()
{
if (has_bonus_ && rand() % 8 == 0)
if (has_bonus_ && rand() % std::max(1, 10 - number_of_hits_) == 0)
{
has_bonus_ = false;
return true;