Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
Region.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{
20 class Region
21 {
22
23 public:
24
26 Region() { X = Y = Width = Height = 0; }
27
28
34 Region(const Point position, const Point size)
35 : Region(position, size.X, size.Y) { }
36
43 Region(const Point position, const int width, const int height)
44 : Region(position.X, position.Y, width, height) { }
45
53 Region(const int x, const int y, const int width, const int height)
54 {
55 Set(x, y, width, height);
56 }
57
58 virtual ~Region() { }
59
67 void Set(const int x, const int y, const int width, const int height)
68 {
69 X = x;
70 Y = y;
71 Width = width;
72 Height = height;
73 }
74
77 int GetTop() { return Y; }
78
81 int GetBottom() { return Y + Height; }
82
85 int GetLeft() { return X; }
86
89 int GetRight() { return X + Width; }
90
91
94 Point GetTopLeft() { return Point(GetLeft(), GetTop()); }
95
99
103
107
111
115 void Translate(const int x, const int y)
116 {
117 X += x;
118 Y += y;
119 }
120
125 void Translate(const Point &point)
126 {
127 X += point.X;
128 Y += point.Y;
129 }
130
131
132 int X = 0;
133 int Y = 0;
134 int Width = 1;
135 int Height = 1;
136 };
137}
Defines a point in 2D space.
Definition Point.h:23
const Vector2 ToVector2() const
Converts the point into a vector.
Definition Point.cpp:94
int X
The x-coordinate of the point.
Definition Point.h:100
int Y
The y-coordinate of the point.
Definition Point.h:101
Defines a rectangular region defined by a point, height, width.
Definition Region.h:21
Point GetTopLeft()
The top left corner of the region.
Definition Region.h:94
Point GetTopRight()
The top right corner of the region.
Definition Region.h:98
Region(const int x, const int y, const int width, const int height)
Instantiates a new Region object.
Definition Region.h:53
Point GetBottomLeft()
The bottom left corner of the region.
Definition Region.h:102
void Translate(const Point &point)
Moves the region by the specified amount.
Definition Region.h:125
int GetLeft()
The left side of the region.
Definition Region.h:85
int GetRight()
The right side of the region.
Definition Region.h:89
void Set(const int x, const int y, const int width, const int height)
Sets the components of the region.
Definition Region.h:67
int X
The left side of the region.
Definition Region.h:132
Region()
Instantiates a new Region object.
Definition Region.h:26
int GetTop()
The top of the region.
Definition Region.h:77
int GetBottom()
The bottom of the region.
Definition Region.h:81
int Height
The height of the region.
Definition Region.h:135
virtual ~Region()
Definition Region.h:58
Region(const Point position, const Point size)
Instantiates a new Region object.
Definition Region.h:34
int Y
The top of the region.
Definition Region.h:133
void Translate(const int x, const int y)
Moves the region by the specified amount.
Definition Region.h:115
Region(const Point position, const int width, const int height)
Instantiates a new Region object.
Definition Region.h:43
Point GetBottomRight()
The bottom right corner of the region.
Definition Region.h:106
int Width
The width of the region.
Definition Region.h:134
Vector2 GetCenter()
The center position of the region.
Definition Region.h:110
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