diff --git a/Enemy.cpp b/Enemy.cpp index c62fb46..3ee1faf 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -1,6 +1,6 @@ #define _USE_MATH_DEFINES #include - +#include "OpenAL.h" #include "Enemy.h" #include "Model.h" #include @@ -53,6 +53,7 @@ void Enemy::update(float delta) { if (hasTarget) { + OpenAL(); //just 2d walking float dx, dz, length; diff --git a/OpenAL.cpp b/OpenAL.cpp index fd95666..092411f 100644 --- a/OpenAL.cpp +++ b/OpenAL.cpp @@ -2,24 +2,25 @@ #include #include #include -#include "al.h" -#include "alc.h" +#include +#include OpenAL::OpenAL() { - Test(); + Init(); + } -bool OpenAL::EndWithError(char* msg) +int OpenAL::EndWithError(char* msg) { //Display error message in console - bool error = false; + int error = 0; std::cout << msg << "\n"; system("PAUSE"); return error; } -bool OpenAL::Test() +int OpenAL::Init() { //Loading of the WAVE file FILE *fp = NULL; //Create FILE pointer for the WAVE file @@ -76,11 +77,11 @@ bool OpenAL::Test() unsigned char* buf = new unsigned char[dataSize]; //Allocate memory for the sound data std::cout << fread(buf, sizeof(BYTE), dataSize, fp) << " bytes loaded\n"; //Read the sound data and display the - //number of bytes loaded. - //Should be the same as the Data Size if OK + //number of bytes loaded. + //Should be the same as the Data Size if OK - //Now OpenAL needs to be initialized + //Now OpenAL needs to be initialized ALCdevice *device; //Create an OpenAL Device ALCcontext *context; //And an OpenAL Context device = alcOpenDevice(NULL); //Open the device @@ -142,7 +143,7 @@ bool OpenAL::Test() //PLAY alSourcePlay(source); //Play the sound buffer linked to the source if (alGetError() != AL_NO_ERROR) return EndWithError("Error playing sound"); //Error when playing sound - system("PAUSE"); //Pause to let the sound play + //system("PAUSE"); //Pause to let the sound play //Clean-up fclose(fp); //Close the WAVE file diff --git a/OpenAL.h b/OpenAL.h index 39b7e30..6b16ffa 100644 --- a/OpenAL.h +++ b/OpenAL.h @@ -3,7 +3,7 @@ class OpenAL { public: OpenAL(); - bool EndWithError(char* msg); - bool Test(); + int EndWithError(char* msg); + int Init(); ~OpenAL(); };