-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSounds.cpp
More file actions
57 lines (47 loc) · 1.01 KB
/
Sounds.cpp
File metadata and controls
57 lines (47 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "Sounds.h"
#include "Logger.h"
Sounds::Sounds()
{
Logger::get() << "Initializing sounds...\n";
this->explosionSound = LoadSnd("sounds/EXPLOSION-Bang-04.wav");
this->shootSound = LoadSnd("sounds/WEAPON-GUNSHOT-Rifle-Swish-02.wav");
}
void Sounds::shoot()
{
PlaySnd(this->shootSound, this->volume);
}
void Sounds::explode()
{
PlaySnd(this->explosionSound, this->volume);
}
void Sounds::setVolume(const float volume)
{
this->volume = volume;
}
void Sounds::decreaseVolume()
{
if (this->volume > 0)
{
this->volume -= 0.01;
Logger::get() << "Volume was decreased to " << this->volume << "\n";
}
}
void Sounds::increaseVolume()
{
if (this->volume < 1)
{
this->volume += 0.01;
Logger::get() << "Volume was increased to " << this->volume << "\n";
}
}
void Sounds::tick(const Time currentTime)
{
if (IsKeyDown(VK_ADD))
{
this->increaseVolume();
}
else if (IsKeyDown(VK_SUBTRACT))
{
this->decreaseVolume();
}
}