forked from JohnAnthony/TROG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometry.hpp
76 lines (66 loc) · 1.26 KB
/
geometry.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include <string>
#define MAX(x, y) ((x > y) ? x : y )
#define MIN(x, y) ((x < y) ? x : y )
#define LENGTH(X) (sizeof X / sizeof X[0])
#define ABS(x) ((x < 0) ? -x : x)
#define RANDOM_IN_RANGE(min, max) ((rand() % (max - min)) + min)
namespace Direction {
typedef enum {
NORTH,
SOUTH,
EAST,
WEST,
NW,
NE,
SW,
SE,
LAST_DIRECTION
} Type;
}
typedef enum {
HEAD,
BODY,
WEAPON,
SHIELD,
GLOVES,
BOOTS,
RING1,
RING2,
NECK,
LAST_EQUIP_LOCATION
} EquipLocations;
struct Rect {
int x;
int y;
int w;
int h;
};
struct Range {
int start;
int end;
};
class Point {
public:
bool operator==(Point const& other);
int x;
int y;
};
enum Color {
COL_WHITE = 0,
COL_RED = 1,
COL_GREEN = 2,
COL_YELLOW = 3,
COL_BLUE = 4,
COL_PURPLE = 5,
COL_CYAN = 6
};
bool IsOnScreen(Point p);
void Alert(std::string str);
bool BinaryChoice(std::string str, char a, char b);
float CalculateDistance(Point p1, Point p2);
Direction::Type MoveCardinal(Direction::Type turn_to, Direction::Type d);
Point GetRelativePoint(Direction::Type d, Point p);
int DICEROLL(int num, int sz);
#endif