Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
Point.h
Go to the documentation of this file.
1
2/*
3 ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
4 ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
5 █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
6 ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
7 ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
8 ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
9 /vvvvvvvvvvvvvvvvvvv \=========================================,
10 `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
11 Katana Engine \/ © 2012 - Shuriken Studios LLC
12 http://www.shurikenstudios.com
13*/
14
15#pragma once
16
17namespace KatanaEngine
18{
19 class Vector2;
20
22 class Point
23 {
24
25 public:
26
30 Point(const int x = 0, const int y = 0);
31 ~Point() { };
32
33
34 static const Point Origin;
40 void Set(const int x, const int y);
41
46 void Set(const Point point);
47
50 bool IsOrigin() const { return (X == 0 && Y == 0); }
51
54 const Vector2 ToVector2() const;
55
58 std::string ToString() const;
59
61 void Display() const { std::cout << ToString() << std::endl; }
62
63
67 Point &operator= (const Point &point);
68
72 Point &operator+=(const Point &point);
73
77 Point &operator-=(const Point &point);
78
82 const Point operator+(const Point &point) const;
83
87 const Point operator-(const Point &point) const;
88
92 bool operator==(const Point &point) const;
93
97 bool operator!=(const Point &point) const;
98
99
100 int X = 0;
101 int Y = 0;
103 };
104}
Defines a point in 2D space.
Definition Point.h:23
bool operator==(const Point &point) const
Determines if two points are equal.
Definition Point.cpp:84
void Display() const
Prints the point to the console.
Definition Point.h:61
Point & operator-=(const Point &point)
Subtracts a point.
Definition Point.cpp:66
void Set(const int x, const int y)
Sets the components of the point.
Definition Point.cpp:28
bool IsOrigin() const
Determines if the point is located at the origin.
Definition Point.h:50
const Vector2 ToVector2() const
Converts the point into a vector.
Definition Point.cpp:94
Point(const int x=0, const int y=0)
Instantiates a new point object.
Definition Point.cpp:22
const Point operator-(const Point &point) const
Subtracts a point from another.
Definition Point.cpp:79
int X
The x-coordinate of the point.
Definition Point.h:100
bool operator!=(const Point &point) const
Determines if two points are not equal.
Definition Point.cpp:89
int Y
The y-coordinate of the point.
Definition Point.h:101
Point & operator=(const Point &point)
Assigns the reference of a point.
Definition Point.cpp:47
std::string ToString() const
Gets a string representation of the point.
Definition Point.cpp:40
const Point operator+(const Point &point) const
Adds two points.
Definition Point.cpp:74
static const Point Origin
A point located at the origin.
Definition Point.h:34
Point & operator+=(const Point &point)
Adds a point.
Definition Point.cpp:58
Defines a vector with 2 components (x and y).
Definition Vector2.h:21
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition Animation.cpp:18