-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudioService.cpp
More file actions
42 lines (35 loc) · 1.09 KB
/
AudioService.cpp
File metadata and controls
42 lines (35 loc) · 1.09 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
#include "AudioService.h"
AudioService::AudioService()
{
if (Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 1024) == -1)
{
cout << "Unable to initialize audio system" << endl;
}
mSounds.push_back(Mix_LoadWAV("Resources/menu_scroll.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/menu_select.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/death.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/explosion.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/fire.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/laser.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/pickup.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/launch_explosive.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/InvaderDead.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/lifeUp.wav"));
mSounds.push_back(Mix_LoadWAV("Resources/multi.wav"));
}
AudioService::~AudioService()
{
for (unsigned i = 0; i < mSounds.size(); i++)
{
Mix_FreeChunk(mSounds[i]);
}
mSounds.clear();
Mix_CloseAudio();
}
void AudioService::playSound(SoundEffect id)
{
Mix_PlayChannel(-1, mSounds[id], 0);
}
void AudioService::stopAllSounds()
{
}