UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
frame.h
Go to the documentation of this file.
1 #ifndef HORUSEYE_FRAMEWORK_FRAME_H_
2 #define HORUSEYE_FRAMEWORK_FRAME_H_
3 
4 namespace ugdk {
5 
6 // Representa um quadro (retangulo) na tela e/ou numa imagem.
7 // Util para trabalhar com animacoes, detectar colisoes
8 // (bounding box), etc.
9 //
10 // left, top, right e bottom sao usados para determinar as
11 // coordenadas do retangulo.
12 //
13 // (left,top)
14 // +------------------+
15 // | |
16 // | |
17 // +------------------+
18 // (right,bottom)
19 
28 class Frame {
29  public:
30  // Construtores e destrutores
32  Frame() : left_(0), top_(0), right_(0), bottom_(0) { }
34 
40  Frame(double left, double top, double right, double bottom) :
41  left_(left), top_(top), right_(right), bottom_(bottom) { }
42  ~Frame() { }
43 
44  // Utilidades inline
46  double width() const { return right_ - left_; }
48  double height() const { return bottom_ - top_; }
49 
50  // Accessors e mutators
55  double left() const { return left_; }
56  void set_left(double left) { left_ = left; }
57  double top() const { return top_; }
58  void set_top(double top) { top_ = top; }
59  double right() const { return right_; }
60  void set_right(double right) { right_ = right; }
61  double bottom() const { return bottom_; }
62  void set_bottom(double bottom) {bottom_ = bottom; }
65  // Devolve true se houver colisao entre
66  // 'frame' e este retangulo.
68  bool Collides(const Frame& frame) const;
69 
70  private:
71  double left_, top_, right_, bottom_;
72 };
73 
74 } // namespace ugdk
75 
76 #endif // HORUSEYE_FRAMEWORK_FRAME_H_