Skip to content

Commit

Permalink
Add music and sound effect
Browse files Browse the repository at this point in the history
- Add music and sound effect
- Other minor bug fixes
  • Loading branch information
NearHuscarl committed Jan 21, 2019
1 parent fe4b72b commit 89f7d26
Show file tree
Hide file tree
Showing 58 changed files with 241 additions and 41 deletions.
5 changes: 2 additions & 3 deletions src/GameCuaTao/Castlevania/CastlevaniaGame.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "Direct2DGame/Input/InputHelper.h"
#include "CastlevaniaGame.h"
#include "Utilities/AudioManager.h"
#include "Settings/Audios.h"

using namespace Castlevania;

Expand All @@ -25,7 +24,7 @@ void CastlevaniaGame::Initialize()

void CastlevaniaGame::LoadContent()
{
AudioManager::LoadContent(*content, GAME_AUDIO);
AudioManager::LoadContent(*content);
}

void CastlevaniaGame::Update(GameTime gameTime)
Expand All @@ -39,4 +38,4 @@ void CastlevaniaGame::Draw(GameTime gameTime)
GetGraphicsDevice().Clear(Color::Black());

sceneManager->Draw(gameTime);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions src/GameCuaTao/Castlevania/Models/Areas/WaterArea.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "WaterArea.h"
#include "../Settings.h"
#include "../../Utilities/AudioManager.h"

using namespace Castlevania;

Expand All @@ -11,4 +12,5 @@ void WaterArea::Splash(Vector2 position)
{
splashPosition = position;
SendMessageToSystems(OBJECT_HITS_WATER_SURFACE);
AudioManager::Play(SE_HITTING_WATER_SURFACE);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Fishman.h"
#include "../../UpdateData.h"
#include "../../Settings.h"
#include "../../../Utilities/AudioManager.h"
#include "../../../Utilities/CollisionGrid.h"

using namespace Castlevania;
Expand Down Expand Up @@ -54,6 +55,7 @@ void Fishman::Update(UpdateData &updateData)
void Fishman::Launch()
{
velocity.y = -launchSpeed;
AudioManager::Play(SE_FISHMAN_LAUNCHING);
SetFishmanState(FishmanState::LAUNCHING);
}

Expand Down
13 changes: 9 additions & 4 deletions src/GameCuaTao/Castlevania/Models/Characters/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../../Settings.h"
#include "../../UpdateData.h"
#include "../../../Scenes/Stages/StageEvent.h"
#include "../../../Utilities/AudioManager.h"
#include "../../../Utilities/CollisionGrid.h"

using namespace Castlevania;
Expand Down Expand Up @@ -194,6 +195,7 @@ void Player::UpdateStates()

if (invisibleTimer.ElapsedMilliseconds() > INVISIBLE_TIME)
{
AudioManager::Play(SE_INVISIBLE_END);
invisibleTimer.Reset();
SendMessageToSystems(INVISIBLE_ENDED);
}
Expand Down Expand Up @@ -368,7 +370,7 @@ void Player::Attack()

void Player::Stoptime()
{
if (isStopwatchActive)
if (isStopwatchActive || data.hearts < 5)
return;

data.hearts = MathHelper::Max(data.hearts - 5, 0);
Expand All @@ -384,8 +386,7 @@ void Player::Throw(std::unique_ptr<RangedWeapon> weapon)
{
if (throwingCooldownTimer.ElapsedMilliseconds() < THROWING_COOLDOWN_TIME)
return;

if (throwingCooldownTimer.ElapsedMilliseconds() >= THROWING_COOLDOWN_TIME)
else
{
if (data.powerup == ObjectId::DoubleShot)
subWeaponCount = 2;
Expand Down Expand Up @@ -511,6 +512,7 @@ void Player::Land()
{
SetMoveState(MoveState::LANDING_HARD);
velocity = Vector2::Zero();
AudioManager::Play(SE_LANDING);
landingTimer.Start();
}
else
Expand All @@ -529,6 +531,7 @@ void Player::Flash()

void Player::BecomeInvisible()
{
AudioManager::Play(SE_INVISIBLE_START);
invisibleTimer.Start();
SendMessageToSystems(INVISIBLE_STARTED);
}
Expand All @@ -545,6 +548,7 @@ void Player::TakeDamage(int damage, Direction direction)

data.health.Add(-damage);
untouchableTimer.Start();
AudioManager::Play(SE_BEING_HIT);
SendMessageToSystems(UNTOUCHABLE_STARTED);
}

Expand Down Expand Up @@ -583,6 +587,7 @@ void Player::Die()

velocity.x = 0.0f;
controlSystem->Enabled(false);
AudioManager::Play(SE_LIVE_LOST);
SetState(ObjectState::DYING);
}

Expand All @@ -598,4 +603,4 @@ void Player::Revive()
SetState(ObjectState::NORMAL);
}

#pragma endregion
#pragma endregion
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../../Settings.h"
#include "../../UpdateData.h"
#include "../../../Scenes/Stages/StageEvent.h"
#include "../../../Utilities/AudioManager.h"

using namespace Castlevania;

Expand Down Expand Up @@ -345,6 +346,7 @@ void PlayerResponseSystem::OnCollideWithMoneyBag(CollisionResult &result)
moneyBag.SetPosition(effectPosition);

parent.AddExp(moneyBag.GetMoney());
AudioManager::Play(SE_GETTING_MONEY_BAG);
}

