Skip to content

Commit

Permalink
CLIENT-GAME: Add isReady method
Browse files Browse the repository at this point in the history
  • Loading branch information
TTENSHII committed Oct 4, 2023
1 parent 6c8c2e2 commit 2ad6834
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/Client/Raylib/Audio/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ namespace Raylib {
SetSoundVolume(_sound, volume);
}

bool Sound::isReady() const
{
return IsSoundReady(_sound);
}

void Sound::unload()
{
UnloadSound(_sound);
Expand Down Expand Up @@ -115,7 +120,7 @@ namespace Raylib {

bool Music::isReady() const
{
return IsMusicStreamPlaying(_music);
return IsMusicReady(_music);
}

void Music::play() const
Expand Down
1 change: 1 addition & 0 deletions src/Client/Raylib/Audio/Audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Raylib {
class Sound {
public:
Sound(const std::string& fileName, float volume = 0.5f);
bool isReady() const;
void unload();
void play() const;
void stop() const;
Expand Down
16 changes: 10 additions & 6 deletions src/ECS/Systems/Systems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ namespace Systems {
constexpr int enemyDamage = 1;
constexpr int playerHealth = 5;
constexpr int playerHealth2 = 5;
constexpr float musicVolume = 0.02F;
constexpr float soundVolume = 0.1F;
constexpr float musicVolume = 0.10F;
constexpr float soundVolume = 0.13F;
constexpr float fontScale = 2.0F;
const float playerWidth = 25.0F;
const float playerHeight = 25.0F;
Expand Down Expand Up @@ -196,10 +196,6 @@ namespace Systems {
{std::nullopt});
Registry::getInstance().setToFrontLayers(id);

Registry::getInstance().getComponents<Raylib::Music>().insertBack(
{musicPath, musicVolume});
Registry::getInstance().getComponents<Raylib::Sound>().insertBack(
{soundPath, soundVolume});
Registry::getInstance().getComponents<Raylib::Text>().insertBack(
{"Press SPACE to play music, ENTER to play sound, J to reset "
"scene, ARROWS to move",
Expand All @@ -213,6 +209,14 @@ namespace Systems {
SystemManagersDirector::getInstance()
.getSystemManager(managerId)
.removeSystem(systemId);

Registry::getInstance().setToFrontLayers(id);

Registry::getInstance().addEntity();
Registry::getInstance().getComponents<Raylib::Music>().insertBack(
{musicPath, musicVolume});
Registry::getInstance().getComponents<Raylib::Sound>().insertBack(
{soundPath, soundVolume});
}

std::vector<std::function<void(std::size_t, std::size_t)>> getECSSystems()
Expand Down

0 comments on commit 2ad6834

Please sign in to comment.