Werkt, maar loopt vast
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include "OpenAL.h"
|
||||||
#include "Enemy.h"
|
#include "Enemy.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -53,6 +53,7 @@ void Enemy::update(float delta)
|
|||||||
{
|
{
|
||||||
if (hasTarget)
|
if (hasTarget)
|
||||||
{
|
{
|
||||||
|
OpenAL();
|
||||||
//just 2d walking
|
//just 2d walking
|
||||||
float dx, dz, length;
|
float dx, dz, length;
|
||||||
|
|
||||||
|
|||||||
+11
-10
@@ -2,24 +2,25 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "al.h"
|
#include <al.h>
|
||||||
#include "alc.h"
|
#include <alc.h>
|
||||||
|
|
||||||
OpenAL::OpenAL()
|
OpenAL::OpenAL()
|
||||||
{
|
{
|
||||||
Test();
|
Init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenAL::EndWithError(char* msg)
|
int OpenAL::EndWithError(char* msg)
|
||||||
{
|
{
|
||||||
//Display error message in console
|
//Display error message in console
|
||||||
bool error = false;
|
int error = 0;
|
||||||
std::cout << msg << "\n";
|
std::cout << msg << "\n";
|
||||||
system("PAUSE");
|
system("PAUSE");
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenAL::Test()
|
int OpenAL::Init()
|
||||||
{
|
{
|
||||||
//Loading of the WAVE file
|
//Loading of the WAVE file
|
||||||
FILE *fp = NULL; //Create FILE pointer for 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
|
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
|
std::cout << fread(buf, sizeof(BYTE), dataSize, fp) << " bytes loaded\n"; //Read the sound data and display the
|
||||||
//number of bytes loaded.
|
//number of bytes loaded.
|
||||||
//Should be the same as the Data Size if OK
|
//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
|
ALCdevice *device; //Create an OpenAL Device
|
||||||
ALCcontext *context; //And an OpenAL Context
|
ALCcontext *context; //And an OpenAL Context
|
||||||
device = alcOpenDevice(NULL); //Open the device
|
device = alcOpenDevice(NULL); //Open the device
|
||||||
@@ -142,7 +143,7 @@ bool OpenAL::Test()
|
|||||||
//PLAY
|
//PLAY
|
||||||
alSourcePlay(source); //Play the sound buffer linked to the source
|
alSourcePlay(source); //Play the sound buffer linked to the source
|
||||||
if (alGetError() != AL_NO_ERROR) return EndWithError("Error playing sound"); //Error when playing sound
|
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
|
//Clean-up
|
||||||
fclose(fp); //Close the WAVE file
|
fclose(fp); //Close the WAVE file
|
||||||
|
|||||||
Reference in New Issue
Block a user