Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
KatanaEngine::Point Class Reference

Defines a point in 2D space. More...

#include <Point.h>

Public Member Functions

 Point (const int x=0, const int y=0)
 Instantiates a new point object.
 
 ~Point ()
 
void Set (const int x, const int y)
 Sets the components of the point.
 
void Set (const Point point)
 Sets the components of the vecpointtor.
 
bool IsOrigin () const
 Determines if the point is located at the origin.
 
const Vector2 ToVector2 () const
 Converts the point into a vector.
 
std::string ToString () const
 Gets a string representation of the point.
 
void Display () const
 Prints the point to the console.
 
Pointoperator= (const Point &point)
 Assigns the reference of a point.
 
Pointoperator+= (const Point &point)
 Adds a point.
 
Pointoperator-= (const Point &point)
 Subtracts a point.
 
const Point operator+ (const Point &point) const
 Adds two points.
 
const Point operator- (const Point &point) const
 Subtracts a point from another.
 
bool operator== (const Point &point) const
 Determines if two points are equal.
 
bool operator!= (const Point &point) const
 Determines if two points are not equal.
 

Public Attributes

int X = 0
 The x-coordinate of the point.
 
int Y = 0
 The y-coordinate of the point.
 

Static Public Attributes

static const Point Origin = Point(0, 0)
 A point located at the origin.
 

Detailed Description

Defines a point in 2D space.

Definition at line 22 of file Point.h.

Constructor & Destructor Documentation

◆ Point()

KatanaEngine::Point::Point ( const int x = 0,
const int y = 0 )

Instantiates a new point object.

Parameters
xThe X component
yThe Y component

Definition at line 22 of file Point.cpp.

◆ ~Point()

KatanaEngine::Point::~Point ( )
inline

Definition at line 31 of file Point.h.

Member Function Documentation

◆ Display()

void KatanaEngine::Point::Display ( ) const
inline

Prints the point to the console.

Definition at line 61 of file Point.h.

◆ IsOrigin()

bool KatanaEngine::Point::IsOrigin ( ) const
inline

Determines if the point is located at the origin.

Returns
Returns true if both components are zero, false otherwise.

Definition at line 50 of file Point.h.

◆ operator!=()

bool KatanaEngine::Point::operator!= ( const Point & point) const

Determines if two points are not equal.

Parameters
pointThe point to compare.
Returns
Returns true if the points are not equal, false otherwise.

Definition at line 89 of file Point.cpp.

◆ operator+()

const Point KatanaEngine::Point::operator+ ( const Point & point) const

Adds two points.

Parameters
pointThe point to add.
Returns
Returns the resulting point.

Definition at line 74 of file Point.cpp.

◆ operator+=()

Point & KatanaEngine::Point::operator+= ( const Point & point)

Adds a point.

Parameters
pointThe point to add.
Returns
Returns the resulting point.

Definition at line 58 of file Point.cpp.

◆ operator-()

const Point KatanaEngine::Point::operator- ( const Point & point) const

Subtracts a point from another.

Parameters
pointThe point to subtract.
Returns
Returns the resulting point.

Definition at line 79 of file Point.cpp.

◆ operator-=()

Point & KatanaEngine::Point::operator-= ( const Point & point)

Subtracts a point.

Parameters
pointThe point to subtract.
Returns
Returns the resulting point.

Definition at line 66 of file Point.cpp.

◆ operator=()

Point & KatanaEngine::Point::operator= ( const Point & point)

Assigns the reference of a point.

Parameters
pointThe reference point.
Returns
Returns the resulting point.

Definition at line 47 of file Point.cpp.

◆ operator==()

bool KatanaEngine::Point::operator== ( const Point & point) const

Determines if two points are equal.

Parameters
pointThe point to compare.
Returns
Returns true if the points are equal, false otherwise.

Definition at line 84 of file Point.cpp.

◆ Set() [1/2]

void KatanaEngine::Point::Set ( const int x,
const int y )

Sets the components of the point.

Parameters
xThe X component.
yThe Y component.

Definition at line 28 of file Point.cpp.

◆ Set() [2/2]

void KatanaEngine::Point::Set ( const Point point)

Sets the components of the vecpointtor.

Parameters
pointThe point whose components to copy.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 34 of file Point.cpp.

◆ ToString()

std::string KatanaEngine::Point::ToString ( ) const

Gets a string representation of the point.

Returns
Returns a string displaying the components of the point.

Definition at line 40 of file Point.cpp.

◆ ToVector2()

const Vector2 KatanaEngine::Point::ToVector2 ( ) const

Converts the point into a vector.

Returns
Returns a displacement vector to the point.

Definition at line 94 of file Point.cpp.

Member Data Documentation

◆ Origin

const Point KatanaEngine::Point::Origin = Point(0, 0)
static

A point located at the origin.

Definition at line 34 of file Point.h.

◆ X

int KatanaEngine::Point::X = 0

The x-coordinate of the point.

Definition at line 100 of file Point.h.

◆ Y

int KatanaEngine::Point::Y = 0

The y-coordinate of the point.

Definition at line 101 of file Point.h.


The documentation for this class was generated from the following files: