Werkt, maar loopt vast

This commit is contained in:
Daniel
2016-05-30 12:46:49 +02:00
parent a80fc69043
commit f0a8330819
3 changed files with 15 additions and 13 deletions
+2 -1
View File
@@ -1,6 +1,6 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include "OpenAL.h"
#include "Enemy.h"
#include "Model.h"
#include <iostream>
@@ -53,6 +53,7 @@ void Enemy::update(float delta)
{
if (hasTarget)
{
OpenAL();
//just 2d walking
float dx, dz, length;
+11 -10
View File
@@ -2,24 +2,25 @@
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include "al.h"
#include "alc.h"
#include <al.h>
#include <alc.h>
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
+2 -2
View File
@@ -3,7 +3,7 @@ class OpenAL
{
public:
OpenAL();
bool EndWithError(char* msg);
bool Test();
int EndWithError(char* msg);
int Init();
~OpenAL();
};