void PlayerResponseSystem::OnCollideWithSubWeaponItem(CollisionResult &result)
Expand All @@ -354,6 +356,7 @@ void PlayerResponseSystem::OnCollideWithSubWeaponItem(CollisionResult &result)

subWeaponItem.Destroy();
parent.SetSubWeapon(itemId);
AudioManager::Play(SE_GETTING_POWERUP);
}

void PlayerResponseSystem::OnCollideWithCross(CollisionResult &result)
Expand All @@ -362,6 +365,7 @@ void PlayerResponseSystem::OnCollideWithCross(CollisionResult &result)

parent.Notify(CROSS_POWERUP_ACTIVATED);
cross.Destroy();
AudioManager::Play(SE_GETTING_HOLY_CROSS);
}

void PlayerResponseSystem::OnCollideWithHeart(CollisionResult &result)
Expand All @@ -370,6 +374,7 @@ void PlayerResponseSystem::OnCollideWithHeart(CollisionResult &result)

parent.AddHeart(5);
largeHeart.Destroy();
AudioManager::Play(SE_GETTING_HEART);
}

void PlayerResponseSystem::OnCollideWithSmallHeart(CollisionResult &result)
Expand All @@ -378,6 +383,7 @@ void PlayerResponseSystem::OnCollideWithSmallHeart(CollisionResult &result)

parent.AddHeart(1);
smallHeart.Destroy();
AudioManager::Play(SE_GETTING_HEART);
}

void PlayerResponseSystem::OnCollideWithInvisibleJar(CollisionResult &result)
Expand All @@ -394,6 +400,7 @@ void PlayerResponseSystem::OnCollideWithPorkChop(CollisionResult &result)

parent.data.health.Add(6);
porkChop.Destroy();
AudioManager::Play(SE_GETTING_POWERUP);
}

void PlayerResponseSystem::OnCollideWithWhipPowerup(CollisionResult &result)
Expand All @@ -420,6 +427,7 @@ void PlayerResponseSystem::OnCollideWithWhipPowerup(CollisionResult &result)
}

whipPowerup.Destroy();
AudioManager::Play(SE_GETTING_POWERUP);
}

void PlayerResponseSystem::OnCollideWithDoubleShot(CollisionResult &result)
Expand All @@ -428,6 +436,7 @@ void PlayerResponseSystem::OnCollideWithDoubleShot(CollisionResult &result)

parent.data.powerup = ObjectId::DoubleShot;
doubleShot.Destroy();
AudioManager::Play(SE_GETTING_POWERUP);
}

