-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameControls.h
61 lines (51 loc) · 1.29 KB
/
GameControls.h
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
#ifndef _GAME_CONT_H
#define _GAME_CONT_H
#include <SDL_events.h>
typedef struct GameControlEvent {
enum {
kGameNone,
kPauseGame,
kPlayer1Left,
kPlayer1Right,
kPlayer1TurnLeft,
kPlayer1TurnRight,
kPlayer1Down,
kPlayer2Left,
kPlayer2Right,
kPlayer2TurnLeft,
kPlayer2TurnRight,
kPlayer2Down,
kGameLastKey
} gameEvent;
enum {
kCursorNone,
kUp,
kDown,
kLeft,
kRight,
kStart,
kBack,
kQuit,
kCursorLastKey
} cursorEvent;
bool isUp;
} GameControlEvent;
enum {
kPlayer1LeftControl = 0,
kPlayer1RightControl = 1,
kPlayer1DownControl = 2,
kPlayer1ClockwiseControl = 3,
kPlayer1CounterclockwiseControl = 4,
kPlayer2LeftControl = 5,
kPlayer2RightControl = 6,
kPlayer2DownControl = 7,
kPlayer2ClockwiseControl = 8,
kPlayer2CounterclockwiseControl = 9
};
void initGameControls();
void getControlEvent(SDL_Event e, GameControlEvent *result);
void getKeyName(int control, char *keyName);
bool tryChangeControl(int control, SDL_Event e, GameControlEvent *result);
void saveControls();
void loadControls();
#endif