-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpauseutils.odin
More file actions
47 lines (38 loc) · 870 Bytes
/
pauseutils.odin
File metadata and controls
47 lines (38 loc) · 870 Bytes
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
//Package for pausing and unpausing game
package extra
import rl "vendor:raylib"
@(private)
PauseState :: struct {
timeScale: f32,
isPaused: bool,
}
@(private)
pause_state := PauseState {
isPaused = false,
timeScale = 1.0,
}
//Pauses the game
PauseStart :: proc(){
pause_state.isPaused = true
}
//Unpauses the game
PauseStop :: proc(){
pause_state.isPaused = false
}
//Toggles pausing the game
PauseToggle :: proc(){
pause_state.isPaused = !pause_state.isPaused
}
//Sets game timescale
PauseSetTimeScale :: proc(timeScale: f32){
pause_state.timeScale = timeScale
}
//Checks if the game is paused
PauseCheck :: proc() -> bool{
return pause_state.isPaused
}
//Get the delta time with pausing and slowing down
PauseGetDeltaTime :: proc() -> f32 {
if pause_state.isPaused do return 0.0
return rl.GetFrameTime() * pause_state.timeScale
}