Positional battle audio
This commit is contained in:
parent
081cc142ee
commit
178153c82b
|
@ -99,7 +99,15 @@ void playBattleSound(int id, int x, int y)
|
||||||
vol /= MAX_BATTLE_SOUND_DISTANCE;
|
vol /= MAX_BATTLE_SOUND_DISTANCE;
|
||||||
vol *= distance;
|
vol *= distance;
|
||||||
|
|
||||||
Mix_SetDistance(channel, vol);
|
if (distance >= MIN_BATTLE_SOUND_DISTANCE)
|
||||||
|
{
|
||||||
|
float bearing = 360 - getAngle(x, y, lastPlayerX, lastPlayerY);
|
||||||
|
Mix_SetPosition(channel, (Sint16)bearing, (Uint8)distance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Mix_SetDistance(channel, vol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "SDL2/SDL_mixer.h"
|
#include "SDL2/SDL_mixer.h"
|
||||||
|
|
||||||
#define MAX_BATTLE_SOUND_DISTANCE 1500
|
#define MAX_BATTLE_SOUND_DISTANCE 1500
|
||||||
|
#define MIN_BATTLE_SOUND_DISTANCE 100
|
||||||
|
|
||||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||||
|
extern float getAngle(int x1, int y1, int x2, int y2);
|
||||||
extern char *getFileLocation(char *filename);
|
extern char *getFileLocation(char *filename);
|
||||||
|
|
||||||
extern Entity *player;
|
extern Entity *player;
|
||||||
|
|
Loading…
Reference in New Issue