indent playsound.c playsound.h
This commit is contained in:
parent
41893a9cda
commit
10c9976e39
2 changed files with 42 additions and 44 deletions
|
|
@ -33,55 +33,54 @@ int mute;
|
||||||
int use_sound = 1;
|
int use_sound = 1;
|
||||||
static int old_sound[4] = { -1, -1, -1, -1 };
|
static int old_sound[4] = { -1, -1, -1, -1 };
|
||||||
|
|
||||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x,
|
void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y)
|
||||||
int y)
|
|
||||||
{
|
{
|
||||||
#ifndef NOSOUND
|
#ifndef NOSOUND
|
||||||
int left, dist;
|
int left, dist;
|
||||||
|
|
||||||
if (!mute && use_sound && s != SND_NONE)
|
if (!mute && use_sound && s != SND_NONE)
|
||||||
{
|
|
||||||
if (override || !Mix_Playing(chan))
|
|
||||||
{
|
{
|
||||||
Mix_PlayChannel(chan, sounds[s], 0);
|
if (override || !Mix_Playing(chan))
|
||||||
|
{
|
||||||
|
Mix_PlayChannel(chan, sounds[s], 0);
|
||||||
|
|
||||||
old_sound[chan] = s;
|
old_sound[chan] = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old_sound[chan] == s)
|
||||||
|
{
|
||||||
|
if (y == SNDDIST_NEAR)
|
||||||
|
dist = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (y < 0)
|
||||||
|
y = 0;
|
||||||
|
else if (y >= screen->h - 1)
|
||||||
|
y = screen->h - 1;
|
||||||
|
|
||||||
|
dist = (255 * ((screen->h - 1) - y)) / (screen->h - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x == SNDPOS_LEFT)
|
||||||
|
left = 255 - dist;
|
||||||
|
else if (x == SNDPOS_CENTER)
|
||||||
|
left = (255 - dist) / 2;
|
||||||
|
else if (x == SNDPOS_RIGHT)
|
||||||
|
left = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (x < 0)
|
||||||
|
x = 0;
|
||||||
|
else if (x >= screen->w)
|
||||||
|
x = screen->w - 1;
|
||||||
|
|
||||||
|
left = ((255 - dist) * ((screen->w - 1) - x)) / (screen->w - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Mix_SetPanning(chan, left, (255 - dist) - left);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_sound[chan] == s)
|
|
||||||
{
|
|
||||||
if (y == SNDDIST_NEAR)
|
|
||||||
dist = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (y < 0)
|
|
||||||
y = 0;
|
|
||||||
else if (y >= screen->h - 1)
|
|
||||||
y = screen->h - 1;
|
|
||||||
|
|
||||||
dist = (255 * ((screen->h - 1) - y)) / (screen->h - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x == SNDPOS_LEFT)
|
|
||||||
left = 255 - dist;
|
|
||||||
else if (x == SNDPOS_CENTER)
|
|
||||||
left = (255 - dist) / 2;
|
|
||||||
else if (x == SNDPOS_RIGHT)
|
|
||||||
left = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (x < 0)
|
|
||||||
x = 0;
|
|
||||||
else if (x >= screen->w)
|
|
||||||
x = screen->w - 1;
|
|
||||||
|
|
||||||
left = ((255 - dist) * ((screen->w - 1) - x)) / (screen->w - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Mix_SetPanning(chan, left, (255 - dist) - left);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@
|
||||||
extern Mix_Chunk *sounds[NUM_SOUNDS];
|
extern Mix_Chunk *sounds[NUM_SOUNDS];
|
||||||
extern int mute, use_sound;
|
extern int mute, use_sound;
|
||||||
|
|
||||||
void playsound(SDL_Surface * screen, int chan, int s, int override, int x,
|
void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y);
|
||||||
int y);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue