Dragonfly 4.19
A text-based game engine
Box.h
1///
2/// A 2-d bounding box
3///
4
5#ifndef __BOX_H__
6#define __BOX_H__
7
8#include "Vector.h"
9
10namespace df {
11
12class Box {
13
14 private:
15 Vector m_corner; ///< Upper left corner of box.
16 float m_horizontal; ///< Horizontal dimension.
17 float m_vertical; ///< Vertical dimension.
18
19 public:
20 /// Create box with upper-left corner, horiz and vert sizes.
21 Box(Vector init_corner, float init_horizontal, float init_vertical);
22
23 /// Create box with (0,0) for corner, and 0 for horiz and vert.
24 Box();
25
26 /// Set upper left corner of box.
27 void setCorner(Vector new_corner);
28
29 /// Get upper left corner of box.
31
32 /// Set horizontal size of box.
33 void setHorizontal(float new_horizontal);
34
35 /// Get horizontal size of box.
36 float getHorizontal() const;
37
38 /// Set vertical size of box.
39 void setVertical(float new_vertical);
40
41 /// Get vertical size of box.
42 float getVertical() const;
43
44 /// Return attributes as string.
45 std::string toString() const;
46
47 bool operator==(const Box &other) const; ///< Compare boxes.
48 bool operator!=(const Box &other) const; ///< Compare boxes.
49
50 /// Draw box outline in pixels.
51 void draw();
52};
53
54
55} // end of namespace df
56#endif //__BOX_H__
Definition: Box.h:12
void setVertical(float new_vertical)
Set vertical size of box.
std::string toString() const
Return attributes as string.
bool operator!=(const Box &other) const
Compare boxes.
float getVertical() const
Get vertical size of box.
Vector getCorner() const
Get upper left corner of box.
Box(Vector init_corner, float init_horizontal, float init_vertical)
Create box with upper-left corner, horiz and vert sizes.
Vector m_corner
Upper left corner of box.
Definition: Box.h:15
void draw()
Draw box outline in pixels.
float m_vertical
Vertical dimension.
Definition: Box.h:17
float getHorizontal() const
Get horizontal size of box.
void setCorner(Vector new_corner)
Set upper left corner of box.
float m_horizontal
Horizontal dimension.
Definition: Box.h:16
void setHorizontal(float new_horizontal)
Set horizontal size of box.
Box()
Create box with (0,0) for corner, and 0 for horiz and vert.
bool operator==(const Box &other) const
Compare boxes.
Definition: Vector.h:12
An animation for a sprite.
Definition: Animation.h:15