El malo nou ja suca cosetes, falta ajustar un poc els paràmetres
This commit is contained in:
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
|
frame_height=32
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=fly
|
||||||
speed=2
|
speed=2
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1
|
frames=0,1
|
||||||
[/animation]
|
[/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 |
@@ -494,6 +494,8 @@ void Director::setFileList()
|
|||||||
Asset::get()->add(prefix + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
|
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_powerup"));
|
||||||
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_one_hit"));
|
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_stop"));
|
||||||
|
game_text_textures_.emplace_back(Resource::get()->getTexture("game_text_100000_points"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texturas - Items
|
// 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_points3_pacmar.png"));
|
||||||
item_textures_.emplace_back(Resource::get()->getTexture("item_clock.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_coffee.png"));
|
||||||
|
item_textures_.emplace_back(Resource::get()->getTexture("item_debian.png"));
|
||||||
item_textures_.emplace_back(Resource::get()->getTexture("item_coffee_machine.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_points3_pacmar.ani"));
|
||||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_clock.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_coffee.ani"));
|
||||||
|
item_animations_.emplace_back(Resource::get()->getAnimation("item_debian.ani"));
|
||||||
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee_machine.ani"));
|
item_animations_.emplace_back(Resource::get()->getAnimation("item_coffee_machine.ani"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,7 +300,7 @@ void Game::updateGameStateGameOver()
|
|||||||
updateSmartSprites();
|
updateSmartSprites();
|
||||||
updatePathSprites();
|
updatePathSprites();
|
||||||
updateTimeStopped();
|
updateTimeStopped();
|
||||||
checkBulletBalloonCollision();
|
checkBulletCollision();
|
||||||
cleanVectors();
|
cleanVectors();
|
||||||
|
|
||||||
if (game_over_counter_ > 0)
|
if (game_over_counter_ > 0)
|
||||||
@@ -462,37 +465,36 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
case ItemType::DISK:
|
case ItemType::DISK:
|
||||||
{
|
{
|
||||||
player->addScore(1000);
|
player->addScore(1000);
|
||||||
const auto x =
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
|
||||||
item->getPosX() +
|
createItemText(x, game_text_textures_.at(0));
|
||||||
(item->getWidth() - game_text_textures_[0]->getWidth()) / 2;
|
|
||||||
createItemText(x, game_text_textures_[0]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::GAVINA:
|
case ItemType::GAVINA:
|
||||||
{
|
{
|
||||||
player->addScore(2500);
|
player->addScore(2500);
|
||||||
const auto x =
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
|
||||||
item->getPosX() +
|
createItemText(x, game_text_textures_.at(1));
|
||||||
(item->getWidth() - game_text_textures_[1]->getWidth()) / 2;
|
|
||||||
createItemText(x, game_text_textures_[1]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::PACMAR:
|
case ItemType::PACMAR:
|
||||||
{
|
{
|
||||||
player->addScore(5000);
|
player->addScore(5000);
|
||||||
const auto x =
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||||
item->getPosX() +
|
createItemText(x, game_text_textures_.at(2));
|
||||||
(item->getWidth() - game_text_textures_[2]->getWidth()) / 2;
|
break;
|
||||||
createItemText(x, game_text_textures_[2]);
|
}
|
||||||
|
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));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::CLOCK:
|
case ItemType::CLOCK:
|
||||||
{
|
{
|
||||||
enableTimeStopItem();
|
enableTimeStopItem();
|
||||||
const auto x =
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
|
||||||
item->getPosX() +
|
createItemText(x, game_text_textures_.at(5));
|
||||||
(item->getWidth() - game_text_textures_[5]->getWidth()) / 2;
|
|
||||||
createItemText(x, game_text_textures_[5]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::COFFEE:
|
case ItemType::COFFEE:
|
||||||
@@ -500,18 +502,14 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
if (player->getCoffees() == 2)
|
if (player->getCoffees() == 2)
|
||||||
{
|
{
|
||||||
player->addScore(5000);
|
player->addScore(5000);
|
||||||
const auto x =
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||||
item->getPosX() +
|
createItemText(x, game_text_textures_.at(2));
|
||||||
(item->getWidth() - game_text_textures_[2]->getWidth()) / 2;
|
|
||||||
createItemText(x, game_text_textures_[2]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player->giveExtraHit();
|
player->giveExtraHit();
|
||||||
const auto x =
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2;
|
||||||
item->getPosX() +
|
createItemText(x, game_text_textures_.at(4));
|
||||||
(item->getWidth() - game_text_textures_[4]->getWidth()) / 2;
|
|
||||||
createItemText(x, game_text_textures_[4]);
|
|
||||||
}
|
}
|
||||||
JA_PlaySound(Resource::get()->getSound("voice_coffee.wav"));
|
JA_PlaySound(Resource::get()->getSound("voice_coffee.wav"));
|
||||||
break;
|
break;
|
||||||
@@ -520,10 +518,8 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
{
|
{
|
||||||
player->setPowerUp();
|
player->setPowerUp();
|
||||||
coffee_machine_enabled_ = false;
|
coffee_machine_enabled_ = false;
|
||||||
const auto x =
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
|
||||||
item->getPosX() +
|
createItemText(x, game_text_textures_.at(3));
|
||||||
(item->getWidth() - game_text_textures_[3]->getWidth()) / 2;
|
|
||||||
createItemText(x, game_text_textures_[3]);
|
|
||||||
JA_PlaySound(Resource::get()->getSound("voice_power_up.wav"));
|
JA_PlaySound(Resource::get()->getSound("voice_power_up.wav"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -539,11 +535,23 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba y procesa la colisión entre las balas y los globos
|
// Comprueba y procesa la colisión de las balas
|
||||||
void Game::checkBulletBalloonCollision()
|
void Game::checkBulletCollision()
|
||||||
{
|
{
|
||||||
for (auto &bullet : bullets_)
|
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();
|
||||||
|
createItem(tabe_->tryToGetBonus() ? ItemType::DEBIAN : ItemType::COFFEE, pos.x, pos.y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba la colisión con los globos
|
||||||
for (auto &balloon : balloon_manager_->getBalloons())
|
for (auto &balloon : balloon_manager_->getBalloons())
|
||||||
{
|
{
|
||||||
if (balloon->isEnabled() && (!balloon->isInvulnerable()) && bullet->isEnabled())
|
if (balloon->isEnabled() && (!balloon->isInvulnerable()) && bullet->isEnabled())
|
||||||
@@ -1246,7 +1254,8 @@ void Game::checkEvents()
|
|||||||
}
|
}
|
||||||
case SDLK_7: // Flash
|
case SDLK_7: // Flash
|
||||||
{
|
{
|
||||||
screen_->flash(flash_color, 3);
|
// screen_->flash(flash_color, 3);
|
||||||
|
tabe_->setState(TabeState::HIT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDLK_8:
|
case SDLK_8:
|
||||||
@@ -1941,7 +1950,7 @@ void Game::updateGameStatePlaying()
|
|||||||
updatePathSprites();
|
updatePathSprites();
|
||||||
updateTimeStopped();
|
updateTimeStopped();
|
||||||
updateHelper();
|
updateHelper();
|
||||||
checkBulletBalloonCollision();
|
checkBulletCollision();
|
||||||
updateMenace();
|
updateMenace();
|
||||||
checkAndUpdateBalloonSpeed();
|
checkAndUpdateBalloonSpeed();
|
||||||
checkState();
|
checkState();
|
||||||
|
|||||||
@@ -211,8 +211,8 @@ private:
|
|||||||
// Comprueba la colisión entre el jugador y los items
|
// Comprueba la colisión entre el jugador y los items
|
||||||
void checkPlayerItemCollision(std::shared_ptr<Player> &player);
|
void checkPlayerItemCollision(std::shared_ptr<Player> &player);
|
||||||
|
|
||||||
// Comprueba la colisión entre las balas y los globos
|
// Comprueba y procesa la colisión de las balas
|
||||||
void checkBulletBalloonCollision();
|
void checkBulletCollision();
|
||||||
|
|
||||||
// Mueve las balas activas
|
// Mueve las balas activas
|
||||||
void updateBullets();
|
void updateBullets();
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ enum class ItemType : int
|
|||||||
PACMAR = 3, /**< Pacman */
|
PACMAR = 3, /**< Pacman */
|
||||||
CLOCK = 4, /**< Reloj */
|
CLOCK = 4, /**< Reloj */
|
||||||
COFFEE = 5, /**< Café */
|
COFFEE = 5, /**< Café */
|
||||||
COFFEE_MACHINE = 6,/**< Máquina de café */
|
DEBIAN = 6, /**< Debian */
|
||||||
NONE = 7, /**< Ninguno */
|
COFFEE_MACHINE = 7,/**< Máquina de café */
|
||||||
|
NONE = 8, /**< Ninguno */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ void Resource::createTextures()
|
|||||||
|
|
||||||
// Tamaño doble
|
// Tamaño doble
|
||||||
std::vector<NameAndText> strings2X = {
|
std::vector<NameAndText> strings2X = {
|
||||||
|
NameAndText("game_text_100000_points", "100.000"),
|
||||||
NameAndText("game_text_get_ready", lang::getText(75)),
|
NameAndText("game_text_get_ready", lang::getText(75)),
|
||||||
NameAndText("game_text_last_stage", lang::getText(79)),
|
NameAndText("game_text_last_stage", lang::getText(79)),
|
||||||
NameAndText("game_text_congratulations", lang::getText(50)),
|
NameAndText("game_text_congratulations", lang::getText(50)),
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public:
|
|||||||
|
|
||||||
// Devuelve el rectangulo donde está el sprite
|
// Devuelve el rectangulo donde está el sprite
|
||||||
SDL_Rect getPosition() const { return pos_; }
|
SDL_Rect getPosition() const { return pos_; }
|
||||||
|
SDL_Rect &getRect() { return pos_; }
|
||||||
|
|
||||||
// Establece la posición y el tamaño
|
// Establece la posición y el tamaño
|
||||||
void setX(int x) { pos_.x = x; }
|
void setX(int x) { pos_.x = x; }
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ void Tabe::update()
|
|||||||
{
|
{
|
||||||
sprite_->update();
|
sprite_->update();
|
||||||
move();
|
move();
|
||||||
|
updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +101,8 @@ void Tabe::enable()
|
|||||||
if (!enabled_)
|
if (!enabled_)
|
||||||
{
|
{
|
||||||
enabled_ = true;
|
enabled_ = true;
|
||||||
y_ = 20.0f;
|
has_bonus_ = true;
|
||||||
|
y_ = param.game.game_area.rect.y + 20.0f;
|
||||||
|
|
||||||
// Establece una dirección aleatoria
|
// Establece una dirección aleatoria
|
||||||
destiny_ = direction_ = rand() % 2 == 0 ? TabeDirection::TO_THE_LEFT : TabeDirection::TO_THE_RIGHT;
|
destiny_ = direction_ = rand() % 2 == 0 ? TabeDirection::TO_THE_LEFT : TabeDirection::TO_THE_RIGHT;
|
||||||
@@ -145,4 +147,52 @@ void Tabe::setRandomFlyPath(TabeDirection direction, int lenght)
|
|||||||
default:
|
default:
|
||||||
break;
|
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;
|
||||||
|
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() % 10 == 0)
|
||||||
|
{
|
||||||
|
has_bonus_ = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ enum class TabeDirection : int
|
|||||||
TO_THE_RIGHT = 1,
|
TO_THE_RIGHT = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class TabeState : int
|
||||||
|
{
|
||||||
|
FLY = 0,
|
||||||
|
HIT = 1,
|
||||||
|
};
|
||||||
|
|
||||||
// Clase Tabe
|
// Clase Tabe
|
||||||
class Tabe
|
class Tabe
|
||||||
{
|
{
|
||||||
@@ -21,15 +27,18 @@ private:
|
|||||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los graficos y animaciones
|
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los graficos y animaciones
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
float x_ = 0; // Posición del objeto
|
float x_ = 0; // Posición del objeto
|
||||||
float y_ = 0; // Posición del objeto
|
float y_ = 0; // Posición del objeto
|
||||||
float speed_ = 0.0f; // Velocidad de movimiento del objeto
|
float speed_ = 0.0f; // Velocidad de movimiento del objeto
|
||||||
float accel_ = 0.0f; // Aceleración del objeto
|
float accel_ = 0.0f; // Aceleración del objeto
|
||||||
int fly_distance_ = 0; // Distancia de vuelo
|
int fly_distance_ = 0; // Distancia de vuelo
|
||||||
int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto
|
int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto
|
||||||
bool enabled_ = false; // Indica si el objeto está activo
|
bool enabled_ = false; // Indica si el objeto está activo
|
||||||
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
|
||||||
|
int hit_counter = 0; // Contador para el estado HIT
|
||||||
|
bool has_bonus_ = true; // Indica si el Tabe aun tiene el bonus para soltar
|
||||||
|
|
||||||
// Mueve el objeto
|
// Mueve el objeto
|
||||||
void move();
|
void move();
|
||||||
@@ -40,6 +49,9 @@ private:
|
|||||||
// Establece un vuelo aleatorio
|
// Establece un vuelo aleatorio
|
||||||
void setRandomFlyPath(TabeDirection direction, int lenght);
|
void setRandomFlyPath(TabeDirection direction, int lenght);
|
||||||
|
|
||||||
|
// Actualiza el estado
|
||||||
|
void updateState();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Tabe();
|
Tabe();
|
||||||
@@ -55,4 +67,16 @@ public:
|
|||||||
|
|
||||||
// Habilita el objeto
|
// Habilita el objeto
|
||||||
void enable();
|
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_; }
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user