home · contact · privacy
c980693b998bf3156ea70e1f3f5a8df8fc36402b
[plomrogue] / src / yx_uint16.c
1 /* yx_uint16.c */
2
3 #include "yx_uint16.h"
4 #include <stdint.h> /* for uint8_t, uint16_t */
5
6
7
8 extern uint8_t yx_uint16_cmp(struct yx_uint16 * a, struct yx_uint16 * b)
9 {
10     if (a->y == b->y && a->x == b->x)
11     {
12         return 1;
13     }
14     return 0;
15 }
16
17
18
19 extern struct yx_uint16 mv_yx_in_dir(char d, struct yx_uint16 yx)
20 {
21     if      (d == 'N' && yx.y > 0)
22     {
23         yx.y--;
24     }
25     else if (d == 'E' && yx.x < UINT16_MAX)
26     {
27         yx.x++;
28     }
29     else if (d == 'S' && yx.y < UINT16_MAX)
30     {
31         yx.y++;
32     }
33     else if (d == 'W' && yx.x > 0)
34     {
35         yx.x--;
36     }
37     return yx;
38 }