Ja no se que he tocat i qué no, cosetes del malo nou
This commit is contained in:
@@ -774,7 +774,7 @@ void Game::createItemText(int x, std::shared_ptr<Texture> texture)
|
|||||||
const auto h = texture->getHeight();
|
const auto h = texture->getHeight();
|
||||||
|
|
||||||
const int y0 = param.game.play_area.rect.h - h;
|
const int y0 = param.game.play_area.rect.h - h;
|
||||||
const int y1 = 155;
|
const int y1 = 160 - (h / 2);
|
||||||
const int y2 = -h;
|
const int y2 = -h;
|
||||||
|
|
||||||
// Ajusta para que no se dibuje fuera de pantalla
|
// Ajusta para que no se dibuje fuera de pantalla
|
||||||
@@ -1262,10 +1262,10 @@ void Game::checkEvents()
|
|||||||
createItem(ItemType::CLOCK, players_.at(0)->getPosX(), players_.at(0)->getPosY() - 40);
|
createItem(ItemType::CLOCK, players_.at(0)->getPosX(), players_.at(0)->getPosY() - 40);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDLK_5: // Crea un PathSprite
|
case SDLK_5: // 5.000
|
||||||
{
|
{
|
||||||
const int x = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
const int x = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(3));
|
createItemText(x, game_text_textures_.at(2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDLK_6: // Crea un mensaje
|
case SDLK_6: // Crea un mensaje
|
||||||
@@ -1273,10 +1273,13 @@ void Game::checkEvents()
|
|||||||
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
|
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDLK_7: // Flash
|
case SDLK_7: // 100.000
|
||||||
{
|
{
|
||||||
// screen_->flash(flash_color, 3);
|
// screen_->flash(flash_color, 3);
|
||||||
tabe_->setState(TabeState::HIT);
|
// tabe_->setState(TabeState::HIT);
|
||||||
|
const int x = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
||||||
|
createItemText(x, game_text_textures_.at(6));
|
||||||
|
break;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDLK_8:
|
case SDLK_8:
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ void Tabe::enable()
|
|||||||
{
|
{
|
||||||
enabled_ = true;
|
enabled_ = true;
|
||||||
has_bonus_ = true;
|
has_bonus_ = true;
|
||||||
|
hit_counter_ = 0;
|
||||||
|
number_of_hits_ = 0;
|
||||||
y_ = param.game.game_area.rect.y + 20.0f;
|
y_ = param.game.game_area.rect.y + 20.0f;
|
||||||
|
|
||||||
// Establece una dirección aleatoria
|
// Establece una dirección aleatoria
|
||||||
@@ -164,7 +166,8 @@ void Tabe::setState(TabeState state)
|
|||||||
|
|
||||||
case TabeState::HIT:
|
case TabeState::HIT:
|
||||||
sprite_->setCurrentAnimation("hit");
|
sprite_->setCurrentAnimation("hit");
|
||||||
hit_counter = 5;
|
hit_counter_ = 5;
|
||||||
|
++number_of_hits_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -178,8 +181,8 @@ void Tabe::updateState()
|
|||||||
{
|
{
|
||||||
if (state_ == TabeState::HIT)
|
if (state_ == TabeState::HIT)
|
||||||
{
|
{
|
||||||
--hit_counter;
|
--hit_counter_;
|
||||||
if (hit_counter == 0)
|
if (hit_counter_ == 0)
|
||||||
{
|
{
|
||||||
setState(TabeState::FLY);
|
setState(TabeState::FLY);
|
||||||
}
|
}
|
||||||
@@ -189,7 +192,7 @@ void Tabe::updateState()
|
|||||||
// Intenta obtener el bonus
|
// Intenta obtener el bonus
|
||||||
bool Tabe::tryToGetBonus()
|
bool Tabe::tryToGetBonus()
|
||||||
{
|
{
|
||||||
if (has_bonus_ && rand() % 8 == 0)
|
if (has_bonus_ && rand() % std::max(1, 10 - number_of_hits_) == 0)
|
||||||
{
|
{
|
||||||
has_bonus_ = false;
|
has_bonus_ = false;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ private:
|
|||||||
TabeDirection direction_; // Dirección del objeto
|
TabeDirection direction_; // Dirección del objeto
|
||||||
TabeDirection destiny_; // Destino del objeto
|
TabeDirection destiny_; // Destino del objeto
|
||||||
TabeState state_ = TabeState::FLY; // Estado
|
TabeState state_ = TabeState::FLY; // Estado
|
||||||
int hit_counter = 0; // Contador para el estado HIT
|
int hit_counter_ = 0; // Contador para el estado HIT
|
||||||
|
int number_of_hits_ = 0; // Cantidad de disparos que ha recibido
|
||||||
bool has_bonus_ = true; // Indica si el Tabe aun tiene el bonus para soltar
|
bool has_bonus_ = true; // Indica si el Tabe aun tiene el bonus para soltar
|
||||||
|
|
||||||
// Mueve el objeto
|
// Mueve el objeto
|
||||||
|
|||||||
Reference in New Issue
Block a user