Pause audio when pausing game / viewing radar.

This commit is contained in:
Steve 2018-02-28 07:52:38 +00:00
parent 6b246971b3
commit c98e93ee2b
5 changed files with 18 additions and 0 deletions

View File

@ -76,6 +76,18 @@ void playSound(int snd, int ch)
Mix_PlayChannel(ch, sounds[snd], 0); Mix_PlayChannel(ch, sounds[snd], 0);
} }
void pauseSound(int pause)
{
if (pause)
{
Mix_Pause(-1);
}
else
{
Mix_Resume(-1);
}
}
void playBattleSound(int snd, int channel, int x, int y) void playBattleSound(int snd, int channel, int x, int y)
{ {
float distance, bearing, vol; float distance, bearing, vol;

View File

@ -208,6 +208,7 @@ static void logic(void)
if (isControl(CONTROL_MAP)) if (isControl(CONTROL_MAP))
{ {
pauseSound(0);
clearControl(CONTROL_MAP); clearControl(CONTROL_MAP);
exitRadar(); exitRadar();
} }

View File

@ -50,6 +50,7 @@ extern int isControl(int type);
extern void clearControl(int type); extern void clearControl(int type);
extern void startSectionTransition(void); extern void startSectionTransition(void);
extern void endSectionTransition(void); extern void endSectionTransition(void);
extern void pauseSound(int pause);
extern App app; extern App app;
extern Colors colors; extern Colors colors;

View File

@ -355,11 +355,13 @@ static void doWorldInProgress(void)
if (isControl(CONTROL_PAUSE)) if (isControl(CONTROL_PAUSE))
{ {
world.state = WS_PAUSED; world.state = WS_PAUSED;
pauseSound(1);
clearControl(CONTROL_PAUSE); clearControl(CONTROL_PAUSE);
} }
if (isControl(CONTROL_MAP)) if (isControl(CONTROL_MAP))
{ {
pauseSound(1);
initRadar(); initRadar();
clearControl(CONTROL_MAP); clearControl(CONTROL_MAP);
} }
@ -472,6 +474,7 @@ static void doWorldPaused(void)
if (isControl(CONTROL_PAUSE)) if (isControl(CONTROL_PAUSE))
{ {
pauseSound(0);
world.state = WS_IN_PROGRESS; world.state = WS_IN_PROGRESS;
clearControl(CONTROL_PAUSE); clearControl(CONTROL_PAUSE);
} }

View File

@ -111,6 +111,7 @@ extern void retryMission(void);
extern void returnToHub(void); extern void returnToHub(void);
extern void returnToTitle(void); extern void returnToTitle(void);
extern void playBattleSound(int snd, int ch, int x, int y); extern void playBattleSound(int snd, int ch, int x, int y);
extern void pauseSound(int pause);
extern App app; extern App app;
extern Colors colors; extern Colors colors;