summary refs log tree commit diff stats
path: root/src/rectangle.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2019-03-16 17:45:16 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2019-03-16 17:45:16 -0400
commit4a03d938451763dfb95b534f9002865e72ea7ec5 (patch)
tree9f2a0f074869009760fc33af5032c6de13da897e /src/rectangle.h
parent57fe8f3c4124819b95164547333a33f4c45eac8d (diff)
downloaddispatcher-4a03d938451763dfb95b534f9002865e72ea7ec5.tar.gz
dispatcher-4a03d938451763dfb95b534f9002865e72ea7ec5.tar.bz2
dispatcher-4a03d938451763dfb95b534f9002865e72ea7ec5.zip
Can click to place tiles in editor now HEAD master
Diffstat (limited to 'src/rectangle.h')
-rw-r--r--src/rectangle.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/rectangle.h b/src/rectangle.h new file mode 100644 index 0000000..7815b56 --- /dev/null +++ b/src/rectangle.h
@@ -0,0 +1,36 @@
1#ifndef RECTANGLE_H_23049366
2#define RECTANGLE_H_23049366
3
4#include "vector.h"
5
6template <typename T>
7class rect {
8public:
9
10 using vector_type = vec2<T>;
11
12 constexpr rect(
13 vector_type pos,
14 vector_type size) :
15 pos(pos),
16 size(size)
17 {
18 }
19
20 const vector_type pos;
21 const vector_type size;
22
23 bool contains(vector_type point) const
24 {
25 return (
26 point.x() >= pos.x() &&
27 point.x() < pos.x() + size.w() &&
28 point.y() >= pos.y() &&
29 point.y() < pos.y() + size.h());
30 }
31
32};
33
34using rect4s = rect<size_t>;
35
36#endif /* end of include guard: RECTANGLE_H_23049366 */