PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
rectf.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_RECTF_H
20 #define PGE_RECTF_H
21 
22 class PGE_Rect;
23 class PGE_PointF;
24 class PGE_SizeF;
25 
26 class PGE_RectF
27 {
28  friend class PGE_Rect;
29 public:
30  PGE_RectF();
31  PGE_RectF(double x, double y, double w, double h);
32  PGE_RectF(const PGE_RectF& r);
33  PGE_RectF(const PGE_Rect& r);
34  ~PGE_RectF();
35  void setRect(double x, double y, double w, double h);
36  void setPos(double x, double y);
37  void setSize(double w, double h);
38 
39  void setLeft(double l);
40  void setRight(double r);
41  void setTop(double t);
42  void setBottom(double b);
43  PGE_RectF withMargin(double margin);
44  PGE_RectF withMargin(double marginX, double marginY);
45 
46  void setX(double x);
47  void setY(double y);
48  void setWidth(double w);
49  void setHeight(double h);
50 
51  void setTopLeft(PGE_PointF p);
52  void setTopRight(PGE_PointF p);
53  void setBottomRight(PGE_PointF p);
54  void setBottomLeft(PGE_PointF p);
55 
56  void setTopLeft(double l, double t);
57  void setTopRight(double r, double t);
58  void setBottomRight(double r, double b);
59  void setBottomLeft(double l, double b);
60 
61  double x();
62  double y();
63 
64  double left();
65  double top();
66  double bottom();
67  double right();
68 
69  double width();
70  double height();
71 
72  PGE_PointF center();
73  PGE_SizeF size();
74 
75  bool collidePoint(double x, double y);
76  bool collideRect(double x, double y, double w, double h);
77  bool collideRect(PGE_RectF &rect);
78  bool collideRectDeep(PGE_RectF &rect, float deep);
79  bool collideRectDeep(PGE_RectF &rect, float deepX, float deepY);
80  bool collideRect(PGE_Rect &rect);
81 private:
82  double _x;
83  double _y;
84  double _w;
85  double _h;
86  double _r;
87  double _b;
88 };
89 
90 #endif // PGE_RECTF_H
Definition: rect.h:26
Definition: sizef.h:23
Definition: pointf.h:23
Definition: rectf.h:26