1 #ifndef ENET_COMMON_H
2 #define ENET_COMMON_H
3 
4 #include <allegro5/allegro.h>
5 
6 #define SCREEN_W 640
7 #define SCREEN_H 480
8 
9 #define FPS 30           // framerate
10 #define PLAYER_SIZE 16   // radius of player circle
11 #define PLAYER_SPEED 200 // movement rate of player in pixels/sec
12 #define MAX_PLAYER_COUNT 32
13 #define DEFAULT_PORT 9234
14 
15 typedef enum
16 {
17     PLAYER_JOIN,
18     PLAYER_LEAVE,
19     POSITION_UPDATE,
20 } MESSAGE_TYPE;
21 
22 // message sent from client to server
23 typedef struct
24 {
25     int x; // requested x movement (-1, 0, or 1)
26     int y; // requested y movement (-1, 0, or 1)
27 } ClientMessage;
28 
29 // message sent from server to client
30 typedef struct
31 {
32     int player_id;
33     MESSAGE_TYPE type;
34     int x;               // current position (x)
35     int y;               // current position (y)
36     ALLEGRO_COLOR color; // valid when type == PLAYER_JOIN
37 } ServerMessage;
38 
39 // storage for all players
40 struct
41 {
42    bool active;
43    int x, y;   // current position
44    int dx, dy; // direction of movemnt
45    ALLEGRO_COLOR color;
46 } players[MAX_PLAYER_COUNT];
47 
48 #endif
49