Creada la classe Resource
Afegida la musica i els sons a Resource
This commit is contained in:
@@ -22,13 +22,14 @@
|
||||
#include "global_inputs.h" // for check
|
||||
#include "input.h" // for InputType, Input, INPUT_DO_NOT_ALL...
|
||||
#include "item.h" // for Item, ItemType::COFFEE_MACHINE, ItemType::CLOCK
|
||||
#include "jail_audio.h" // for JA_PlaySound, JA_DeleteSound, JA_L...
|
||||
#include "jail_audio.h" // for JA_PlaySound
|
||||
#include "lang.h" // for getText
|
||||
#include "manage_hiscore_table.h" // for ManageHiScoreTable
|
||||
#include "notifier.h" // for Notifier
|
||||
#include "options.h" // for options
|
||||
#include "param.h" // for param
|
||||
#include "player.h" // for Player, PlayerStatus
|
||||
#include "resource.h" // for Resource
|
||||
#include "scoreboard.h" // for Scoreboard, ScoreboardMode, SCOREB...
|
||||
#include "screen.h" // for Screen
|
||||
#include "section.h" // for Name, name, Options, options
|
||||
@@ -39,9 +40,8 @@ struct JA_Music_t; // lines 35-35
|
||||
struct JA_Sound_t; // lines 36-36
|
||||
|
||||
// Constructor
|
||||
Game::Game(int player_id, int current_stage, bool demo, JA_Music_t *music)
|
||||
: music_(music),
|
||||
current_stage_(current_stage)
|
||||
Game::Game(int player_id, int current_stage, bool demo)
|
||||
: current_stage_(current_stage)
|
||||
{
|
||||
// Copia los punteros
|
||||
asset_ = Asset::get();
|
||||
@@ -429,25 +429,6 @@ void Game::loadMedia()
|
||||
text_nokia2_big_ = std::make_unique<Text>(asset_->get("nokia_big2.png"), asset_->get("nokia_big2.txt"), renderer_);
|
||||
}
|
||||
|
||||
// Sonidos
|
||||
{
|
||||
balloon_sound_ = JA_LoadSound(asset_->get("balloon.wav").c_str());
|
||||
bubble1_sound_ = JA_LoadSound(asset_->get("bubble1.wav").c_str());
|
||||
bubble2_sound_ = JA_LoadSound(asset_->get("bubble2.wav").c_str());
|
||||
bubble3_sound_ = JA_LoadSound(asset_->get("bubble3.wav").c_str());
|
||||
bubble4_sound_ = JA_LoadSound(asset_->get("bubble4.wav").c_str());
|
||||
bullet_sound_ = JA_LoadSound(asset_->get("bullet.wav").c_str());
|
||||
clock_sound_ = JA_LoadSound(asset_->get("clock.wav").c_str());
|
||||
coffee_out_sound_ = JA_LoadSound(asset_->get("coffeeout.wav").c_str());
|
||||
hi_score_sound_ = JA_LoadSound(asset_->get("hiscore.wav").c_str());
|
||||
item_drop_sound_ = JA_LoadSound(asset_->get("itemdrop.wav").c_str());
|
||||
item_pick_up_sound_ = JA_LoadSound(asset_->get("itempickup.wav").c_str());
|
||||
player_collision_sound_ = JA_LoadSound(asset_->get("player_collision.wav").c_str());
|
||||
power_ball_sound_ = JA_LoadSound(asset_->get("powerball.wav").c_str());
|
||||
stage_change_sound_ = JA_LoadSound(asset_->get("stage_change.wav").c_str());
|
||||
coffee_machine_sound_ = JA_LoadSound(asset_->get("title.wav").c_str());
|
||||
}
|
||||
|
||||
std::cout << "** RESOURCES FOR GAME SECTION LOADED\n"
|
||||
<< std::endl;
|
||||
}
|
||||
@@ -467,23 +448,6 @@ void Game::unloadMedia()
|
||||
balloon_animations_.clear();
|
||||
explosions_animations_.clear();
|
||||
item_animations_.clear();
|
||||
|
||||
// Sonidos
|
||||
JA_DeleteSound(balloon_sound_);
|
||||
JA_DeleteSound(bullet_sound_);
|
||||
JA_DeleteSound(player_collision_sound_);
|
||||
JA_DeleteSound(hi_score_sound_);
|
||||
JA_DeleteSound(item_drop_sound_);
|
||||
JA_DeleteSound(item_pick_up_sound_);
|
||||
JA_DeleteSound(coffee_out_sound_);
|
||||
JA_DeleteSound(stage_change_sound_);
|
||||
JA_DeleteSound(bubble1_sound_);
|
||||
JA_DeleteSound(bubble2_sound_);
|
||||
JA_DeleteSound(bubble3_sound_);
|
||||
JA_DeleteSound(bubble4_sound_);
|
||||
JA_DeleteSound(clock_sound_);
|
||||
JA_DeleteSound(power_ball_sound_);
|
||||
JA_DeleteSound(coffee_machine_sound_);
|
||||
}
|
||||
|
||||
// Carga el fichero de datos para la demo
|
||||
@@ -649,7 +613,7 @@ void Game::updateHiScore()
|
||||
if (hi_score_achieved_ == false)
|
||||
{
|
||||
hi_score_achieved_ = true;
|
||||
JA_PlaySound(hi_score_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("hiscore.wav"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -725,7 +689,7 @@ void Game::updateStage()
|
||||
updateHiScore();
|
||||
JA_StopMusic();
|
||||
}
|
||||
JA_PlaySound(stage_change_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("stage_change.wav"));
|
||||
stage_bitmap_counter_ = 0;
|
||||
balloon_speed_ = default_balloon_speed_;
|
||||
setBalloonSpeed(balloon_speed_);
|
||||
@@ -763,7 +727,11 @@ void Game::updateGameOver()
|
||||
{
|
||||
// Hace sonar aleatoriamente uno de los 4 sonidos de burbujas
|
||||
const auto index = rand() % 4;
|
||||
JA_Sound_t *sound[4] = {bubble1_sound_, bubble2_sound_, bubble3_sound_, bubble4_sound_};
|
||||
JA_Sound_t *sound[4] = {
|
||||
Resource::get()->getSound("bubble1.wav"),
|
||||
Resource::get()->getSound("bubble2.wav"),
|
||||
Resource::get()->getSound("bubble3.wav"),
|
||||
Resource::get()->getSound("bubble4.wav")};
|
||||
JA_PlaySound(sound[index], 0);
|
||||
}
|
||||
|
||||
@@ -991,7 +959,7 @@ void Game::destroyAllBalloons()
|
||||
}
|
||||
|
||||
balloon_deploy_counter_ = 300;
|
||||
JA_PlaySound(power_ball_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("powerball.wav"));
|
||||
screen_->flash(flash_color, 5);
|
||||
screen_->shake();
|
||||
}
|
||||
@@ -1119,7 +1087,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
||||
}
|
||||
|
||||
updateHiScore();
|
||||
JA_PlaySound(item_pick_up_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("itempickup.wav"));
|
||||
item->disable();
|
||||
}
|
||||
}
|
||||
@@ -1154,7 +1122,7 @@ void Game::checkBulletBalloonCollision()
|
||||
if (droppeditem != ItemType::COFFEE_MACHINE)
|
||||
{
|
||||
createItem(droppeditem, balloon->getPosX(), balloon->getPosY());
|
||||
JA_PlaySound(item_drop_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("itemdrop.wav"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1167,7 +1135,7 @@ void Game::checkBulletBalloonCollision()
|
||||
popBalloon(balloon);
|
||||
|
||||
// Sonido de explosión
|
||||
JA_PlaySound(balloon_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("balloon.wav"));
|
||||
|
||||
// Deshabilita la bala
|
||||
bullet->disable();
|
||||
@@ -1209,8 +1177,7 @@ void Game::renderBullets()
|
||||
// Crea un objeto bala
|
||||
void Game::createBullet(int x, int y, BulletType kind, bool powered_up, int owner)
|
||||
{
|
||||
auto b = std::make_unique<Bullet>(x, y, kind, powered_up, owner, &(param.game.play_area.rect), bullet_texture_);
|
||||
bullets_.push_back(std::move(b));
|
||||
bullets_.emplace_back(std::make_unique<Bullet>(x, y, kind, powered_up, owner, &(param.game.play_area.rect), bullet_texture_));
|
||||
}
|
||||
|
||||
// Vacia el vector de balas
|
||||
@@ -1238,7 +1205,7 @@ void Game::updateItems()
|
||||
item->update();
|
||||
if (item->isOnFloor())
|
||||
{
|
||||
JA_PlaySound(coffee_machine_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("title.wav"));
|
||||
screen_->shake();
|
||||
}
|
||||
}
|
||||
@@ -1439,7 +1406,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(coffee_out_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("coffeeout.wav"));
|
||||
screen_->shake();
|
||||
}
|
||||
else
|
||||
@@ -1450,9 +1417,9 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
|
||||
JA_PauseMusic();
|
||||
}
|
||||
stopAllBalloons(10);
|
||||
JA_PlaySound(player_collision_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("player_collision.wav"));
|
||||
screen_->shake();
|
||||
JA_PlaySound(coffee_out_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("coffeeout.wav"));
|
||||
player->setStatusPlaying(PlayerStatus::DYING);
|
||||
if (!demo_.enabled)
|
||||
{
|
||||
@@ -1772,14 +1739,14 @@ void Game::renderMessages()
|
||||
{
|
||||
if (time_stopped_counter_ % 30 == 0)
|
||||
{
|
||||
JA_PlaySound(clock_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (time_stopped_counter_ % 15 == 0)
|
||||
{
|
||||
JA_PlaySound(clock_sound_);
|
||||
JA_PlaySound(Resource::get()->getSound("clock.wav"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1843,7 +1810,7 @@ void Game::checkMusicStatus()
|
||||
if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED)
|
||||
{
|
||||
// Si se ha completado el juego o los jugadores han terminado, detiene la música
|
||||
game_completed_ || allPlayersAreGameOver() ? JA_StopMusic() : JA_PlayMusic(music_);
|
||||
game_completed_ || allPlayersAreGameOver() ? JA_StopMusic() : JA_PlayMusic(Resource::get()->getMusic("playing.ogg"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2352,6 +2319,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
|
||||
player->setInput(bulletType == BulletType::UP ? InputType::FIRE_CENTER : bulletType == BulletType::LEFT ? InputType::FIRE_LEFT
|
||||
: InputType::FIRE_RIGHT);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), bulletType, player->isPowerUp(), player->getId());
|
||||
JA_PlaySound(Resource::get()->getSound("bullet.wav"));
|
||||
player->setFireCooldown(10); // Establece un tiempo de espera para el próximo disparo.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user