void PlayerResponseSystem::OnCollideWithCrystalBall(CollisionResult &result)
Expand Down
3 changes: 3 additions & 0 deletions src/GameCuaTao/Castlevania/Models/Factories/ObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Direct2DGame/Utilities/CppExtensions.h"
#include "ObjectFactory.h"
#include "../../Utilities/TypeConverter.h"
#include "../../Settings/Audios.h"
#include "../Systems/Movement/SimpleMovementSystem.h"
#include "../Systems/Movement/EntityMovementSystem.h"
#include "../Systems/Movement/WaveMovementSystem.h"
Expand Down Expand Up @@ -495,6 +496,7 @@ std::unique_ptr<RangedWeapon> ObjectFactory::CreateAxe(Vector2 position)
auto renderingSystem = std::make_unique<AnimationRenderingSystem>(*object, "Weapons/Axe.ani.xml");

object->SetPosition(position);
object->SetThrowSoundEffect(SE_USING_WEAPON);
object->Attach(std::move(movementSystem));
object->Attach(std::move(collisionSystem));
object->Attach(std::move(responseSystem));
Expand All @@ -518,6 +520,7 @@ std::unique_ptr<RangedWeapon> ObjectFactory::CreateDagger(Vector2 position)
auto renderingSystem = std::make_unique<SpriteRenderingSystem>(*object, "Weapons/Dagger.png");

object->SetPosition(position);
object->SetThrowSoundEffect(SE_THROWING_DAGGER);
object->Attach(std::move(movementSystem));
object->Attach(std::move(collisionSystem));
object->Attach(std::move(responseSystem));
Expand Down
6 changes: 6 additions & 0 deletions src/GameCuaTao/Castlevania/Models/Items/Container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Powerup.h"
#include "../Settings.h"
#include "../../Models/UpdateData.h"
#include "../../Utilities/AudioManager.h"
#include "../../Utilities/CollisionGrid.h"

using namespace Castlevania;
Expand Down Expand Up @@ -30,6 +31,11 @@ void Container::OnBeingHit()
SpawnItem();
}

if (objectId == ObjectId::BreakableBlock)
AudioManager::PlayOneInstance(SE_HITTING_BREAKABLE_BLOCK);
else
AudioManager::PlayOneInstance(SE_HITTING_SOMETHING);

SetState(ObjectState::DYING);
body.Enabled(false);
}
Expand Down
3 changes: 3 additions & 0 deletions src/GameCuaTao/Castlevania/Models/Items/Door.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Door.h"
#include "../Settings.h"
#include "../../Utilities/AudioManager.h"

using namespace Castlevania;

Expand All @@ -21,11 +22,13 @@ void Door::Idle()
void Door::Open()
{
doorState = DoorState::OPENING;
AudioManager::Play(SE_USING_DOOR);
SendMessageToSystems(MOVE_STATE_CHANGED);
}

void Door::Close()
{
doorState = DoorState::CLOSING;
AudioManager::Play(SE_USING_DOOR);
SendMessageToSystems(MOVE_STATE_CHANGED);
}
2 changes: 2 additions & 0 deletions src/GameCuaTao/Castlevania/Models/Weapons/HolyWater.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "HolyWater.h"
#include "../Settings.h"
#include "../../Utilities/AudioManager.h"

using namespace Castlevania;

Expand All @@ -14,6 +15,7 @@ void HolyWater::StartFlaming()
Detach<IMovementSystem>();
isFlaming = true;
SendMessageToSystems(MOVE_STATE_CHANGED);
AudioManager::Play(SE_HOLY_WATER_TOUCHING_GROUND);
flamingTimer.Start();
}

Expand Down
8 changes: 8 additions & 0 deletions src/GameCuaTao/Castlevania/Models/Weapons/RangedWeapon.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "RangedWeapon.h"
#include "../UpdateData.h"
#include "../../Utilities/AudioManager.h"

using namespace Castlevania;

