Enemy speelt cow!

This commit is contained in:
Aaldert
2016-06-20 15:30:38 +02:00
parent 5c776e3d3a
commit d5406120c6
10 changed files with 26 additions and 32 deletions
+2 -5
View File
@@ -205,12 +205,9 @@
<None Include="worlds\worlds.json" />
</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\enemy.wav" />
<Media Include="WAVE\test1.wav" />
<Media Include="WAVE\test2.wav" />
<Media Include="WAVE\test3.wav" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+2 -11
View File
@@ -168,22 +168,13 @@
</None>
</ItemGroup>
<ItemGroup>
<Media Include="WAVE\Sound.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="WAVE\bond.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="WAVE\jpark.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="WAVE\test.wav">
<Media Include="WAVE\test1.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="WAVE\test2.wav">
<Filter>Resource Files</Filter>
</Media>
<Media Include="WAVE\test3.wav">
<Media Include="WAVE\enemy.wav">
<Filter>Resource Files</Filter>
</Media>
</ItemGroup>
+13 -9
View File
@@ -2,7 +2,6 @@
#include <cmath>
#include "Enemy.h"
#include "Model.h"
#include "CrystalPoint.h"
#include <iostream>
Enemy::Enemy(const std::string &fileName,
@@ -19,7 +18,8 @@ Enemy::Enemy(const std::string &fileName,
speed = 1;
radius = 10;
hasTarget = false;
hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound("WAVE/Sound.wav", false);
hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound("WAVE/enemy.wav", false);
music = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);
attack = false;
}
@@ -72,9 +72,14 @@ void Enemy::collide(const Entity * entity)
void Enemy::update(float delta)
{
music->SetPos(position, Vec3f());
if (hasTarget)
{
if (music->IsPlaying() == false)
{
music->Play();
}
//just 2d walking
float dx, dz, length;
@@ -98,15 +103,14 @@ void Enemy::update(float delta)
else
{
attack = true;
if (music->IsPlaying() == true)
{
// music->Pause();
music->Stop();
}
}
rotation.y = atan2f(dx, dz) * 180 / M_PI;
}
if (false)
{
Sound* sound = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);
sound->SetPos(position, Vec3f());
sound->Play();
}
}
+3
View File
@@ -3,6 +3,7 @@
#include "Entity.h"
#include <string>
#include "Vector.h"
#include "CrystalPoint.h"
class Enemy : public Entity
{
@@ -10,6 +11,8 @@ public:
Enemy(const std::string &fileName,const Vec3f &position,Vec3f &rotation,const float &scale);
~Enemy();
Sound* music;
bool hasTarget;
Vec3f target;
float speed,radius;
+5 -5
View File
@@ -9,8 +9,6 @@ Sound::Sound(const char* inWavPath, bool inLooping):
source_id(0),
is_looping(inLooping)
{
isPlaying = false;
const char* path = inWavPath;
FILE *fp = fopen(path, "rb"); // Open the WAVE file
@@ -122,7 +120,6 @@ void Sound::SetPos(const Vec3f& inPos, const Vec3f& inVel)
void Sound::Play()
{
isPlaying = true;
alSourcePlay(source_id);
int e = alGetError(); // != AL_NO_ERROR) return;
}
@@ -136,12 +133,15 @@ void Sound::Pause()
void Sound::Stop()
{
isPlaying = false;
alSourceStop(source_id);
}
bool Sound::IsPlaying()
{
return isPlaying;
ALenum state;
alGetSourcei(source_id, AL_SOURCE_STATE, &state);
return (state == AL_PLAYING);
}
-1
View File
@@ -16,7 +16,6 @@ public:
bool IsPlaying();
private:
bool isPlaying;
unsigned int buffer_id;
unsigned int source_id;
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -9,7 +9,7 @@
"collision": true
}
],
"music": "WAVE/test3.wav"
"music": "WAVE/test1.wav"
},
"player": {
"startposition": [ 20, 5, 20 ]