Practical Tools for Simple Design
Loading...
Searching...
No Matches
BGM.hpp
1#ifndef UTIL_BGM_HPP
2#define UTIL_BGM_HPP
3
4#include "pch.hpp" // IWYU pragma: export
5
6#include "Util/AssetStore.hpp"
7
8namespace Util {
17class BGM {
18public:
19 BGM() = delete;
20
26 explicit BGM(const std::string &path);
27
31 BGM(const BGM &) = delete;
32
37 BGM &operator=(const BGM &) = delete;
38
43 int GetVolume() const;
44
52 void SetVolume(int volume);
53
58 void LoadMedia(const std::string &path);
59
64 void VolumeUp(int step = 1);
65
70 void VolumeDown(int step = 1);
71
80 void Play(int loop = -1);
81
89 void FadeIn(int tick, int loop = -1);
90
95 void FadeOut(int tick);
96
102 void Pause();
103
108 void Resume();
109
110private:
112
113private:
114 std::shared_ptr<Mix_Music> m_BGM;
115};
116
117} // namespace Util
118
119#endif // UTIL_BGM_HPP
A class template for managing assets.
Definition: AssetStore.hpp:20
Class for handling background music.
Definition: BGM.hpp:17
void SetVolume(int volume)
Sets the volume of the background music.
int GetVolume() const
Retrieves the current volume of the background music.
void LoadMedia(const std::string &path)
Loads the background music from the specified file path.
void FadeIn(int tick, int loop=-1)
Fades in the background music gradually.
void Pause()
Pauses the currently playing background music.
void VolumeDown(int step=1)
Decreases the volume of the background music by one.
void FadeOut(int tick)
Fades out the background music gradually.
void Resume()
Resumes the paused background music.
BGM & operator=(const BGM &)=delete
Deleted copy assignment operator to prevent copying of BGM objects.
BGM(const BGM &)=delete
Deleted copy constructor to prevent copying of BGM objects.
BGM(const std::string &path)
Constructor that initializes the BGM object and loads the music from the specified file path.
void Play(int loop=-1)
Plays the background music.
void VolumeUp(int step=1)
Increases the volume of the background music by one.
Useful tools for development.
Definition: Animation.hpp:12