Enemy speelt cow!
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ public:
|
||||
bool IsPlaying();
|
||||
|
||||
private:
|
||||
bool isPlaying;
|
||||
unsigned int buffer_id;
|
||||
unsigned int source_id;
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -9,7 +9,7 @@
|
||||
"collision": true
|
||||
}
|
||||
],
|
||||
"music": "WAVE/test3.wav"
|
||||
"music": "WAVE/test1.wav"
|
||||
},
|
||||
"player": {
|
||||
"startposition": [ 20, 5, 20 ]
|
||||
|
||||
Reference in New Issue
Block a user