-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSound.cpp
More file actions
50 lines (42 loc) · 1.25 KB
/
Sound.cpp
File metadata and controls
50 lines (42 loc) · 1.25 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
/*#include "Utility/package.hpp"
#include "Sound.hpp"
//---------------------------------------------------------------------------------
// Written by Terence J. Grant - tjgrant [at] tatewake [dot] com
// Find the full tutorial at: http://gamedev.tutsplus.com/series/
//----------------------------------------------------------------------------------
Sound::Sound()
{
char buf[80];
mMusic = new tSound("music.mp3");
for (int i = 1; i <= 8; i++)
{
sprintf(buf, "explosion-0%d.wav", i);
mExplosions.push_back(new tSound(buf));
if (i <= 4)
{
sprintf(buf, "shoot-0%d.wav", i);
mShots.push_back(new tSound(buf));
}
sprintf(buf, "spawn-0%d.wav", i);
mSpawns.push_back(new tSound(buf));
}
}
tSound* Sound::getMusic() const
{
return mMusic;
}
tSound* Sound::getExplosion() const
{
size_t i = size_t(tMath::random() * (float)mExplosions.size()) % mExplosions.size();
return mExplosions[i];
}
tSound* Sound::getShot() const
{
size_t i = size_t(tMath::random() * (float)mShots.size()) % mShots.size();
return mShots[i];
}
tSound* Sound::getSpawn() const
{
size_t i = size_t(tMath::random() * (float)mSpawns.size()) % mSpawns.size();
return mSpawns[i];
}*/