home · contact · privacy
Improved formatting and comments for yx_uint16.h
[plomrogue] / src / yx_uint16.h
1 /* yx_uint16.h
2  *
3  * Structs and routines for coordinates and movement in 2-dimensional space
4  * (such as the ncurses screen and game maps).
5  */
6
7 #ifndef YX_UINT16_H
8 #define YX_UINT16_H
9
10
11
12 #include <stdint.h> /* for uint8_t, uint16_t */
13
14
15
16 /* Coordinates for maps of max. 65536x65536 cells. */
17 struct yx_uint16
18 {
19     uint16_t y;
20     uint16_t x;
21 };
22
23
24
25 /* Directions available for movement. */
26 enum dir
27 {
28     NORTH = 1,
29     EAST,
30     SOUTH,
31     WEST
32 };
33
34
35
36 /* Return 1 if two yx_uint16 coordinates at "a" and "b" are equal, else 0. */
37 extern uint8_t yx_uint16_cmp(struct yx_uint16 * a, struct yx_uint16 * b);
38
39
40
41 /* Return yx_uint16 coordinate one step from coordinate yx in direction dir.
42  *
43  * If an invalid dir "d" is passed, "yx" remains unchanged.
44  */
45 extern struct yx_uint16 mv_yx_in_dir(enum dir d, struct yx_uint16 yx);
46
47
48
49 #endif