forked from taisei-project/taisei
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.c
42 lines (32 loc) · 1.18 KB
/
global.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
/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (c) 2011-2018, Lukas Weber <[email protected]>.
* Copyright (c) 2012-2018, Andrei Alexeyev <[email protected]>.
*/
#include "taisei.h"
#include "global.h"
Global global;
void init_global(CLIAction *cli) {
memset(&global, 0, sizeof(global));
tsrand_init(&global.rand_game, time(0));
tsrand_init(&global.rand_visual, time(0));
tsrand_switch(&global.rand_visual);
memset(&resources, 0, sizeof(Resources));
memset(&global.replay, 0, sizeof(Replay));
global.replaymode = REPLAY_RECORD;
global.frameskip = cli->frameskip;
if(global.frameskip) {
log_warn("FPS limiter disabled. Gotta go fast! (frameskip = %i)", global.frameskip);
}
fpscounter_reset(&global.fps.logic);
fpscounter_reset(&global.fps.render);
fpscounter_reset(&global.fps.busy);
}
// Inputdevice-agnostic method of checking whether a game control is pressed.
// ALWAYS use this instead of SDL_GetKeyState if you need it.
// XXX: Move this somewhere?
bool gamekeypressed(KeyIndex key) {
return SDL_GetKeyboardState(NULL)[config_get_int(KEYIDX_TO_CFGIDX(key))] || gamepad_game_key_pressed(key);
}