Arcade Shooter
Region.h
1 
2 /* ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
3  ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
4  █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
5  ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
6  ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
7  ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
8  /vvvvvvvvvvvvvvvvvvv \=========================================,
9  `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
10  Katana Engine \/ © 2012 - Shuriken Studios LLC */
11 
12 #pragma once
13 
14 namespace KatanaEngine
15 {
17  class Region
18  {
19 
20  public:
21 
23  Region() { X = Y = Width = Height = 0; }
24 
25 
31  Region(const Point position, const Point size)
32  : Region(position, size.X, size.Y) { }
33 
40  Region(const Point position, const int width, const int height)
41  : Region(position.X, position.Y, width, height) { }
42 
50  Region(const int x, const int y, const int width, const int height)
51  {
52  Set(x, y, width, height);
53  }
54 
55  virtual ~Region() { }
56 
64  void Set(const int x, const int y, const int width, const int height)
65  {
66  X = x;
67  Y = y;
68  Width = width;
69  Height = height;
70  }
71 
74  int GetTop() { return Y; }
75 
78  int GetBottom() { return Y + Height; }
79 
82  int GetLeft() { return X; }
83 
86  int GetRight() { return X + Width; }
87 
88 
91  Point GetTopLeft() { return Point(GetLeft(), GetTop()); }
92 
95  Point GetTopRight() { return Point(GetRight(), GetTop()); }
96 
100 
104 
108 
112  void Translate(const int x, const int y)
113  {
114  X += x;
115  Y += y;
116  }
117 
122  void Translate(const Point &point)
123  {
124  X += point.X;
125  Y += point.Y;
126  }
127 
128 
129  int X;
130  int Y;
131  int Width;
132  int Height;
133  };
134 }
int Width
The width of the region.
Definition: Region.h:131
Region(const Point position, const int width, const int height)
Instantiates a new Region object.
Definition: Region.h:40
int Height
The height of the region.
Definition: Region.h:132
Region(const int x, const int y, const int width, const int height)
Instantiates a new Region object.
Definition: Region.h:50
int X
The x-coordinate of the point.
Definition: Point.h:97
int GetRight()
The right side of the region.
Definition: Region.h:86
void Translate(const Point &point)
Moves the region by the specified amount.
Definition: Region.h:122
int Y
The y-coordinate of the point.
Definition: Point.h:98
Defines a vector with 2 components (x and y). This is additional information...
Definition: Vector2.h:18
void Translate(const int x, const int y)
Moves the region by the specified amount.
Definition: Region.h:112
int GetBottom()
The bottom of the region.
Definition: Region.h:78
Region(const Point position, const Point size)
Instantiates a new Region object.
Definition: Region.h:31
void Set(const int x, const int y, const int width, const int height)
Sets the components of the region.
Definition: Region.h:64
Region()
Instantiates a new Region object.
Definition: Region.h:23
int X
The left side of the region.
Definition: Region.h:129
Point GetBottomLeft()
The bottom left corner of the region.
Definition: Region.h:99
Defines a rectangular region defined by a point, height, width.
Definition: Region.h:17
Point GetTopLeft()
The top left corner of the region.
Definition: Region.h:91
Point GetTopRight()
The top right corner of the region.
Definition: Region.h:95
const Vector2 ToVector2() const
Converts the point into a vector.
Definition: Point.cpp:91
Defines a point in 2D space.
Definition: Point.h:19
int Y
The top of the region.
Definition: Region.h:130
Vector2 GetCenter()
The center position of the region.
Definition: Region.h:107
int GetTop()
The top of the region.
Definition: Region.h:74
Point GetBottomRight()
The bottom right corner of the region.
Definition: Region.h:103
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition: Animation.cpp:14
int GetLeft()
The left side of the region.
Definition: Region.h:82