This commit is contained in:
Aaldert
2016-06-20 13:43:13 +02:00
parent f84fcfa4e2
commit b7d73c9abe
7 changed files with 31 additions and 5 deletions
+3
View File
@@ -206,7 +206,10 @@
</ItemGroup>
<ItemGroup>
<Media Include="WAVE\bond.wav" />
<Media Include="WAVE\jpark.wav" />
<Media Include="WAVE\Sound.wav" />
<Media Include="WAVE\test.wav" />
<Media Include="WAVE\test2.wav" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+9
View File
@@ -174,5 +174,14 @@
<Media Include="WAVE\bond.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="WAVE\test.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="WAVE\test2.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="WAVE\jpark.wav">
<Filter>Resource Files</Filter>
</Media>
</ItemGroup>
</Project>
+9 -1
View File
@@ -8,8 +8,9 @@ Sound::Sound(const char* inWavPath, bool inLooping):
buffer_id(0),
source_id(0),
is_looping(inLooping)
{
isPlaying = false;
const char* path = inWavPath;
FILE *fp = fopen(path, "rb"); // Open the WAVE file
@@ -121,6 +122,7 @@ void Sound::SetPos(const Vec3f& inPos, const Vec3f& inVel)
void Sound::Play()
{
isPlaying = true;
alSourcePlay(source_id);
int e = alGetError(); // != AL_NO_ERROR) return;
}
@@ -134,6 +136,12 @@ void Sound::Pause()
void Sound::Stop()
{
isPlaying = false;
alSourceStop(source_id);
}
bool Sound::IsPlaying()
{
return isPlaying;
}
+2
View File
@@ -13,8 +13,10 @@ public:
void Play();
void Pause();
void Stop();
bool IsPlaying();
private:
bool isPlaying;
unsigned int buffer_id;
unsigned int source_id;
BIN
View File
Binary file not shown.
+7 -3
View File
@@ -179,9 +179,6 @@ World::World(const std::string &fileName):
if (!v["world"]["music"].isNull())
{
music_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
Sound* music = CrystalPoint::GetSoundSystem().GetSound(music_id);
music->SetPos(Vec3f(), Vec3f());
music->Play();
}
if (!v["portal"].isNull())
@@ -257,6 +254,13 @@ void World::draw()
void World::update(float elapsedTime)
{
Sound* music = CrystalPoint::GetSoundSystem().GetSound(music_id);
music->SetPos(player->position, Vec3f());
if (music->IsPlaying() == false)
{
music->Play();
}
for (auto &entity : entities)
entity->update(elapsedTime);
+1 -1
View File
@@ -9,7 +9,7 @@
"collision": true
}
],
"music": "WAVE/bond.wav"
"music": "WAVE/test2.wav"
},
"player": {
"startposition": [ 20, 5, 20 ]