-
Notifications
You must be signed in to change notification settings - Fork 0
/
pause.c
86 lines (66 loc) · 1.34 KB
/
pause.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* See Licensing and Copyright notice in naev.h
*/
/**
* @file pause.c
*
* @brief Handles pausing and resuming the game.
*
* Main trick to pausing/unpausing is to allow things based on time to
* behavie properly when the toolkit opens a window.
*/
#include "pause.h"
#include "naev.h"
#include "player.h"
#include "sound.h"
int paused = 0; /**< is paused? */
int player_paused = 0; /**< Whether the player initiated the pause. */
double dt_mod = 1.; /**< dt modifier. */
/**
* @brief Pauses the game.
*/
void pause_game (void)
{
if (paused)
return; /* already paused */
/* Pause sounds. */
if (player.p != NULL) {
player_soundPause();
sound_pause();
}
paused = 1; /* officially paused */
player_paused = 0;
}
/**
* @brief Unpauses the game.
*/
void unpause_game (void)
{
if (!paused)
return; /* already unpaused */
/* Resume sounds. */
if (player.p != NULL) {
player_soundResume();
sound_resume();
}
paused = 0; /* officially unpaused */
player_paused = 0;
}
/**
* @brief Adjusts the game's dt modifier.
*/
void pause_setSpeed( double mod )
{
dt_mod = mod;
sound_setSpeed( mod );
}
/**
* @brief Pauses the game and marks the pause as player-initiated.
*/
void pause_player (void)
{
if (paused)
return;
pause_game();
player_paused = 1;
}