00001 #ifndef COORD_H 00002 #define COORD_H 00003 00004 bool in_bounds_x(int x); 00005 bool in_bounds_y(int y); 00006 bool in_bounds(int x, int y); 00007 bool map_bounds_x(int x); 00008 bool map_bounds_y(int y); 00009 bool map_bounds(int x, int y); 00010 coord_def random_in_bounds(); 00011 00012 inline bool in_bounds(const coord_def &p) 00013 { 00014 return in_bounds(p.x, p.y); 00015 } 00016 00017 inline bool map_bounds(const coord_def &p) 00018 { 00019 return map_bounds(p.x, p.y); 00020 } 00021 00022 // Checks that a given point is within the map, excluding 'margin' squares at 00023 // the edge of the map. 00024 bool map_bounds_with_margin(coord_def p, int margin); 00025 00026 // Determines if the coordinate is within bounds of an LOS array. 00027 inline bool show_bounds(const coord_def &p) 00028 { 00029 return (p.x >= 0 && p.x < ENV_SHOW_DIAMETER 00030 && p.y >= 0 && p.y < ENV_SHOW_DIAMETER); 00031 } 00032 00033 int grid_distance(const coord_def& p1, const coord_def& p2); 00034 int distance(const coord_def& p1, const coord_def& p2); 00035 bool adjacent(const coord_def& p1, const coord_def& p2); 00036 00037 // Conversion between different coordinate systems. 00038 // XXX: collect all of these here? 00039 00040 coord_def player2grid(const coord_def& pc); 00041 coord_def grid2player(const coord_def& pc); 00042 00043 #endif