KTech 1.1.0
C++ 2D terminal game engine library
Loading...
Searching...
No Matches
upoint.hpp
1/*
2 KTech, Kaup's C++ 2D terminal game engine library.
3 Copyright (C) 2023-2025 Ethan Kaufman (AKA Kaup)
4
5 This file is part of KTech.
6
7 KTech is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 any later version.
11
12 KTech is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with KTech. If not, see <https://www.gnu.org/licenses/>.
19*/
20
21#pragma once
22
23#define KTECH_DEFINITION
24#include "../ktech.hpp"
25#undef KTECH_DEFINITION
26
29{
30 uint32_t x;
31 uint32_t y;
32
38 constexpr UPoint(uint32_t x = 0, uint32_t y = 0)
39 : x(x), y(y) {}
40
46 constexpr auto operator==(const UPoint& uPoint) const -> bool
47 {
48 return (x == uPoint.x) && (y == uPoint.y);
49 }
50
56 constexpr auto operator+(const UPoint& uPoint) const -> UPoint
57 {
58 return {x + uPoint.x, y + uPoint.y};
59 }
60
66 constexpr auto operator-(const UPoint& uPoint) const -> UPoint
67 {
68 return {x - uPoint.x, y - uPoint.y};
69 }
70
76 constexpr auto operator+=(const UPoint& uPoint) -> UPoint&
77 {
78 x += uPoint.x;
79 y += uPoint.y;
80 return *this;
81 }
82
88 constexpr auto operator-=(const UPoint& uPoint) -> UPoint&
89 {
90 x -= uPoint.x;
91 y -= uPoint.y;
92 return *this;
93 }
94};
Unsigned 2D vector, mostly used to store sizes and 2D indexes.
Definition upoint.hpp:29
constexpr auto operator-(const UPoint &uPoint) const -> UPoint
Subtract UPoint from another.
Definition upoint.hpp:66
uint32_t y
Y axis.
Definition upoint.hpp:31
constexpr auto operator==(const UPoint &uPoint) const -> bool
Compare 2 UPoints.
Definition upoint.hpp:46
constexpr auto operator+(const UPoint &uPoint) const -> UPoint
Add 2 UPoints together.
Definition upoint.hpp:56
uint32_t x
X axis.
Definition upoint.hpp:30
constexpr auto operator-=(const UPoint &uPoint) -> UPoint &
Subtract a UPoint from this UPoint.
Definition upoint.hpp:88
constexpr auto operator+=(const UPoint &uPoint) -> UPoint &
Add a UPoint to this UPoint.
Definition upoint.hpp:76
constexpr UPoint(uint32_t x=0, uint32_t y=0)
Construct a UPoint.
Definition upoint.hpp:38