KTech 1.1.0
C++ 2D terminal game engine library
Loading...
Searching...
No Matches
KTech::Point Struct Reference

2D vector, mostly used to store positions and directions. More...

#include <point.hpp>

Public Member Functions

constexpr Point (int32_t x=0, int32_t y=0)
 Construct a Point.
 
constexpr Point (const UPoint &uPoint)
 Construct a Point from a UPoint.
 
constexpr auto operator== (const Point &point) const -> bool
 Compare 2 Points.
 
constexpr auto operator+ (const Point &point) const -> Point
 Add 2 Points together.
 
constexpr auto operator- (const Point &point) const -> Point
 Subtract Point from another.
 
constexpr auto operator+= (const Point &point) -> Point &
 Add a Point to this Point.
 
constexpr auto operator-= (const Point &point) -> Point &
 Subtract a Point from this Point.
 

Public Attributes

int32_t x
 X axis (+ right, - left).
 
int32_t y
 Y axis (+ down, - up).
 

Detailed Description

2D vector, mostly used to store positions and directions.

Constructor & Destructor Documentation

◆ Point() [1/2]

KTech::Point::Point ( int32_t x = 0,
int32_t y = 0 )
inlineconstexpr

Construct a Point.

Parameters
[in]xX axis.
[in]yY axis.

◆ Point() [2/2]

KTech::Point::Point ( const UPoint & uPoint)
inlineconstexpr

Construct a Point from a UPoint.

Parameters
[in]uPointBase UPoint.

Member Function Documentation

◆ operator+()

auto KTech::Point::operator+ ( const Point & point) const -> Point
inlineconstexpr

Add 2 Points together.

Parameters
[in]pointThe Point to add with this Point.
Returns
New Point with the sum of the 2 Points.

◆ operator+=()

auto KTech::Point::operator+= ( const Point & point) -> Point&
inlineconstexpr

Add a Point to this Point.

Parameters
[in]pointThe Point to add to this Point.
Returns
Self-reference (for function chaining).

◆ operator-()

auto KTech::Point::operator- ( const Point & point) const -> Point
inlineconstexpr

Subtract Point from another.

Parameters
[in]pointThe Point to subtract from this Point.
Returns
New Point with the difference between the 2 Points.

◆ operator-=()

auto KTech::Point::operator-= ( const Point & point) -> Point&
inlineconstexpr

Subtract a Point from this Point.

Parameters
[in]pointThe Point to subtract from this Point.
Returns
Self-reference (for function chaining).

◆ operator==()

auto KTech::Point::operator== ( const Point & point) const -> bool
inlineconstexpr

Compare 2 Points.

Parameters
[in]pointThe Point to compare with this Point.
Returns
true: the X and Y axes are equal. false: they are unequal.

The documentation for this struct was generated from the following file: