Dragonfly  4.3
A text-based game engine
Sprite.h
1 ///
2 /// The sprite
3 ///
4 
5 #ifndef __SPRITE_H__
6 #define __SPRITE_H__
7 
8 // System includes.
9 #include <string>
10 
11 // Engine includes.
12 #include "Color.h"
13 #include "Frame.h"
14 
15 namespace df {
16 
17 class Sprite {
18 
19  private:
20  int m_width; ///< Sprite width.
21  int m_height; ///< Sprite height.
22  int m_max_frame_count; ///< Maximum number of frames sprite can have.
23  int m_frame_count; ///< Actual number of frames sprite has.
24  Color m_color; ///< Optional color for entire sprite.
25  Frame *m_frame; ///< Array of frames.
26  std::string m_label; ///< Text label to identify sprite.
27  Sprite(); ///< Sprite constructor always has one arg.
28 
29  public:
30  /// Delete sprite, removing any allocated frames.
31  ~Sprite();
32 
33  /// Create sprite with indicated maximum number of frames.
34  Sprite(int max_frames);
35 
36  /// Set width of sprite.
37  void setWidth(int new_width);
38 
39  /// Get width of sprite.
40  int getWidth() const;
41 
42  /// Set height of sprite.
43  void setHeight(int new_height);
44 
45  /// Get height of sprite.
46  int getHeight() const;
47 
48  /// Set sprite color.
49  void setColor(Color new_color);
50 
51  /// Get sprite color.
52  Color getColor() const;
53 
54  /// Get total count of frames in sprite.
55  int getFrameCount() const;
56 
57  /// Add frame to sprite.
58  /// Return -1 if frame array full, else 0.
59  int addFrame(Frame new_frame);
60 
61  /// Get next sprite frame indicated by number.
62  /// Return empty frame if out of range [0, frame_count].
63  Frame getFrame(int frame_number) const;
64 
65  /// Set label associated with sprite.
66  void setLabel(std::string new_label);
67 
68  /// Get label associated with sprite.
69  std::string getLabel() const;
70 };
71 
72 } // end of namespace df
73 #endif // __SPRITE_H__
Frame getFrame(int frame_number) const
Get next sprite frame indicated by number.
int getHeight() const
Get height of sprite.
int m_frame_count
Actual number of frames sprite has.
Definition: Sprite.h:23
Frame * m_frame
Array of frames.
Definition: Sprite.h:25
int addFrame(Frame new_frame)
Add frame to sprite.
A 2-d bounding box.
Definition: Box.h:10
Sprite()
Sprite constructor always has one arg.
void setLabel(std::string new_label)
Set label associated with sprite.
Color m_color
Optional color for entire sprite.
Definition: Sprite.h:24
Color getColor() const
Get sprite color.
std::string m_label
Text label to identify sprite.
Definition: Sprite.h:26
void setColor(Color new_color)
Set sprite color.
Definition: Frame.h:12
Definition: Sprite.h:17
Color
Colors Dragonfly recognizes.
Definition: Color.h:11
~Sprite()
Delete sprite, removing any allocated frames.
void setHeight(int new_height)
Set height of sprite.
std::string getLabel() const
Get label associated with sprite.
int getFrameCount() const
Get total count of frames in sprite.
int m_max_frame_count
Maximum number of frames sprite can have.
Definition: Sprite.h:22
void setWidth(int new_width)
Set width of sprite.
int m_height
Sprite height.
Definition: Sprite.h:21
int m_width
Sprite width.
Definition: Sprite.h:20
int getWidth() const
Get width of sprite.