| 173 | { |
| 174 | public: |
| 175 | PitchVolume() : |
| 176 | Effect("Pitch / Volume"), |
| 177 | m_pitchText(getFont(), "Pitch: " + std::to_string(m_pitch)), |
| 178 | m_volumeText(getFont(), "Volume: " + std::to_string(m_volume)) |
| 179 | { |
| 180 | // Load the music file |
| 181 | if (!m_music.openFromFile(resourcesDir() / "doodle_pop.ogg")) |
| 182 | { |
| 183 | std::cerr << "Failed to load " << (resourcesDir() / "doodle_pop.ogg").string() << std::endl; |
| 184 | std::abort(); |
| 185 | } |
| 186 | |
| 187 | // Set the music to loop |
| 188 | m_music.setLooping(true); |
| 189 | |
| 190 | // We don't care about attenuation in this effect |
| 191 | m_music.setAttenuation(0.f); |
| 192 | |
| 193 | // Set initial pitch |
| 194 | m_music.setPitch(m_pitch); |
| 195 | |
| 196 | // Set initial volume |
| 197 | m_music.setVolume(m_volume); |
| 198 | |
| 199 | m_pitchText.setPosition({windowWidth / 2.f - 120.f, windowHeight / 2.f - 80.f}); |
| 200 | m_volumeText.setPosition({windowWidth / 2.f - 120.f, windowHeight / 2.f - 30.f}); |
| 201 | } |
| 202 | |
| 203 | void onUpdate(float /*time*/, float x, float y) override |
| 204 | { |
nothing calls this directly
no test coverage detected