Compare commits
12 Commits
2025-01-05
...
bad0a10328
| Author | SHA1 | Date | |
|---|---|---|---|
| bad0a10328 | |||
| 52a0c2b91f | |||
| f12a456017 | |||
| f39e65afaf | |||
| d3183237df | |||
| 60302004f4 | |||
| e60938cb19 | |||
| 2b3cc719ba | |||
| d01c91ebde | |||
| 7130f2298a | |||
| 380cc17861 | |||
| a5388873e3 |
@@ -11,7 +11,7 @@ Coffee Crisis Arcade Edition és una versió ampliada i millorada del aclamat Co
|
||||
Defensa el teu cafè contra les bambolles gegants en aquest trepidant joc d'arcade! 🍵
|
||||
|
||||
<p align="center">
|
||||
<img src="https://php.sustancia.synology.me/images/ccae_title.png" alt="Títol" />
|
||||
<img src="https://php.sustancia.synology.me/images/ccae_title.png" alt="Títol" width="60%" />
|
||||
</p>
|
||||
|
||||
## Controls
|
||||
@@ -25,7 +25,8 @@ El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels
|
||||
> Nota: El joc suporta nomes un jugador amb teclat.
|
||||
|
||||
<p align="center">
|
||||
<img src="https://php.sustancia.synology.me/images/ccae1.png" alt="Joc" />
|
||||
<img src="https://php.sustancia.synology.me/images/ccae1.png" alt="Joc" width="45%" />
|
||||
<img src="https://php.sustancia.synology.me/images/ccae3.png" alt="Joc" width="45%" />
|
||||
</p>
|
||||
|
||||
## Altres tecles
|
||||
@@ -43,7 +44,7 @@ El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels
|
||||
| **F10** | Reset del joc |
|
||||
|
||||
<p align="center">
|
||||
<img src="https://php.sustancia.synology.me/images/ccae2.png" alt="Joc" />
|
||||
<img src="https://php.sustancia.synology.me/images/ccae2.png" alt="Joc" width="50%" />
|
||||
</p>
|
||||
|
||||
## Com instal·lar i jugar
|
||||
|
||||
9
data/gfx/item/item_debian.ani
Normal file
9
data/gfx/item/item_debian.ani
Normal file
@@ -0,0 +1,9 @@
|
||||
frame_width=20
|
||||
frame_height=20
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
speed=10
|
||||
loop=0
|
||||
frames=0,1
|
||||
[/animation]
|
||||
BIN
data/gfx/item/item_debian.png
Normal file
BIN
data/gfx/item/item_debian.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 565 B |
@@ -2,8 +2,15 @@ frame_width=32
|
||||
frame_height=32
|
||||
|
||||
[animation]
|
||||
name=default
|
||||
name=fly
|
||||
speed=2
|
||||
loop=0
|
||||
frames=0,1
|
||||
[/animation]
|
||||
|
||||
[animation]
|
||||
name=hit
|
||||
speed=2
|
||||
loop=0
|
||||
frames=2,3
|
||||
[/animation]
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.6 KiB |
BIN
data/sound/debian_drop.wav
Normal file
BIN
data/sound/debian_drop.wav
Normal file
Binary file not shown.
BIN
data/sound/debian_pickup.wav
Normal file
BIN
data/sound/debian_pickup.wav
Normal file
Binary file not shown.
BIN
data/sound/tabe_hit.wav
Normal file
BIN
data/sound/tabe_hit.wav
Normal file
Binary file not shown.
Binary file not shown.
@@ -321,7 +321,7 @@ int BalloonManager::destroyAllBalloons()
|
||||
}
|
||||
|
||||
balloon_deploy_counter_ = 300;
|
||||
JA_PlaySound(Resource::get()->getSound("powerball.wav"));
|
||||
JA_PlaySound(Resource::get()->getSound("power_ball_explosion.wav"));
|
||||
Screen::get()->flash(flash_color, 3);
|
||||
Screen::get()->shake();
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ Director::Director(int argc, const char *argv[])
|
||||
section::name = section::Name::GAME;
|
||||
section::options = section::Options::GAME_PLAY_1P;
|
||||
#elif DEBUG
|
||||
section::name = section::Name::LOGO;
|
||||
section::name = section::Name::HI_SCORE_TABLE;
|
||||
#else // NORMAL GAME
|
||||
section::name = section::Name::LOGO;
|
||||
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||
@@ -126,6 +126,10 @@ void Director::close()
|
||||
SDL_DestroyWindow(window_);
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
#ifdef ARCADE
|
||||
shutdownSystem(section::options == section::Options::QUIT_WITH_CONTROLLER);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Carga los parametros
|
||||
@@ -393,16 +397,16 @@ void Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/sound/bubble4.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/bullet.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/clock.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/coffeeout.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/coffee_out.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/continue_clock.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/game_start.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/hiscore.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/itemdrop.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/itempickup.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/hi_score_achieved.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/item_drop.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/item_pickup.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/logo.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/notify.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/player_collision.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/powerball.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/power_ball_explosion.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/stage_change.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/tabe.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/title.wav", AssetType::SOUND);
|
||||
@@ -411,6 +415,9 @@ void Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/sound/voice_no.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/voice_power_up.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/walk.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/debian_drop.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/debian_pickup.wav", AssetType::SOUND);
|
||||
Asset::get()->add(prefix + "/data/sound/tabe_hit.wav", AssetType::SOUND);
|
||||
|
||||
// Shaders
|
||||
Asset::get()->add(prefix + "/data/shaders/crtpi_256.glsl", AssetType::DATA);
|
||||
@@ -490,6 +497,8 @@ void Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION);
|
||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION);
|
||||
Asset::get()->add(prefix + "/data/gfx/item/item_debian.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION);
|
||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
|
||||
}
|
||||
@@ -762,11 +771,6 @@ int Director::run()
|
||||
// Habilita de nuevo los std::cout
|
||||
std::cout.rdbuf(orig_buf);
|
||||
#endif
|
||||
#ifdef ARCADE
|
||||
// Comprueba si ha de apagar el sistema
|
||||
if (section::options == section::Options::QUIT_WITH_CONTROLLER)
|
||||
shutdownSystem();
|
||||
#endif
|
||||
|
||||
return (section::options == section::Options::QUIT_WITH_CONTROLLER) ? 1 : 0;
|
||||
}
|
||||
@@ -794,20 +798,23 @@ std::string Director::getLangFile(lang::Code code)
|
||||
|
||||
#ifdef ARCADE
|
||||
// Apaga el sistema
|
||||
void Director::shutdownSystem()
|
||||
void Director::shutdownSystem(bool shouldShutdown)
|
||||
{
|
||||
if (shouldShutdown)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Apaga el sistema en Windows
|
||||
system("shutdown /s /t 0");
|
||||
// Apaga el sistema en Windows
|
||||
system("shutdown /s /t 5");
|
||||
#elif __APPLE__
|
||||
// Apaga el sistema en macOS
|
||||
system("sudo shutdown -h now");
|
||||
// Apaga el sistema en macOS
|
||||
system("sudo shutdown -h +0.1");
|
||||
#elif __linux__
|
||||
// Apaga el sistema en Linux
|
||||
system("shutdown -h now");
|
||||
// Apaga el sistema en Linux
|
||||
system("sleep 5; shutdown -h now");
|
||||
#else
|
||||
// Sistema operativo no compatible
|
||||
#error "Sistema operativo no soportado"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // ARCADE
|
||||
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
std::string getLangFile(lang::Code code);
|
||||
#ifdef ARCADE
|
||||
// Apaga el sistema
|
||||
void shutdownSystem();
|
||||
void shutdownSystem(bool shouldShutdown);
|
||||
#endif
|
||||
|
||||
// Inicializa todo
|
||||
|
||||
129
source/game.cpp
129
source/game.cpp
@@ -140,6 +140,7 @@ void Game::setResources()
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_powerup"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_one_hit"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_stop"));
|
||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_100000_points"));
|
||||
}
|
||||
|
||||
// Texturas - Items
|
||||
@@ -149,6 +150,7 @@ void Game::setResources()
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_points3_pacmar.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_clock.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_debian.png"));
|
||||
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee_machine.png"));
|
||||
}
|
||||
|
||||
@@ -181,6 +183,7 @@ void Game::setResources()
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_points3_pacmar.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_clock.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_debian.ani"));
|
||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee_machine.ani"));
|
||||
}
|
||||
}
|
||||
@@ -202,7 +205,7 @@ void Game::updateHiScore()
|
||||
if (hi_score_achieved_ == false)
|
||||
{
|
||||
hi_score_achieved_ = true;
|
||||
JA_PlaySound(Resource::get()->getSound("hiscore.wav"));
|
||||
JA_PlaySound(Resource::get()->getSound("hi_score_achieved.wav"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,7 +300,7 @@ void Game::updateGameStateGameOver()
|
||||
updateSmartSprites();
|
||||
updatePathSprites();
|
||||
updateTimeStopped();
|
||||
checkBulletBalloonCollision();
|
||||
checkBulletCollision();
|
||||
cleanVectors();
|
||||
|
||||
if (game_over_counter_ > 0)
|
||||
@@ -462,37 +465,41 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
case ItemType::DISK:
|
||||
{
|
||||
player->addScore(1000);
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[0]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[0]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(0));
|
||||
JA_PlaySound(Resource::get()->getSound("item_pickup.wav"));
|
||||
break;
|
||||
}
|
||||
case ItemType::GAVINA:
|
||||
{
|
||||
player->addScore(2500);
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[1]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[1]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(1));
|
||||
JA_PlaySound(Resource::get()->getSound("item_pickup.wav"));
|
||||
break;
|
||||
}
|
||||
case ItemType::PACMAR:
|
||||
{
|
||||
player->addScore(5000);
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[2]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[2]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(2));
|
||||
JA_PlaySound(Resource::get()->getSound("item_pickup.wav"));
|
||||
break;
|
||||
}
|
||||
case ItemType::DEBIAN:
|
||||
{
|
||||
player->addScore(100000);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(6));
|
||||
JA_PlaySound(Resource::get()->getSound("debian_pickup.wav"));
|
||||
break;
|
||||
}
|
||||
case ItemType::CLOCK:
|
||||
{
|
||||
enableTimeStopItem();
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[5]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[5]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(5));
|
||||
JA_PlaySound(Resource::get()->getSound("item_pickup.wav"));
|
||||
break;
|
||||
}
|
||||
case ItemType::COFFEE:
|
||||
@@ -500,18 +507,14 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
if (player->getCoffees() == 2)
|
||||
{
|
||||
player->addScore(5000);
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[2]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[2]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
player->giveExtraHit();
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[4]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[4]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(4));
|
||||
}
|
||||
JA_PlaySound(Resource::get()->getSound("voice_coffee.wav"));
|
||||
break;
|
||||
@@ -520,10 +523,8 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
{
|
||||
player->setPowerUp();
|
||||
coffee_machine_enabled_ = false;
|
||||
const auto x =
|
||||
item->getPosX() +
|
||||
(item->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_[3]);
|
||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
|
||||
createItemText(x, game_text_textures_.at(3));
|
||||
JA_PlaySound(Resource::get()->getSound("voice_power_up.wav"));
|
||||
break;
|
||||
}
|
||||
@@ -532,18 +533,46 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
}
|
||||
|
||||
updateHiScore();
|
||||
JA_PlaySound(Resource::get()->getSound("itempickup.wav"));
|
||||
item->disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba y procesa la colisión entre las balas y los globos
|
||||
void Game::checkBulletBalloonCollision()
|
||||
// Comprueba y procesa la colisión de las balas
|
||||
void Game::checkBulletCollision()
|
||||
{
|
||||
for (auto &bullet : bullets_)
|
||||
{
|
||||
// Comprueba la colisión con el Tabe
|
||||
if (bullet->isEnabled() && tabe_->isEnabled())
|
||||
if (checkCollision(bullet->getCollider(), tabe_->getCollider()))
|
||||
{
|
||||
tabe_->setState(TabeState::HIT);
|
||||
bullet->disable();
|
||||
auto pos = tabe_->getCollider();
|
||||
if (tabe_->tryToGetBonus())
|
||||
{
|
||||
createItem(ItemType::DEBIAN, pos.x, pos.y);
|
||||
JA_PlaySound(Resource::get()->getSound("debian_drop.wav"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rand() % 3 == 0)
|
||||
{
|
||||
createItem(ItemType::COFFEE, pos.x, pos.y);
|
||||
// JA_PlaySound(Resource::get()->getSound("item_drop.wav"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// JA_PlaySound(Resource::get()->getSound("tabe_hit.wav"));
|
||||
}
|
||||
JA_PlaySound(Resource::get()->getSound("tabe_hit.wav"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Comprueba la colisión con los globos
|
||||
for (auto &balloon : balloon_manager_->getBalloons())
|
||||
{
|
||||
if (balloon->isEnabled() && (!balloon->isInvulnerable()) && bullet->isEnabled())
|
||||
@@ -560,7 +589,7 @@ void Game::checkBulletBalloonCollision()
|
||||
if (dropped_item != ItemType::COFFEE_MACHINE)
|
||||
{
|
||||
createItem(dropped_item, balloon->getPosX(), balloon->getPosY());
|
||||
JA_PlaySound(Resource::get()->getSound("itemdrop.wav"));
|
||||
JA_PlaySound(Resource::get()->getSound("item_drop.wav"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -745,7 +774,7 @@ void Game::createItemText(int x, std::shared_ptr<Texture> texture)
|
||||
const auto h = texture->getHeight();
|
||||
|
||||
const int y0 = param.game.play_area.rect.h - h;
|
||||
const int y1 = 155;
|
||||
const int y1 = 160 - (h / 2);
|
||||
const int y2 = -h;
|
||||
|
||||
// Ajusta para que no se dibuje fuera de pantalla
|
||||
@@ -865,7 +894,7 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
|
||||
// Lo pierde
|
||||
player->removeExtraHit();
|
||||
throwCoffee(player->getPosX() + (player->getWidth() / 2), player->getPosY() + (player->getHeight() / 2));
|
||||
JA_PlaySound(Resource::get()->getSound("coffeeout.wav"));
|
||||
JA_PlaySound(Resource::get()->getSound("coffee_out.wav"));
|
||||
screen_->shake();
|
||||
}
|
||||
else
|
||||
@@ -893,20 +922,28 @@ void Game::updateTimeStopped()
|
||||
if (time_stopped_counter_ > 120)
|
||||
{
|
||||
if (time_stopped_counter_ % 30 == 0)
|
||||
{
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (time_stopped_counter_ % 15 == 0)
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
if (time_stopped_counter_ % 30 == 0)
|
||||
{
|
||||
balloon_manager_->normalColorsToAllBalloons();
|
||||
if (time_stopped_counter_ % 30 == 15)
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
}
|
||||
else if (time_stopped_counter_ % 30 == 15)
|
||||
{
|
||||
balloon_manager_->reverseColorsToAllBalloons();
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
disableTimeStopItem();
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el juego
|
||||
@@ -1233,10 +1270,10 @@ void Game::checkEvents()
|
||||
createItem(ItemType::CLOCK, players_.at(0)->getPosX(), players_.at(0)->getPosY() - 40);
|
||||
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;
|
||||
createItemText(x, game_text_textures_.at(3));
|
||||
createItemText(x, game_text_textures_.at(2));
|
||||
break;
|
||||
}
|
||||
case SDLK_6: // Crea un mensaje
|
||||
@@ -1244,9 +1281,13 @@ void Game::checkEvents()
|
||||
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
|
||||
break;
|
||||
}
|
||||
case SDLK_7: // Flash
|
||||
case SDLK_7: // 100.000
|
||||
{
|
||||
screen_->flash(flash_color, 3);
|
||||
// screen_->flash(flash_color, 3);
|
||||
// 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;
|
||||
}
|
||||
case SDLK_8:
|
||||
@@ -1941,7 +1982,7 @@ void Game::updateGameStatePlaying()
|
||||
updatePathSprites();
|
||||
updateTimeStopped();
|
||||
updateHelper();
|
||||
checkBulletBalloonCollision();
|
||||
checkBulletCollision();
|
||||
updateMenace();
|
||||
checkAndUpdateBalloonSpeed();
|
||||
checkState();
|
||||
|
||||
@@ -211,8 +211,8 @@ private:
|
||||
// Comprueba la colisión entre el jugador y los items
|
||||
void checkPlayerItemCollision(std::shared_ptr<Player> &player);
|
||||
|
||||
// Comprueba la colisión entre las balas y los globos
|
||||
void checkBulletBalloonCollision();
|
||||
// Comprueba y procesa la colisión de las balas
|
||||
void checkBulletCollision();
|
||||
|
||||
// Mueve las balas activas
|
||||
void updateBullets();
|
||||
|
||||
@@ -51,8 +51,8 @@ HiScoreTable::HiScoreTable()
|
||||
fade_->setMode(fade_mode_);
|
||||
fade_->activate();
|
||||
|
||||
// Crea el contenido de la textura con la lista de puntuaciones
|
||||
fillTexture();
|
||||
// Crea los sprites con los textos
|
||||
createSprites();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -77,6 +77,9 @@ void HiScoreTable::update()
|
||||
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
|
||||
}
|
||||
|
||||
// Actualiza las posiciones de los sprites de texto
|
||||
updateSprites();
|
||||
|
||||
// Actualiza el objeto screen
|
||||
Screen::get()->update();
|
||||
|
||||
@@ -102,19 +105,15 @@ void HiScoreTable::update()
|
||||
{
|
||||
fade_->activate();
|
||||
}
|
||||
|
||||
// Dibuja los sprites en la textura
|
||||
fillTexture();
|
||||
}
|
||||
}
|
||||
|
||||
// Crea el contenido de la textura con la lista de puntuaciones
|
||||
// Dibuja los sprites en la textura
|
||||
void HiScoreTable::fillTexture()
|
||||
{
|
||||
// hay 27 letras - 7 de puntos quedan 20 caracteres 20 - name_lenght 0 num_dots
|
||||
constexpr auto max_names = 10;
|
||||
constexpr auto space_between_header = 32;
|
||||
const auto space_between_lines = text_->getCharacterSize() * 2.0f;
|
||||
const auto size = space_between_header + space_between_lines * (max_names - 1) + text_->getCharacterSize();
|
||||
const auto first_line = (param.game.height - size) / 2;
|
||||
|
||||
// Pinta en el backbuffer el texto y los sprites
|
||||
auto temp = SDL_GetRenderTarget(renderer_);
|
||||
SDL_SetRenderTarget(renderer_, backbuffer_);
|
||||
@@ -122,22 +121,12 @@ void HiScoreTable::fillTexture()
|
||||
SDL_RenderClear(renderer_);
|
||||
|
||||
// Escribe el texto: Mejores puntuaciones
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, first_line, lang::getText(42), 1, orange_color, 1, shdw_txt_color);
|
||||
header_->render();
|
||||
|
||||
// Escribe los nombres de la tabla de puntuaciones
|
||||
for (int i = 0; i < max_names; ++i)
|
||||
for (auto const &entry : entry_names_)
|
||||
{
|
||||
const auto name_lenght = options.game.hi_score_table[i].name.length();
|
||||
const auto score = format(options.game.hi_score_table[i].score);
|
||||
const auto score_lenght = score.size();
|
||||
const auto num_dots = 25 - name_lenght - score_lenght;
|
||||
std::string dots;
|
||||
for (int j = 0; j < (int)num_dots; ++j)
|
||||
{
|
||||
dots = dots + ".";
|
||||
}
|
||||
const auto line = options.game.hi_score_table[i].name + dots + score;
|
||||
text_->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, (i * space_between_lines) + first_line + space_between_header, line, 1, orange_color, 1, shdw_txt_color);
|
||||
entry->render();
|
||||
}
|
||||
|
||||
// Cambia el destino de renderizado
|
||||
@@ -274,4 +263,104 @@ std::string HiScoreTable::format(int number)
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Crea los sprites con los textos
|
||||
void HiScoreTable::createSprites()
|
||||
{
|
||||
// Obtiene el tamaño de la textura
|
||||
int backbuffer_width;
|
||||
int backbuffer_height;
|
||||
SDL_QueryTexture(backbuffer_, nullptr, nullptr, &backbuffer_width, &backbuffer_height);
|
||||
|
||||
// Hay 27 letras - 7 de puntos quedan 20 caracteres 20 - name_lenght 0 num_dots
|
||||
constexpr int max_names = 10;
|
||||
constexpr int space_between_header = 32;
|
||||
const int space_between_lines = text_->getCharacterSize() * 2;
|
||||
const int size = space_between_header + space_between_lines * (max_names - 1) + text_->getCharacterSize();
|
||||
const int first_line = (param.game.height - size) / 2;
|
||||
|
||||
// Crea el sprite para el texto de cabecera
|
||||
header_ = std::make_unique<Sprite>(text_->writeDXToTexture(TEXT_COLOR | TEXT_SHADOW, lang::getText(42), 1, orange_color, 1, shdw_txt_color));
|
||||
header_->setPosition(param.game.game_area.center_x - (header_->getWidth() / 2), first_line);
|
||||
|
||||
// Crea los sprites para las entradas en la tabla de puntuaciones
|
||||
for (int i = 0; i < max_names; ++i)
|
||||
{
|
||||
const auto name_lenght = options.game.hi_score_table.at(i).name.length();
|
||||
const auto score = format(options.game.hi_score_table.at(i).score);
|
||||
const auto score_lenght = score.size();
|
||||
const auto num_dots = 25 - name_lenght - score_lenght;
|
||||
std::string dots;
|
||||
for (int j = 0; j < (int)num_dots; ++j)
|
||||
{
|
||||
dots = dots + ".";
|
||||
}
|
||||
const auto line = options.game.hi_score_table.at(i).name + dots + score;
|
||||
|
||||
entry_names_.emplace_back(std::make_shared<PathSprite>(text_->writeDXToTexture(TEXT_SHADOW, line, 1, orange_color, 1, shdw_txt_color)));
|
||||
if (false)
|
||||
{
|
||||
if (i % 1 == 0)
|
||||
{
|
||||
entry_names_.back()->addPath(
|
||||
-entry_names_.back()->getWidth(),
|
||||
(backbuffer_width - entry_names_.back()->getWidth()) / 2,
|
||||
PathType::HORIZONTAL,
|
||||
(i * space_between_lines) + first_line + space_between_header,
|
||||
80,
|
||||
easeOutQuint,
|
||||
0);
|
||||
entry_names_.back()->setPosition(-entry_names_.back()->getWidth(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
entry_names_.back()->addPath(
|
||||
backbuffer_width,
|
||||
(backbuffer_width - entry_names_.back()->getWidth()) / 2,
|
||||
PathType::HORIZONTAL,
|
||||
(i * space_between_lines) + first_line + space_between_header,
|
||||
80,
|
||||
easeOutQuint,
|
||||
0);
|
||||
entry_names_.back()->setPosition(backbuffer_width, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
entry_names_.back()->addPath(
|
||||
backbuffer_height,
|
||||
(i * space_between_lines) + first_line + space_between_header,
|
||||
PathType::VERTICAL,
|
||||
(backbuffer_width - entry_names_.back()->getWidth()) / 2,
|
||||
80,
|
||||
easeOutQuint,
|
||||
0);
|
||||
entry_names_.back()->setPosition(0, backbuffer_height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las posiciones de los sprites de texto
|
||||
void HiScoreTable::updateSprites()
|
||||
{
|
||||
constexpr int init_counter = 220;
|
||||
const int counter_between_entries = text_->getCharacterSize() * 2;
|
||||
if (counter_ >= init_counter)
|
||||
{
|
||||
const int counter2 = counter_ - init_counter;
|
||||
if (counter2 % counter_between_entries == 0)
|
||||
{
|
||||
int index = counter2 / counter_between_entries;
|
||||
if (index < static_cast<int>(entry_names_.size()))
|
||||
{
|
||||
entry_names_.at(index)->enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto const &entry : entry_names_)
|
||||
{
|
||||
entry->update();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <SDL2/SDL_stdinc.h> // para Uint16, Uint32, Uint8
|
||||
#include <memory> // para unique_ptr
|
||||
#include <string> // para string
|
||||
#include "sprite.h"
|
||||
#include "path_sprite.h"
|
||||
class Background; // lines 8-8
|
||||
class Fade; // lines 9-9
|
||||
class Text; // lines 10-10
|
||||
@@ -31,9 +33,12 @@ private:
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
SDL_Texture *backbuffer_; // Textura para usar como backbuffer
|
||||
|
||||
std::unique_ptr<Fade> fade_; // Objeto para renderizar fades
|
||||
std::unique_ptr<Background> background_; // Objeto para dibujar el fondo del juego
|
||||
std::shared_ptr<Text> text_; // Objeto para escribir texto
|
||||
std::unique_ptr<Fade> fade_; // Objeto para renderizar fades
|
||||
std::unique_ptr<Background> background_; // Objeto para dibujar el fondo del juego
|
||||
std::shared_ptr<Text> text_; // Objeto para escribir texto
|
||||
std::unique_ptr<Sprite> header_; // Sprite con la cabecera del texto
|
||||
std::vector<std::shared_ptr<PathSprite>> entry_names_; // Lista con los spritres de cada uno de los nombres de la tabla de records
|
||||
std::vector<Path> paths_; // Vector con los recorridos precalculados
|
||||
|
||||
// Variables
|
||||
Uint16 counter_; // Contador
|
||||
@@ -56,7 +61,7 @@ private:
|
||||
// Convierte un entero a un string con separadores de miles
|
||||
std::string format(int number);
|
||||
|
||||
// Crea el contenido de la textura con la lista de puntuaciones
|
||||
// Dibuja los sprites en la textura
|
||||
void fillTexture();
|
||||
|
||||
// Recarga todas las texturas
|
||||
@@ -65,6 +70,12 @@ private:
|
||||
// Gestiona el fade
|
||||
void updateFade();
|
||||
|
||||
// Crea los sprites con los textos
|
||||
void createSprites();
|
||||
|
||||
// Actualiza las posiciones de los sprites de texto
|
||||
void updateSprites();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
HiScoreTable();
|
||||
|
||||
@@ -22,8 +22,9 @@ enum class ItemType : int
|
||||
PACMAR = 3, /**< Pacman */
|
||||
CLOCK = 4, /**< Reloj */
|
||||
COFFEE = 5, /**< Café */
|
||||
COFFEE_MACHINE = 6,/**< Máquina de café */
|
||||
NONE = 7, /**< Ninguno */
|
||||
DEBIAN = 6, /**< Debian */
|
||||
COFFEE_MACHINE = 7,/**< Máquina de café */
|
||||
NONE = 8, /**< Ninguno */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,7 +96,7 @@ void PathSprite::addPath(std::vector<SDL_Point> spots, int waiting_counter)
|
||||
// Habilita el objeto
|
||||
void PathSprite::enable()
|
||||
{
|
||||
if (paths_.size() == 0)
|
||||
if (paths_.size() == 0 || enabled_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -133,9 +133,13 @@ void PathSprite::moveThroughCurrentPath()
|
||||
if (path.on_destination)
|
||||
{
|
||||
if (path.waiting_counter == 0)
|
||||
{
|
||||
path.finished = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
--path.waiting_counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,11 +148,15 @@ void PathSprite::goToNextPathOrDie()
|
||||
{
|
||||
// Comprueba si ha terminado el recorrdo actual
|
||||
if (paths_.at(current_path_).finished)
|
||||
{
|
||||
++current_path_;
|
||||
}
|
||||
|
||||
// Comprueba si quedan mas recorridos
|
||||
if (current_path_ >= static_cast<int>(paths_.size()))
|
||||
{
|
||||
enabled_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Indica si ha terminado todos los recorridos
|
||||
|
||||
@@ -301,6 +301,7 @@ void Resource::createTextures()
|
||||
|
||||
// Tamaño doble
|
||||
std::vector<NameAndText> strings2X = {
|
||||
NameAndText("game_text_100000_points", "100.000"),
|
||||
NameAndText("game_text_get_ready", lang::getText(75)),
|
||||
NameAndText("game_text_last_stage", lang::getText(79)),
|
||||
NameAndText("game_text_congratulations", lang::getText(50)),
|
||||
|
||||
@@ -89,23 +89,26 @@ void Screen::render()
|
||||
// Dibuja efectos y elementos sobre el game_canvas_
|
||||
renderFlash();
|
||||
renderAttenuate();
|
||||
renderShake();
|
||||
OnScreenHelp::get()->render();
|
||||
renderInfo();
|
||||
Notifier::get()->render();
|
||||
|
||||
// Restablece el objetivo de renderizado al buffer de pantalla predeterminado
|
||||
SDL_SetRenderTarget(renderer_, nullptr);
|
||||
|
||||
// Renderiza el contenido del game_canvas_ o aplica shaders según configuración
|
||||
// Renderiza el contenido del game_canvas_
|
||||
renderScreen();
|
||||
}
|
||||
|
||||
// Selecciona y ejecuta el método de renderizado adecuado basado en la configuración de shaders
|
||||
// Renderiza el contenido del game_canvas_
|
||||
void Screen::renderScreen()
|
||||
{
|
||||
// Restablece el objetivo de renderizado al buffer de pantalla predeterminado
|
||||
SDL_SetRenderTarget(renderer_, nullptr);
|
||||
clean();
|
||||
|
||||
#ifdef NO_SHADERS
|
||||
// Actualiza la pantalla con el contenido del game_canvas_
|
||||
presentGameCanvas();
|
||||
// Actualiza la pantalla con el contenido del buffer de renderizado
|
||||
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
|
||||
SDL_RenderPresent(renderer_);
|
||||
#else
|
||||
if (options.video.shaders)
|
||||
{
|
||||
@@ -114,8 +117,9 @@ void Screen::renderScreen()
|
||||
}
|
||||
else
|
||||
{
|
||||
// Actualiza la pantalla con el contenido del game_canvas_
|
||||
presentGameCanvas();
|
||||
// Actualiza la pantalla con el contenido del buffer de renderizado
|
||||
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -311,6 +315,33 @@ void Screen::renderAttenuate()
|
||||
}
|
||||
}
|
||||
|
||||
// Aplica el efecto de agitar la pantalla
|
||||
void Screen::renderShake()
|
||||
{
|
||||
if (shake_effect_.enabled)
|
||||
{
|
||||
// Guarda el renderizador actual para dejarlo despues como estaba
|
||||
auto current_target = SDL_GetRenderTarget(renderer_);
|
||||
|
||||
// Crea una textura temporal
|
||||
auto temp_texture = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height);
|
||||
|
||||
// Vuelca game_canvas_ a la textura temporal
|
||||
SDL_SetRenderTarget(renderer_, temp_texture);
|
||||
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
|
||||
|
||||
// Vuelca textura temporal a game_canvas_
|
||||
SDL_SetRenderTarget(renderer_, game_canvas_);
|
||||
SDL_RenderCopy(renderer_, temp_texture, &src_rect_, &dst_rect_);
|
||||
|
||||
// Elimina la textura temporal
|
||||
SDL_DestroyTexture(temp_texture);
|
||||
|
||||
// Restaura el renderizador de destino original
|
||||
SDL_SetRenderTarget(renderer_, current_target);
|
||||
}
|
||||
}
|
||||
|
||||
// Activa / desactiva los shaders
|
||||
void Screen::toggleShaders()
|
||||
{
|
||||
@@ -404,19 +435,4 @@ SDL_Point Screen::getNewPosition()
|
||||
new_pos.y = std::clamp(new_pos.y, 30, DM.h - new_height);
|
||||
|
||||
return new_pos;
|
||||
}
|
||||
|
||||
// Actualiza la pantalla con el contenido del game_canvas_
|
||||
void Screen::presentGameCanvas()
|
||||
{
|
||||
// Copia la textura de juego en el renderizador en la posición adecuada
|
||||
if (shake_effect_.enabled)
|
||||
{
|
||||
// Esta copia es para evitar que se vea negro por los laterales
|
||||
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
|
||||
}
|
||||
SDL_RenderCopy(renderer_, game_canvas_, &src_rect_, &dst_rect_);
|
||||
|
||||
// Actualiza la pantalla con el contenido del buffer de renderizado
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
@@ -28,9 +28,9 @@ private:
|
||||
static Screen *screen_;
|
||||
|
||||
// Objetos y punteros
|
||||
SDL_Window *window_; // Ventana de la aplicación
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
SDL_Texture *game_canvas_; // Textura donde se dibuja todo antes de volcarse al renderizador
|
||||
SDL_Window *window_; // Ventana de la aplicación
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
SDL_Texture *game_canvas_; // Textura donde se dibuja todo antes de volcarse al renderizador
|
||||
|
||||
// Variables
|
||||
SDL_Rect src_rect_; // Coordenadas de donde va a pillar la textura del juego para dibujarla
|
||||
@@ -98,6 +98,9 @@ private:
|
||||
// Atenua la pantalla
|
||||
void renderAttenuate();
|
||||
|
||||
// Aplica el efecto de agitar la pantalla
|
||||
void renderShake();
|
||||
|
||||
// Calcula los frames por segundo
|
||||
void updateFPS();
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect getPosition() const { return pos_; }
|
||||
SDL_Rect &getRect() { return pos_; }
|
||||
|
||||
// Establece la posición y el tamaño
|
||||
void setX(int x) { pos_.x = x; }
|
||||
|
||||
@@ -18,6 +18,7 @@ void Tabe::update()
|
||||
{
|
||||
sprite_->update();
|
||||
move();
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +101,10 @@ void Tabe::enable()
|
||||
if (!enabled_)
|
||||
{
|
||||
enabled_ = true;
|
||||
y_ = 20.0f;
|
||||
has_bonus_ = true;
|
||||
hit_counter_ = 0;
|
||||
number_of_hits_ = 0;
|
||||
y_ = param.game.game_area.rect.y + 20.0f;
|
||||
|
||||
// Establece una dirección aleatoria
|
||||
destiny_ = direction_ = rand() % 2 == 0 ? TabeDirection::TO_THE_LEFT : TabeDirection::TO_THE_RIGHT;
|
||||
@@ -145,4 +149,53 @@ void Tabe::setRandomFlyPath(TabeDirection direction, int lenght)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el estado
|
||||
void Tabe::setState(TabeState state)
|
||||
{
|
||||
if (enabled_)
|
||||
{
|
||||
state_ = state;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TabeState::FLY:
|
||||
sprite_->setCurrentAnimation("fly");
|
||||
break;
|
||||
|
||||
case TabeState::HIT:
|
||||
sprite_->setCurrentAnimation("hit");
|
||||
hit_counter_ = 5;
|
||||
++number_of_hits_;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el estado
|
||||
void Tabe::updateState()
|
||||
{
|
||||
if (state_ == TabeState::HIT)
|
||||
{
|
||||
--hit_counter_;
|
||||
if (hit_counter_ == 0)
|
||||
{
|
||||
setState(TabeState::FLY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Intenta obtener el bonus
|
||||
bool Tabe::tryToGetBonus()
|
||||
{
|
||||
if (has_bonus_ && rand() % std::max(1, 10 - number_of_hits_) == 0)
|
||||
{
|
||||
has_bonus_ = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,12 @@ enum class TabeDirection : int
|
||||
TO_THE_RIGHT = 1,
|
||||
};
|
||||
|
||||
enum class TabeState : int
|
||||
{
|
||||
FLY = 0,
|
||||
HIT = 1,
|
||||
};
|
||||
|
||||
// Clase Tabe
|
||||
class Tabe
|
||||
{
|
||||
@@ -21,15 +27,19 @@ private:
|
||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los graficos y animaciones
|
||||
|
||||
// Variables
|
||||
float x_ = 0; // Posición del objeto
|
||||
float y_ = 0; // Posición del objeto
|
||||
float speed_ = 0.0f; // Velocidad de movimiento del objeto
|
||||
float accel_ = 0.0f; // Aceleración del objeto
|
||||
int fly_distance_ = 0; // Distancia de vuelo
|
||||
int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto
|
||||
bool enabled_ = false; // Indica si el objeto está activo
|
||||
TabeDirection direction_; // Dirección del objeto
|
||||
TabeDirection destiny_; // Destino del objeto
|
||||
float x_ = 0; // Posición del objeto
|
||||
float y_ = 0; // Posición del objeto
|
||||
float speed_ = 0.0f; // Velocidad de movimiento del objeto
|
||||
float accel_ = 0.0f; // Aceleración del objeto
|
||||
int fly_distance_ = 0; // Distancia de vuelo
|
||||
int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto
|
||||
bool enabled_ = false; // Indica si el objeto está activo
|
||||
TabeDirection direction_; // Dirección del objeto
|
||||
TabeDirection destiny_; // Destino del objeto
|
||||
TabeState state_ = TabeState::FLY; // Estado
|
||||
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
|
||||
|
||||
// Mueve el objeto
|
||||
void move();
|
||||
@@ -40,6 +50,9 @@ private:
|
||||
// Establece un vuelo aleatorio
|
||||
void setRandomFlyPath(TabeDirection direction, int lenght);
|
||||
|
||||
// Actualiza el estado
|
||||
void updateState();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Tabe();
|
||||
@@ -55,4 +68,16 @@ public:
|
||||
|
||||
// Habilita el objeto
|
||||
void enable();
|
||||
|
||||
// Establece el estado
|
||||
void setState(TabeState state);
|
||||
|
||||
// Intenta obtener el bonus
|
||||
bool tryToGetBonus();
|
||||
|
||||
// Obtiene el area de colisión
|
||||
SDL_Rect &getCollider() { return sprite_->getRect(); }
|
||||
|
||||
// Getters
|
||||
bool isEnabled() const { return enabled_; }
|
||||
};
|
||||
@@ -173,6 +173,25 @@ std::shared_ptr<Texture> Text::writeToTexture(const std::string &text, int zoom,
|
||||
return texture;
|
||||
}
|
||||
|
||||
// Escribe el texto con extras en una textura
|
||||
std::shared_ptr<Texture> Text::writeDXToTexture(Uint8 flags, const std::string &text, int kerning, Color textColor, Uint8 shadow_distance, Color shadow_color, int lenght)
|
||||
{
|
||||
auto renderer = Screen::get()->getRenderer();
|
||||
auto texture = std::make_shared<Texture>(renderer);
|
||||
auto width = Text::lenght(text, kerning);
|
||||
auto height = box_height_ + shadow_distance;
|
||||
auto temp = SDL_GetRenderTarget(renderer);
|
||||
texture->createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET);
|
||||
texture->setBlendMode(SDL_BLENDMODE_BLEND);
|
||||
texture->setAsRenderTarget(renderer);
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
|
||||
SDL_RenderClear(renderer);
|
||||
writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght);
|
||||
SDL_SetRenderTarget(renderer, temp);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
// Escribe el texto con colores
|
||||
void Text::writeColored(int x, int y, const std::string &text, Color color, int kerning, int lenght)
|
||||
{
|
||||
@@ -272,7 +291,7 @@ void Text::setFixedWidth(bool value)
|
||||
void Text::setPalette(int number)
|
||||
{
|
||||
auto temp = SDL_GetRenderTarget(Screen::get()->getRenderer());
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
||||
sprite_->getTexture()->setPalette(number);
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);
|
||||
}
|
||||
@@ -55,6 +55,9 @@ public:
|
||||
// Escribe el texto en una textura
|
||||
std::shared_ptr<Texture> writeToTexture(const std::string &text, int zoom = 1, int kerning = 1);
|
||||
|
||||
// Escribe el texto con extras en una textura
|
||||
std::shared_ptr<Texture> writeDXToTexture(Uint8 flags, const std::string &text, int kerning = 1, Color textColor = Color(), Uint8 shadow_distance = 1, Color shadow_color = Color(), int lenght = -1);
|
||||
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, const std::string &text, Color color, int kerning = 1, int lenght = -1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user