Dragonfly  4.3
A text-based game engine
Shape.h
1 ///
2 /// A single-space, 2d shape for drawing.
3 ///
4 
5 #ifndef __SHAPE_H__
6 #define __SHAPE_H__
7 
8 // System includes.
9 #include <SFML/Graphics/CircleShape.hpp>
10 
11 // Engine includes.
12 #include "Color.h"
13 #include "Vector.h"
14 
15 namespace df {
16 
17 enum ShapeType {
18  UNDEFINED_SHAPE = -1,
19  CIRCLE,
20  SQUARE,
21  TRIANGLE,
22 };
23 
24 class Shape {
25 
26  private:
27  Color m_color; ///< Shape color.
28  unsigned char m_r,m_g,m_b; ///< RGB colors used if color is CUSTOM.
29  ShapeType m_type; ///< Type of shape.
30  float m_size; ///< Radius size (in pixels).
31  unsigned char m_opacity; ///< Opacity (transparent) 0 to 255 (opaque).
32 
33  public:
34 
35  /// Default is Circle, df::WHITE, size 1 character.
36  Shape();
37 
38  /// Set size (in pixels).
39  void setSize(float new_size);
40 
41  /// Get size (in pixels).
42  float getSize() const;
43 
44  /// Set type.
45  void setType(ShapeType new_type);
46 
47  /// Get type.
48  ShapeType getType() const;
49 
50  /// Set color, where input is Dragonfly Color.
51  void setColor(Color new_color);
52 
53  /// Set color, where input is RGB.
54  void setColor(unsigned char r, unsigned char g, unsigned char b);
55 
56  /// Get color. Returns Dragonfly Color.
57  Color getColor() const;
58 
59  /// Set opacity (0 is transparent, 255 is opaque).
60  void setOpacity(unsigned char new_opacity);
61 
62  /// Get opacity (0 is transparent, 255 is opaque).
63  unsigned char getOpacity() const;
64 
65  /// Draw self at given world position.
66  void draw(Vector world_pos);
67 };
68 
69 } // end of namespace df
70 #endif //__SHAPE_H__
Definition: Shape.h:24
Color m_color
Shape color.
Definition: Shape.h:27
ShapeType m_type
Type of shape.
Definition: Shape.h:29
void setColor(Color new_color)
Set color, where input is Dragonfly Color.
ShapeType getType() const
Get type.
float getSize() const
Get size (in pixels).
unsigned char m_b
RGB colors used if color is CUSTOM.
Definition: Shape.h:28
A 2-d bounding box.
Definition: Box.h:10
void draw(Vector world_pos)
Draw self at given world position.
unsigned char m_opacity
Opacity (transparent) 0 to 255 (opaque).
Definition: Shape.h:31
Shape()
Default is Circle, df::WHITE, size 1 character.
void setOpacity(unsigned char new_opacity)
Set opacity (0 is transparent, 255 is opaque).
unsigned char getOpacity() const
Get opacity (0 is transparent, 255 is opaque).
float m_size
Radius size (in pixels).
Definition: Shape.h:30
void setType(ShapeType new_type)
Set type.
Color
Colors Dragonfly recognizes.
Definition: Color.h:11
void setSize(float new_size)
Set size (in pixels).
Color getColor() const
Get color. Returns Dragonfly Color.
Definition: Vector.h:10