-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsoundeffect.cpp
34 lines (28 loc) · 884 Bytes
/
soundeffect.cpp
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
#include "prism/soundeffect.h"
#include "prism/memoryhandler.h"
#include "prism/file.h"
#include "prism/math.h"
namespace prism {
SoundEffectCollection loadConsecutiveSoundEffectsToCollection(const char* tPath, int tAmount) {
SoundEffectCollection ret;
ret.mAmount = tAmount;
ret.mSoundEffects = (int*)allocMemory(tAmount * sizeof(int));
loadConsecutiveSoundEffects(ret.mSoundEffects, tPath, tAmount);
return ret;
}
void loadConsecutiveSoundEffects(int* tDst, const char* tPath, int tAmount)
{
int i;
for (i = 0; i < tAmount; i++) {
char path[1024];
getPathWithNumberAffixedFromAssetPath(path, tPath, i);
tDst[i] = loadSoundEffect(path);
}
}
int playRandomSoundEffectFromCollection(const SoundEffectCollection& tCollection)
{
int i;
i = randfromInteger(0, tCollection.mAmount - 1);
return playSoundEffect(tCollection.mSoundEffects[i]);
}
}