File: enet_common.h

package info (click to toggle)
allegro5 2%3A5.2.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,820 kB
  • sloc: ansic: 109,795; cpp: 12,976; objc: 4,592; java: 2,845; python: 2,595; javascript: 1,238; sh: 1,008; makefile: 40; xml: 27; pascal: 24
file content (48 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download | duplicates (5)
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
#ifndef ENET_COMMON_H
#define ENET_COMMON_H

#include <allegro5/allegro.h>

#define SCREEN_W 640
#define SCREEN_H 480

#define FPS 30           // framerate
#define PLAYER_SIZE 16   // radius of player circle
#define PLAYER_SPEED 200 // movement rate of player in pixels/sec
#define MAX_PLAYER_COUNT 32
#define DEFAULT_PORT 9234

typedef enum
{
    PLAYER_JOIN,
    PLAYER_LEAVE,
    POSITION_UPDATE,
} MESSAGE_TYPE;

// message sent from client to server
typedef struct
{
    int x; // requested x movement (-1, 0, or 1)
    int y; // requested y movement (-1, 0, or 1)
} ClientMessage;

// message sent from server to client
typedef struct
{
    int player_id;
    MESSAGE_TYPE type;
    int x;               // current position (x)
    int y;               // current position (y)
    ALLEGRO_COLOR color; // valid when type == PLAYER_JOIN
} ServerMessage;

// storage for all players
struct
{
   bool active;
   int x, y;   // current position
   int dx, dy; // direction of movemnt
   ALLEGRO_COLOR color;
} players[MAX_PLAYER_COUNT];

#endif