aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/data/bounds.cpp24
-rw-r--r--src/engine/data/bounds.hpp8
-rw-r--r--src/engine/data/vector2.cpp16
-rw-r--r--src/engine/data/vector2.hpp33
-rw-r--r--src/engine/graphics/string_matrix.cpp10
-rw-r--r--src/engine/user/cursor.cpp4
6 files changed, 38 insertions, 57 deletions
diff --git a/src/engine/data/bounds.cpp b/src/engine/data/bounds.cpp
index cd08a02..fbd7ec4 100644
--- a/src/engine/data/bounds.cpp
+++ b/src/engine/data/bounds.cpp
@@ -5,34 +5,34 @@ Bounds::Bounds(const BoundsOptions &options)
{
}
-uint32_t Bounds::width() const noexcept
+uint32_t Bounds::get_width() const noexcept
{
return _width;
}
-void Bounds::width(uint32_t width) noexcept
+void Bounds::set_width(uint32_t width) noexcept
{
_width = width;
}
-uint32_t Bounds::height() const noexcept
+uint32_t Bounds::get_height() const noexcept
{
return _height;
}
-void Bounds::height(uint32_t height) noexcept
+void Bounds::set_height(uint32_t height) noexcept
{
_height = height;
}
CoordsValidation Bounds::validate_coords(const Vector2 &coords) const noexcept
{
- if (coords.x() >= _width)
+ if (coords.get_x() >= _width)
{
return CoordsValidation::X_HIGH;
}
- if (coords.y() >= _height)
+ if (coords.get_y() >= _height)
{
return CoordsValidation::Y_HIGH;
}
@@ -42,24 +42,24 @@ CoordsValidation Bounds::validate_coords(const Vector2 &coords) const noexcept
const Bounds &Bounds::operator*=(const Bounds &bounds) noexcept
{
- _width *= bounds.width();
- _height *= bounds.height();
+ _width *= bounds._width;
+ _height *= bounds._height;
return *this;
}
const Bounds &Bounds::operator+=(const Bounds &bounds) noexcept
{
- _width += bounds.width();
- _height += bounds.height();
+ _width += bounds._width;
+ _height += bounds._height;
return *this;
}
const Bounds &Bounds::operator-=(const Bounds &bounds) noexcept
{
- _width -= bounds.width();
- _height -= bounds.height();
+ _width -= bounds._width;
+ _height -= bounds._height;
return *this;
}
diff --git a/src/engine/data/bounds.hpp b/src/engine/data/bounds.hpp
index 1875bf4..b29005e 100644
--- a/src/engine/data/bounds.hpp
+++ b/src/engine/data/bounds.hpp
@@ -22,13 +22,13 @@ class Bounds
public:
explicit Bounds(const BoundsOptions &options);
- [[nodiscard]] uint32_t width() const noexcept;
+ [[nodiscard]] uint32_t get_width() const noexcept;
- void width(uint32_t width) noexcept;
+ void set_width(uint32_t width) noexcept;
- [[nodiscard]] uint32_t height() const noexcept;
+ [[nodiscard]] uint32_t get_height() const noexcept;
- void height(uint32_t height) noexcept;
+ void set_height(uint32_t height) noexcept;
[[nodiscard]] CoordsValidation validate_coords(const Vector2 &coords) const noexcept;
diff --git a/src/engine/data/vector2.cpp b/src/engine/data/vector2.cpp
index 5d42913..7a22d62 100644
--- a/src/engine/data/vector2.cpp
+++ b/src/engine/data/vector2.cpp
@@ -2,38 +2,38 @@
Vector2::Vector2(const Vector2Options &options) : _x(options.x), _y(options.y) {}
-uint32_t Vector2::x() const noexcept
+uint32_t Vector2::get_x() const noexcept
{
return _x;
}
-void Vector2::x(uint32_t x) noexcept
+void Vector2::set_x(uint32_t x) noexcept
{
_x = x;
}
-uint32_t Vector2::y() const noexcept
+uint32_t Vector2::get_y() const noexcept
{
return _y;
}
-void Vector2::y(uint32_t y) noexcept
+void Vector2::set_y(uint32_t y) noexcept
{
_y = y;
}
const Vector2 &Vector2::operator+=(const Vector2 &vector2) noexcept
{
- _x += vector2.x();
- _y += vector2.y();
+ _x += vector2._x;
+ _y += vector2._y;
return *this;
}
const Vector2 &Vector2::operator-=(const Vector2 &vector2) noexcept
{
- _x -= vector2.x();
- _y -= vector2.y();
+ _x -= vector2._x;
+ _y -= vector2._y;
return *this;
}
diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp
index 580123c..a7896ef 100644
--- a/src/engine/data/vector2.hpp
+++ b/src/engine/data/vector2.hpp
@@ -14,34 +14,15 @@ struct Vector2Options
class Vector2
{
public:
- /**
- * Creates a 2D vector.
- */
explicit Vector2(const Vector2Options &options);
- /**
- * Returns the X coordinate.
- */
- [[nodiscard]] uint32_t x() const noexcept;
-
- /**
- * Sets the X coordinate.
- *
- * @param x A new X coordinate
- */
- void x(uint32_t x) noexcept;
-
- /**
- * Returns the Y coordinate.
- */
- [[nodiscard]] uint32_t y() const noexcept;
-
- /**
- * Sets the Y coordinate.
- *
- * @param Y A new Y coordinate
- */
- void y(uint32_t y) noexcept;
+ [[nodiscard]] uint32_t get_x() const noexcept;
+
+ void set_x(uint32_t x) noexcept;
+
+ [[nodiscard]] uint32_t get_y() const noexcept;
+
+ void set_y(uint32_t y) noexcept;
const Vector2 &operator+=(const Vector2 &vector2) noexcept;
const Vector2 &operator-=(const Vector2 &vector2) noexcept;
diff --git a/src/engine/graphics/string_matrix.cpp b/src/engine/graphics/string_matrix.cpp
index aae2b9d..75d3700 100644
--- a/src/engine/graphics/string_matrix.cpp
+++ b/src/engine/graphics/string_matrix.cpp
@@ -1,10 +1,10 @@
#include "string_matrix.hpp"
StringMatrix::StringMatrix(const Bounds &bounds)
- : _rows(bounds.height()), _columns(bounds.width())
+ : _rows(bounds.get_height()), _columns(bounds.get_width())
{
- _matrix.reserve(bounds.height());
- _matrix.assign(_matrix.capacity(), std::vector<std::string_view>(bounds.width()));
+ _matrix.reserve(bounds.get_height());
+ _matrix.assign(_matrix.capacity(), std::vector<std::string_view>(bounds.get_width()));
};
void StringMatrix::fill(std::string_view element)
@@ -22,12 +22,12 @@ void StringMatrix::fill(std::string_view element)
std::string_view StringMatrix::get(const Vector2 &pos) const
{
- return _matrix[pos.y()][pos.x()];
+ return _matrix[pos.get_y()][pos.get_x()];
}
void StringMatrix::set(const Vector2 &pos, std::string_view element)
{
- _matrix[pos.y()][pos.x()] = element;
+ _matrix[pos.get_y()][pos.get_x()] = element;
}
unsigned int StringMatrix::rows() const
diff --git a/src/engine/user/cursor.cpp b/src/engine/user/cursor.cpp
index d4a2997..44e24dc 100644
--- a/src/engine/user/cursor.cpp
+++ b/src/engine/user/cursor.cpp
@@ -7,8 +7,8 @@
void CursorController::move_to(const Vector2 &pos)
{
- fmt::print(MOVE_CURSOR_TO, fmt::arg("esc", ESC), fmt::arg("row", pos.y()),
- fmt::arg("column", pos.x()));
+ fmt::print(MOVE_CURSOR_TO, fmt::arg("esc", ESC), fmt::arg("row", pos.get_y()),
+ fmt::arg("column", pos.get_x()));
std::cout.flush();
}