home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xconq55.zip / xc5.5 / dir.h < prev    next >
C/C++ Source or Header  |  1991-06-13  |  1KB  |  47 lines

  1. /* Copyright (c) 1987, 1988  Stanley T. Shebs. */
  2. /* This program may be used, copied, modified, and redistributed freely */
  3. /* for noncommercial purposes, so long as this notice remains intact. */
  4.  
  5. /* Definitions for directions of the compass. */
  6.  
  7. /* The terrain model is based on hexes arranged in horizontal rows.  This */
  8. /* means that although east and west remain intact, the concepts of north */
  9. /* and south have basically vanished. */
  10.  
  11. /* Unfortunately, not all hex-dependent definitions are here.  Pathfinding */
  12. /* code has some knowledge of hexes also, as does map generation. */
  13.  
  14. #define NUMDIRS 6
  15.  
  16. #define NE    0
  17. #define EAST  1
  18. #define SE    2
  19. #define SW    3
  20. #define WEST  4
  21. #define NW    5
  22.              
  23. #define DIRNAMES { "NE", "E", "SE", "SW", "W", "NW" }
  24.  
  25. #define DIRX { 0, 1,  1,  0, -1, -1 }
  26. #define DIRY { 1, 0, -1, -1,  0,  1 }
  27.  
  28. #define DIRCHARS "ulnbhy"
  29.  
  30. #define random_dir() (random(NUMDIRS))
  31.  
  32. #define for_all_directions(dir)  for (dir = 0; dir < NUMDIRS; ++dir)
  33.  
  34. #define normalize_dir(d)    (((d)+NUMDIRS)%NUMDIRS)
  35. #define opposite_dir(d) (((d) + 3) % NUMDIRS)
  36. #define    right_of(d)    (((d) + 1) % NUMDIRS)
  37. #define    left_of(d)    (((d) + NUMDIRS - 1) % NUMDIRS)
  38.  
  39. extern char *dirnames[];
  40.  
  41. extern int dirx[], diry[];
  42.  
  43.  
  44.  
  45.  
  46.  
  47.