Expand All @@ -8,6 +9,11 @@ RangedWeapon::RangedWeapon(ObjectId type) : GameObject{ type }
this->throwVelocity = Vector2{ 500, 0 };
}

void RangedWeapon::SetThrowSoundEffect(std::string soundEffect)
{
throwSoundEffect = soundEffect;
}

Vector2 RangedWeapon::GetThrowVelocity()
{
return throwVelocity;
Expand Down Expand Up @@ -54,4 +60,6 @@ void RangedWeapon::Throw(Vector2 position)
velocity.x = std::abs(velocity.x);
else
velocity.x = -std::abs(velocity.x);

AudioManager::Play(throwSoundEffect);
}
2 changes: 2 additions & 0 deletions src/GameCuaTao/Castlevania/Models/Weapons/RangedWeapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Castlevania
public:
RangedWeapon(ObjectId type);

void SetThrowSoundEffect(std::string soundEffect);
Vector2 GetThrowVelocity();
void SetThrowVelocity(Vector2 velocity);
int GetAttack() override;
Expand All @@ -22,5 +23,6 @@ namespace Castlevania
private:
Vector2 throwVelocity;
int attack;
std::string throwSoundEffect;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../Characters/Enemies/Enemy.h"
#include "../Settings.h"
#include "../IAttackable.h"
#include "../../Utilities/AudioManager.h"

using namespace Castlevania;

Expand Down Expand Up @@ -105,6 +106,7 @@ void WeaponResponseSystem::OnCollideWithEnemy(CollisionResult &result, Player &p

hitObjects.push_back(&enemy);
enemy.TakeDamage(weapon->GetAttack());
AudioManager::PlayOneInstance(SE_HITTING_SOMETHING);

if (enemy.GetState() == ObjectState::DYING)
player.AddExp(enemy.GetExp());
Expand All @@ -119,6 +121,7 @@ void WeaponResponseSystem::OnCollideWithFireball(CollisionResult &result)

fireball.GetBody().Enabled(false);
fireball.SetState(ObjectState::DYING);
AudioManager::PlayOneInstance(SE_HITTING_SOMETHING);

if (destroyOnHit)
parent.Destroy();
Expand Down
2 changes: 2 additions & 0 deletions src/GameCuaTao/Castlevania/Models/Weapons/Whip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Whip.h"
#include "../Settings.h"
#include "WhipFlashingRenderingSystem.h"
#include "../../Utilities/AudioManager.h"

using namespace Castlevania;

Expand Down Expand Up @@ -63,6 +64,7 @@ void Whip::Unleash()
// Collision detection will be turn on when whip is on the attack frame
// body.Enabled(true);
SendMessageToSystems(WHIP_UNLEASHED);
AudioManager::Play(SE_USING_WEAPON);
}

void Whip::Withdraw()
Expand Down
3 changes: 3 additions & 0 deletions src/GameCuaTao/Castlevania/Scenes/GameOverScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "GameOverScene.h"
#include "SceneManager.h"
#include "GameplayScene.h"
#include "../Utilities/AudioManager.h"

using namespace Castlevania;

Expand Down Expand Up @@ -33,6 +34,8 @@ void GameOverScene::LoadContent()

endTextPosition.x = gameOverTextPosition.x + 12;
endTextPosition.y = gameOverTextPosition.y + 130;

AudioManager::Play(M_GAME_OVER);
}

void GameOverScene::Update(GameTime gameTime)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "BossFightCutscene.h"
#include "Stage.h"
#include "StageEvent.h"
#include "../../Utilities/AudioManager.h"

using namespace Castlevania;

Expand Down Expand Up @@ -57,6 +58,8 @@ void BossFightCutscene::Update(UpdateData &updateData)
boss->SetActive();

stage.OnNotify(Subject::Empty(), CUTSCENE_ENDED);
AudioManager::Stop(M_BLOCK_01);
AudioManager::PlaySong(M_BOSS_BATTLE);
isComplete = true;
}
}
Loading

0 comments on commit 89f7d26

Please sign in to comment.