PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
rect.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef PGE_RECT_H
20 #define PGE_RECT_H
21 
22 class PGE_RectF;
23 class PGE_Point;
24 class PGE_Size;
25 
26 class PGE_Rect
27 {
28  friend class PGE_RectF;
29 public:
30  PGE_Rect();
31  PGE_Rect(int x, int y, int w, int h);
32  PGE_Rect(const PGE_Rect& r);
33  PGE_Rect(const PGE_RectF& r);
34  ~PGE_Rect();
35  void setRect(int x, int y, int w, int h);
36  void setPos(int x, int y);
37  void setSize(int w, int h);
38 
39  void setLeft(int l);
40  void setRight(int r);
41  void setTop(int t);
42  void setBottom(int b);
43 
44  void setX(int x);
45  void setY(int y);
46  void setWidth(int w);
47  void setHeight(int h);
48 
49  void setTopLeft(PGE_Point p);
50  void setTopRight(PGE_Point p);
51  void setBottomRight(PGE_Point p);
52  void setBottomLeft(PGE_Point p);
53 
54  void setTopLeft(int l, int t);
55  void setTopRight(int r, int t);
56  void setBottomRight(int r, int b);
57  void setBottomLeft(int l, int b);
58 
59  int x();
60  int y();
61 
62  int left();
63  int top();
64  int bottom();
65  int right();
66 
67  int width();
68  int height();
69 
70  PGE_Point center();
71  PGE_Size size();
72 
73  bool collidePoint(int x, int y);
74  bool collideRect(int x, int y, int w, int h);
75  bool collideRect(PGE_Rect &rect);
76  bool collideRect(PGE_RectF &rect);
77 private:
78  int _x;
79  int _y;
80  int _w;
81  int _h;
82  int _r;
83  int _b;
84 };
85 
86 #endif // PGE_RECT_H
Definition: rect.h:26
Definition: size.h:23
Definition: point.h:23
Definition: rectf.h:26