the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "Rect2i.h"
3
4Rect2i::Rect2i(int x, int y, int width, int height)
5{
6 xPos = x;
7 yPos = y;
8 this->width = width;
9 this->height = height;
10}
11
12Rect2i *Rect2i::intersect(const Rect2i *other)
13{
14 int x0 = xPos;
15 int y0 = yPos;
16 int x1 = xPos + width;
17 int y1 = yPos + height;
18
19 int x2 = other->getX();
20 int y2 = other->getY();
21 int x3 = x2 + other->getWidth();
22 int y3 = y2 + other->getHeight();
23
24 xPos = max(x0, x2);
25 yPos = max(y0, y2);
26 width = max(0, min(x1, x3) - xPos);
27 height = max(0, min(y1, y3) - yPos);
28
29 return this;
30}
31
32int Rect2i::getX() const
33{
34 return xPos;
35}
36
37int Rect2i::getY() const
38{
39 return yPos;
40}
41
42void Rect2i::setX(int x)
43{
44 xPos = x;
45}
46
47void Rect2i::setY(int y)
48{
49 yPos = y;
50}
51
52int Rect2i::getWidth() const
53{
54 return width;
55}
56
57int Rect2i::getHeight() const
58{
59 return height;
60}
61
62void Rect2i::setWidth(int width)
63{
64 this->width = width;
65}
66
67void Rect2i::setHeight(int height)
68{
69 this->height = height;
70}
71
72void Rect2i::setPosition(int x, int y)
73{
74 xPos = x;
75 yPos = y;
76}