aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Rect2i.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/Rect2i.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/Rect2i.cpp')
-rw-r--r--Minecraft.Client/Rect2i.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/Minecraft.Client/Rect2i.cpp b/Minecraft.Client/Rect2i.cpp
new file mode 100644
index 00000000..7cd208ad
--- /dev/null
+++ b/Minecraft.Client/Rect2i.cpp
@@ -0,0 +1,76 @@
+#include "stdafx.h"
+#include "Rect2i.h"
+
+Rect2i::Rect2i(int x, int y, int width, int height)
+{
+ xPos = x;
+ yPos = y;
+ this->width = width;
+ this->height = height;
+}
+
+Rect2i *Rect2i::intersect(const Rect2i *other)
+{
+ int x0 = xPos;
+ int y0 = yPos;
+ int x1 = xPos + width;
+ int y1 = yPos + height;
+
+ int x2 = other->getX();
+ int y2 = other->getY();
+ int x3 = x2 + other->getWidth();
+ int y3 = y2 + other->getHeight();
+
+ xPos = max(x0, x2);
+ yPos = max(y0, y2);
+ width = max(0, min(x1, x3) - xPos);
+ height = max(0, min(y1, y3) - yPos);
+
+ return this;
+}
+
+int Rect2i::getX() const
+{
+ return xPos;
+}
+
+int Rect2i::getY() const
+{
+ return yPos;
+}
+
+void Rect2i::setX(int x)
+{
+ xPos = x;
+}
+
+void Rect2i::setY(int y)
+{
+ yPos = y;
+}
+
+int Rect2i::getWidth() const
+{
+ return width;
+}
+
+int Rect2i::getHeight() const
+{
+ return height;
+}
+
+void Rect2i::setWidth(int width)
+{
+ this->width = width;
+}
+
+void Rect2i::setHeight(int height)
+{
+ this->height = height;
+}
+
+void Rect2i::setPosition(int x, int y)
+{
+ xPos = x;
+ yPos = y;
+} \ No newline at end of file