Add pause function
This commit is contained in:
parent
b65b742403
commit
1ec5502d46
1 changed files with 9 additions and 1 deletions
|
@ -46,6 +46,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
static bool paused = false;
|
||||
static float speed = 1.0;
|
||||
static unsigned previous_ticks = 0;
|
||||
|
||||
|
@ -98,7 +99,10 @@ static void check_reload(void) {}
|
|||
|
||||
static void update(void) {
|
||||
unsigned ticks = SDL_GetTicks();
|
||||
|
||||
if (!paused)
|
||||
current_time += speed * (ticks - previous_ticks);
|
||||
|
||||
previous_ticks = ticks;
|
||||
}
|
||||
|
||||
|
@ -151,6 +155,10 @@ static void handle_input(const char *input) {
|
|||
case '>':
|
||||
if (speed < 0)
|
||||
set_speed(-speed);
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
paused = !paused;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue