src/direction_type.h
branchnoai
changeset 9723 eee46cb39750
child 9724 b39bc69bb2f2
equal deleted inserted replaced
9722:ebf0ece7d8f6 9723:eee46cb39750
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file direction_type.h Different types to 'show' directions. */
       
     4 
       
     5 #ifndef DIRECTION_TYPE_H
       
     6 #define DIRECTION_TYPE_H
       
     7 
       
     8 #include "core/enum_type.hpp"
       
     9 
       
    10 /**
       
    11  * Defines the 8 directions on the map.
       
    12  *
       
    13  * This enum defines 8 possible directions which are used for
       
    14  * the vehicles in the game. The directions are aligned straight
       
    15  * to the viewport, not to the map. So north points to the top of
       
    16  * your viewport and not rotated by 45 degrees left or right to get
       
    17  * a "north" used in you games.
       
    18  */
       
    19 enum Direction {
       
    20 	DIR_BEGIN = 0,          ///< Used to iterate
       
    21 	DIR_N   = 0,            ///< North
       
    22 	DIR_NE  = 1,            ///< Northeast
       
    23 	DIR_E   = 2,            ///< East
       
    24 	DIR_SE  = 3,            ///< Southeast
       
    25 	DIR_S   = 4,            ///< South
       
    26 	DIR_SW  = 5,            ///< Southwest
       
    27 	DIR_W   = 6,            ///< West
       
    28 	DIR_NW  = 7,            ///< Northwest
       
    29 	DIR_END,                ///< Used to iterate
       
    30 	INVALID_DIR = 0xFF,     ///< Flag for an invalid direction
       
    31 };
       
    32 
       
    33 /** Define basic enum properties */
       
    34 template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR> {};
       
    35 typedef TinyEnumT<Direction> DirectionByte; //typedefing-enumification of Direction
       
    36 
       
    37 
       
    38 /**
       
    39  * Enumeration for the difference between two directions.
       
    40  *
       
    41  * This enumeration is used to mark differences between
       
    42  * two directions. If you get one direction you can align
       
    43  * a second direction in 8 different ways. This enumeration
       
    44  * only contains 6 of these 8 differences, but the remaining
       
    45  * two can be calculated by adding to differences together.
       
    46  * This also means you can add two differences together and
       
    47  * get the difference you really want to get. The difference
       
    48  * of 45 degrees left + the difference of 45 degrees right results in the
       
    49  * difference of 0 degrees.
       
    50  *
       
    51  * @note To get this mentioned addition of direction you must use
       
    52  *       modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
       
    53  * @see ChangeDirDiff(DirDiff, DirDiff)
       
    54  */
       
    55 enum DirDiff {
       
    56 	DIRDIFF_SAME    = 0,    ///< Both directions faces to the same direction
       
    57 	DIRDIFF_45RIGHT = 1,    ///< Angle of 45 degrees right
       
    58 	DIRDIFF_90RIGHT = 2,    ///< Angle of 90 degrees right
       
    59 	DIRDIFF_REVERSE = 4,    ///< One direction is the opposit of the other one
       
    60 	DIRDIFF_90LEFT  = 6,    ///< Angle of 90 degrees left
       
    61 	DIRDIFF_45LEFT  = 7     ///< Angle of 45 degrees left
       
    62 };
       
    63 
       
    64 
       
    65 /**
       
    66  * Enumeration for diagonal directions.
       
    67  *
       
    68  * This enumeration is used for the 4 direction of the tile-edges.
       
    69  */
       
    70 enum DiagDirection {
       
    71 	DIAGDIR_BEGIN = 0,      ///< Used for iterations
       
    72 	DIAGDIR_NE  = 0,        ///< Northeast, upper right on your monitor
       
    73 	DIAGDIR_SE  = 1,        ///< Southeast
       
    74 	DIAGDIR_SW  = 2,        ///< Southwest
       
    75 	DIAGDIR_NW  = 3,        ///< Northwest
       
    76 	DIAGDIR_END,            ///< Used for iterations
       
    77 	INVALID_DIAGDIR = 0xFF, ///< Flag for an invalid DiagDirection
       
    78 };
       
    79 
       
    80 DECLARE_POSTFIX_INCREMENT(DiagDirection);
       
    81 
       
    82 /** Define basic enum properties */
       
    83 template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR> {};
       
    84 typedef TinyEnumT<DiagDirection> DiagDirectionByte; //typedefing-enumification of DiagDirection
       
    85 
       
    86 
       
    87 /**
       
    88  * Enumeration for the difference between to DiagDirection.
       
    89  *
       
    90  * As the DiagDirection only contains 4 possible directions the
       
    91  * difference between two of these directions can only be in 4 ways.
       
    92  * As the DirDiff enumeration the values can be added together and
       
    93  * you will get the resulting difference (use modulo DIAGDIR_END).
       
    94  *
       
    95  * @see DirDiff
       
    96  */
       
    97 enum DiagDirDiff {
       
    98 	DIAGDIRDIFF_SAME    = 0,        ///< Same directions
       
    99 	DIAGDIRDIFF_90RIGHT = 1,        ///< 90 degrees right
       
   100 	DIAGDIRDIFF_REVERSE = 2,        ///< Reverse directions
       
   101 	DIAGDIRDIFF_90LEFT  = 3         ///< 90 degrees left
       
   102 };
       
   103 
       
   104 /** Allow incrementing of DiagDirDiff variables */
       
   105 DECLARE_POSTFIX_INCREMENT(DiagDirDiff);
       
   106 
       
   107 
       
   108 /**
       
   109  * Enumeration for the two axis X and Y
       
   110  *
       
   111  * This enumeration represente the two axis X and Y in the game.
       
   112  * The X axis is the one which goes align the north-west edge
       
   113  * (and south-east edge). The Y axis must be so the one which goes
       
   114  * align the north-east edge (and south-west) edge.
       
   115  */
       
   116 enum Axis {
       
   117 	AXIS_X = 0,     ///< The X axis
       
   118 	AXIS_Y = 1,     ///< The y axis
       
   119 	AXIS_END        ///< Used for iterations
       
   120 };
       
   121 
       
   122 #endif /* DIRECTION_TYPE_H */