ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
direction.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA4_MAP_DIRECTION_H
23 #define ULTIMA4_MAP_DIRECTION_H
24 
25 namespace Ultima {
26 namespace Ultima4 {
27 
28 enum Direction {
29  DIR_NONE,
30  DIR_WEST,
31  DIR_NORTH,
32  DIR_EAST,
33  DIR_SOUTH,
34  DIR_ADVANCE,
35  DIR_RETREAT
36 };
37 
38 #define MASK_DIR(dir) (1 << (dir))
39 #define MASK_DIR_WEST (1 << DIR_WEST)
40 #define MASK_DIR_NORTH (1 << DIR_NORTH)
41 #define MASK_DIR_EAST (1 << DIR_EAST)
42 #define MASK_DIR_SOUTH (1 << DIR_SOUTH)
43 #define MASK_DIR_ADVANCE (1 << DIR_ADVANCE)
44 #define MASK_DIR_RETREAT (1 << DIR_RETREAT)
45 #define MASK_DIR_ALL (MASK_DIR_WEST | MASK_DIR_NORTH | MASK_DIR_EAST | MASK_DIR_EAST | MASK_DIR_SOUTH | MASK_DIR_ADVANCE | MASK_DIR_RETREAT)
46 
47 #define DIR_IN_MASK(dir,mask) ((1 << (dir)) & (mask))
48 #define DIR_ADD_TO_MASK(dir,mask) ((1 << (dir)) | (mask))
49 #define DIR_REMOVE_FROM_MASK(dir,mask) ((~(1 << (dir))) & (mask))
50 
54 Direction dirReverse(Direction dir);
55 
56 Direction dirFromMask(int dir_mask);
57 Direction dirRotateCW(Direction dir);
58 Direction dirRotateCCW(Direction dir);
59 
65 int dirGetBroadsidesDirs(Direction dir);
66 
71 Direction dirRandomDir(int valid_directions_mask);
72 
79 Direction dirNormalize(Direction orientation, Direction dir);
80 
84 Direction keyToDirection(int key);
85 
89 int directionToKey(Direction dir);
90 
91 } // End of namespace Ultima4
92 } // End of namespace Ultima
93 
94 #endif
Definition: detection.h:27