From ce48af53646cd9e7ec762fc1ac176b3aa620b11d Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 5 May 2011 00:57:07 +0200 Subject: - refactorized the whole project and made a few subprojects - replaced tcp with enet - added connect dialog - some smaller bugfixes --- pacman-c++/common/constants.h | 102 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 pacman-c++/common/constants.h (limited to 'pacman-c++/common/constants.h') diff --git a/pacman-c++/common/constants.h b/pacman-c++/common/constants.h new file mode 100644 index 0000000..d40c39e --- /dev/null +++ b/pacman-c++/common/constants.h @@ -0,0 +1,102 @@ +#ifndef CONSTANTS_H +#define CONSTANTS_H +#include + +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; + const unsigned int packet_timeout = 3000; + } + + namespace Game + { + const unsigned int bonus_point_value = 100; + const unsigned int point_value = 10; + /* players will be placed with this minimum manhattan distance */ + const unsigned int player_minimum_distance = 5; + /* if the distance above isn't possible, decrease the distance by this value */ + const unsigned int player_distance_decr = 2; + /* there's a chance of 1:30 that a bonus point will be added (with one actor) */ + const unsigned int bouns_point_chance = 30; + /* every additional player will raise the chance of a bonus point by that factor */ + const unsigned int bouns_point_chance_playerfactor = 3; + /* there's a chance of 1:5 that a block will be colorized */ + const unsigned int colorize_block_chance = 5; + /* how long colorized blocks will stay colorized */ + const unsigned int colorize_block_tickcount_min = 50; + const unsigned int colorize_block_tickcount_max = 100; + } + + namespace AI + { + /* bots minimum manhatten distance before other players will be recognized */ + const unsigned int player_minimum_distance = 4; + /* weight values used to determine new direction of bot */ + const unsigned int weight_afraid = 50; + const unsigned int weight_hunt = 10; + const unsigned int weight_bonus_point = 3; + const unsigned int weight_point = 1; + const unsigned int weight_colorblock = 5; + } +} + +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 death = (1 << 9); + + const field_t direction_none = 0; + const field_t direction_left = (1 << 10); + const field_t direction_right = (1 << 11); + const field_t direction_up = (1 << 12); + const field_t direction_down = (1 << 13); + + const mask_t color_mask = Color::none | Color::red | Color::blue | Color::green | Color::yellow; + 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 -- cgit v1.2.3