-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.cpp
44 lines (34 loc) · 809 Bytes
/
util.cpp
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
#include "util.hpp"
std::ostream& operator <<(std::ostream& out, const SDL_Rect& r)
{
return out << "SDL_Rect{" << r.x << ", " << r.y << ", " << r.w << ", " << r.h << "}";
}
V2::V2(int x, int y)
: x(x), y(y) { }
V2::V2(int s)
: x(s), y(s) { }
bool V2::in(SDL_Rect r) const
{
SDL_Point p{x, y};
return SDL_PointInRect(&p, &r);
}
V2 V2::operator +(const V2& other) const
{
return {x + other.x, y + other.y};
}
V2g::V2g(int s)
: x(s), y(s) { }
V2g::V2g(int x, int y)
: x(x), y(y) { }
bool V2g::operator ==(const V2g& other) const
{
return x == other.x && y == other.y;
}
bool V2g::operator !=(const V2g& other) const
{
return x != other.x || y != other.y;
}
std::ostream& operator <<(std::ostream& out, const V2g gpos)
{
return out << "V2g{" << gpos.x << ", " << gpos.y << "}";
}