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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#ifndef CONSTANTS_H
#define CONSTANTS_H
#include <sys/types.h>
namespace Constants {
const struct
{
const unsigned int width;
const unsigned int height;
}
field_size = { 16, 16 },
map_size = { 35, 17 },
map_size_pixel = { field_size.width * map_size.width,
field_size.height * map_size.height };
const unsigned int sprite_margin = 2;
const unsigned int sprite_offset = 20;
const unsigned int tick = 250; // ms
extern bool server;
namespace Networking
{
const unsigned int port = 7321;
const unsigned int connection_timeout = 3000;
}
namespace Game
{
const unsigned int bonus_point_value = 100;
const unsigned int point_value = 10;
}
}
namespace Color
{
enum Color
{
none = 0,
red = (1 << 0),
blue = (1 << 1),
green = (1 << 2),
yellow = (1 << 3)
};
/* colororder used in protocol and gui */
const Color order[] =
{ Color::red, Color::blue, Color::green, Color::yellow, Color::none };
}
// constants for data transmission to client
namespace Transmission
{
typedef unsigned int field_t;
typedef unsigned int mask_t;
const field_t none = 0;
const field_t block = (1 << 4);
const field_t point = (1 << 5);
const field_t bonuspoint = (1 << 6);
const field_t pacman = (1 << 7);
const field_t empty = (1 << 8); // explicit empty for update
const field_t direction_none = 0;
const field_t direction_left = (1 << 9);
const field_t direction_right = (1 << 10);
const field_t direction_up = (1 << 11);
const field_t direction_down = (1 << 12);
const mask_t color_mask = Color::none | Color::red | Color::blue | Color::green;
const mask_t type_mask = block | bonuspoint;
const mask_t direction_mask = direction_none | direction_left | direction_right | direction_up | direction_down;
typedef field_t** map_t;
}
#endif // CONSTANTS_H
|