-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontroller.h
40 lines (32 loc) · 843 Bytes
/
controller.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
#ifndef CONTROLLER_H
#define CONTROLLER_H
/* Controller:
*
* the immediate "will" of a ship.
* 1- Directly wired to keyboard for human players,
* 2- The result of AI decision making procedure,
* 3- In a LAN, with deterministic lockstep: what is communicated between clients
* 4- For e.g. a replay: what is saved for each player per-frame to record an "action"
*
* (3 and 4: TODO)
*
*/
struct ShipController{
enum {LEFT, RIGHT, GO, FIRE , N_STATUS};
bool status[ N_STATUS ];
void reset(){
for (int i=0; i<N_STATUS; i++) status[i]=false;
}
int key[ N_STATUS ]; // which key controls this catus
ShipController(){
reset();
}
void soakKey( int newKey , bool newStatus){
for (int i=0; i<N_STATUS; i++) {
if (key[i]==newKey) status[i]=newStatus;
}
}
void useWASD();
void useArrows();
};
#endif // CONTROLLER_H