-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge: Merge pull request #44 from G-Epitech/43-add-snake-music
feat: add snake sounds
- Loading branch information
Showing
23 changed files
with
428 additions
and
27 deletions.
There are no files selected for viewing
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** arcade | ||
** File description: | ||
** SoundComponent | ||
*/ | ||
|
||
#include "SoundComponent.hpp" | ||
|
||
using namespace shared::games::components; | ||
using namespace arcade::games::common::components; | ||
|
||
SoundComponent::SoundComponent(shared::games::entity::IEntity &entity, const std::string &path, | ||
shared::games::components::SoundState state, shared::games::components::SoundVolume volume, bool loop, onChangeFunction onChange) | ||
: AComponent(SOUND, entity), _path(path), _state(state), _volume(volume), _loop(loop), _onChange(onChange) | ||
{ | ||
this->_type = SOUND; | ||
} | ||
|
||
const std::string &SoundComponent::getPath() const noexcept | ||
{ | ||
return this->_path; | ||
} | ||
|
||
SoundState &SoundComponent::getState() noexcept | ||
{ | ||
return this->_state; | ||
} | ||
|
||
SoundVolume &SoundComponent::getVolume() noexcept | ||
{ | ||
return this->_volume; | ||
} | ||
|
||
bool &SoundComponent::getLoop() noexcept | ||
{ | ||
return this->_loop; | ||
} | ||
|
||
void SoundComponent::onStateChange(std::shared_ptr<shared::games::IGame> ctx, | ||
shared::games::components::SoundState state) | ||
{ | ||
if (this->_onChange) | ||
this->_onChange(ctx, state); | ||
} | ||
|
||
void SoundComponent::setState(SoundState state) | ||
{ | ||
this->_state = state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** arcade | ||
** File description: | ||
** SoundComponent | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "AComponent.hpp" | ||
#include "shared/games/components/ISoundComponent.hpp" | ||
|
||
namespace arcade::games::common::components | ||
{ | ||
class SoundComponent; | ||
} | ||
|
||
class arcade::games::common::components::SoundComponent | ||
: public virtual shared::games::components::ISoundComponent, public AComponent | ||
{ | ||
public: | ||
typedef void (*onChangeFunction)(std::shared_ptr<shared::games::IGame> ctx, shared::games::components::SoundState state); | ||
|
||
~SoundComponent() override = default; | ||
|
||
explicit SoundComponent(shared::games::entity::IEntity &entity, const std::string &path, | ||
shared::games::components::SoundState state, shared::games::components::SoundVolume volume, bool loop, onChangeFunction onChange = nullptr); | ||
|
||
/** | ||
* @brief Get path of the sound | ||
* | ||
* @return Sound path | ||
*/ | ||
const std::string &getPath() const noexcept override; | ||
|
||
/** | ||
* @brief Get state of the sound | ||
* | ||
* @return Sound state | ||
*/ | ||
shared::games::components::SoundState &getState() noexcept override; | ||
|
||
/** | ||
* @brief Get volume of the sound | ||
* | ||
* @return Sound volume | ||
*/ | ||
shared::games::components::SoundVolume &getVolume() noexcept override; | ||
|
||
/** | ||
* @brief Get loop of the sound | ||
* | ||
* @return Sound loop | ||
*/ | ||
bool &getLoop() noexcept override; | ||
|
||
/** | ||
* @brief On state change event handler for the component | ||
* | ||
* @param ctx Context of the game | ||
* @param state New state of the sound | ||
*/ | ||
void onStateChange(std::shared_ptr<shared::games::IGame> ctx, shared::games::components::SoundState state) override; | ||
|
||
/** | ||
* @brief Set the state of the sound | ||
* | ||
* @param state New state of the sound | ||
*/ | ||
void setState(shared::games::components::SoundState state); | ||
|
||
protected: | ||
std::string _path; | ||
shared::games::components::SoundState _state; | ||
shared::games::components::SoundVolume _volume; | ||
onChangeFunction _onChange; | ||
bool _loop; | ||
}; |
Oops, something went wrong.