Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

dir.h File Reference

Definitions for the directions of the compass. More...

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define NUMDIRS   6
 Number of directions.

#define NODIR   -1
#define NORTHEAST   0
#define EAST   1
#define SOUTHEAST   2
#define SOUTHWEST   3
#define WEST   4
#define NORTHWEST   5
#define DIRNAMES   { "NE", "E", "SE", "SW", "W", "NW" }
 String names for the directions.

#define DIRX   { 0, 1, 1, 0, -1, -1 }
 Conversions from directions to x,y deltas.

#define DIRY   { 1, 0, -1, -1, 0, 1 }
#define for_all_directions(dir)   for ((dir) = 0; (dir) < NUMDIRS; ++(dir))
 Iteration over the different directions.

#define for_all_directions_randomly(dir, tmp)   for ((tmp) = 0, (dir) = xrandom(NUMDIRS); (tmp) < NUMDIRS; ++(tmp), (dir) = ((dir) + 1) % NUMDIRS)
#define left_dir(d)   (((d) + 5) % NUMDIRS)
 Formulas for relative directions to the left.

#define right_dir(d)   (((d) + 1) % NUMDIRS)
 Formulas for relative directions to the right.

#define opposite_dir(d)   (((d) + 3) % NUMDIRS)
 Oposite direction.

#define dir_subtract(d1, d2)   (((d1) - (d2) + NUMDIRS) % NUMDIRS)
 Difference in directions.

#define angle_with(d1, d2)   min(((d1) - (d2) + NUMDIRS) % NUMDIRS, ((d2) - (d1) + NUMDIRS) % NUMDIRS)
 Smallest difference in directions.

#define random_dir()   (xrandom(NUMDIRS))
 Generate random direction.


Variables

char * dirnames []
 Direction name array.

int dirx []
 X delta array.

int diry []


Detailed Description

Definitions for the directions of the compass.

The terrain model is based on hexes arranged in horizontal rows. This means that although east and west remain intact, the concepts of north and south have vanished. Unfortunately, not all hex-dependent definitions are here. Pathfinding code has some knowledge of hexes also, as does map generation and probably parts of the machine player code.


Define Documentation

#define angle_with d1,
d2   )     min(((d1) - (d2) + NUMDIRS) % NUMDIRS, ((d2) - (d1) + NUMDIRS) % NUMDIRS)
 

Smallest difference in directions.

This macro looks for the smallest difference, going each way.

Parameters:
d1 is the first direction.
d2 is the second direction.

#define dir_subtract d1,
d2   )     (((d1) - (d2) + NUMDIRS) % NUMDIRS)
 

Difference in directions.

Compute the difference between two directions, always computing relative to the first direction.

Parameters:
d1 is the first direction.
d2 is the second direction.

#define DIRNAMES   { "NE", "E", "SE", "SW", "W", "NW" }
 

String names for the directions.

#define DIRX   { 0, 1, 1, 0, -1, -1 }
 

Conversions from directions to x,y deltas.

#define DIRY   { 1, 0, -1, -1, 0, 1 }
 

#define EAST   1
 

#define for_all_directions dir   )     for ((dir) = 0; (dir) < NUMDIRS; ++(dir))
 

Iteration over the different directions.

Iterate through all six directions, going from NORTHEAST to NORTHWEST.

Parameters:
dir is the direction iteration variable.

#define for_all_directions_randomly dir,
tmp   )     for ((tmp) = 0, (dir) = xrandom(NUMDIRS); (tmp) < NUMDIRS; ++(tmp), (dir) = ((dir) + 1) % NUMDIRS)
 

#define left_dir  )     (((d) + 5) % NUMDIRS)
 

Formulas for relative directions to the left.

Parameters:
d is the direction to turn.

#define NODIR   -1
 

#define NORTHEAST   0
 

#define NORTHWEST   5
 

#define NUMDIRS   6
 

Number of directions.

#define opposite_dir  )     (((d) + 3) % NUMDIRS)
 

Oposite direction.

Formula for generating the opposite direction to the given direction.

Parameters:
d is the direction for which to find the opposite direction.

 
#define random_dir  )     (xrandom(NUMDIRS))
 

Generate random direction.

Generates a random direction.

See also:
xrandom, NUMDIRS.

#define right_dir  )     (((d) + 1) % NUMDIRS)
 

Formulas for relative directions to the right.

Parameters:
d is the direction to turn.

#define SOUTHEAST   2
 

#define SOUTHWEST   3
 

#define WEST   4
 


Variable Documentation

char* dirnames[]
 

Direction name array.

int dirx[]
 

X delta array.

int diry[]
 


Generated on Sat Sep 17 10:29:08 2005 for XconqKernel by doxygen 1.3.6