Dragonfly 4.22
A text-based game engine
Frame.h
1///
2/// A sprite frame
3///
4
5#ifndef __FRAME_H__
6#define __FRAME_H__
7
8// System includes.
9#include <string>
10
11// Engine includes.
12#include "Color.h"
13#include "Vector.h"
14
15namespace df {
16
17/// Options to transform frame before drawing.
19 NONE, ///< No frame transform (default).
20 VERTICAL, ///< Frame flipped vertically.
21 HORIZONTAL, ///< Frame flipped horizontally.
22 BOTH, ///< Frame flipped both vertically and horizontally.
23};
24
25class Frame {
26
27 private:
28 int m_width; ///< Width of frame
29 int m_height; ///< Height of frame
30 std::string m_frame_str; ///< All frame characters stored as string.
31
32 public:
33 /// Create empty frame.
35
36 /// Create frame of indicated width and height with string.
37 Frame(int new_width, int new_height, std::string frame_str);
38
39 /// Set width of frame.
40 void setWidth(int new_width);
41
42 /// Get width of frame.
43 int getWidth() const;
44
45 /// Set height of frame.
46 void setHeight(int new_height);
47
48 /// Get height of frame.
49 int getHeight() const;
50
51 /// Set frame characters (stored as string).
52 void setString(std::string new_frame_str);
53
54 /// Get frame characters (stored as string).
55 std::string getString() const;
56
57 /// Draw self, centered at position (x,y) with color.
58 /// Don't draw transparent characters (0 means none).
59 /// Return 0 if ok, else -1.
60 /// Note: top-left coordinate is (0,0).
61 int draw(Vector position, Color color, char transparency, Transform transform = NONE) const;
62};
63
64} // end of namespace df
65#endif //__FRAME_H__
Definition: Frame.h:25
int m_height
Height of frame.
Definition: Frame.h:29
int getWidth() const
Get width of frame.
std::string m_frame_str
All frame characters stored as string.
Definition: Frame.h:30
std::string getString() const
Get frame characters (stored as string).
Frame()
Create empty frame.
void setHeight(int new_height)
Set height of frame.
int getHeight() const
Get height of frame.
void setString(std::string new_frame_str)
Set frame characters (stored as string).
Frame(int new_width, int new_height, std::string frame_str)
Create frame of indicated width and height with string.
int draw(Vector position, Color color, char transparency, Transform transform=NONE) const
Draw self, centered at position (x,y) with color.
void setWidth(int new_width)
Set width of frame.
int m_width
Width of frame.
Definition: Frame.h:28
Definition: Vector.h:12
An animation for a sprite.
Definition: Animation.h:15
Color
Colors Dragonfly recognizes.
Definition: Color.h:11
Transform
Options to transform frame before drawing.
Definition: Frame.h:18
@ VERTICAL
Frame flipped vertically.
Definition: Frame.h:20
@ BOTH
Frame flipped both vertically and horizontally.
Definition: Frame.h:22
@ NONE
No frame transform (default).
Definition: Frame.h:19
@ HORIZONTAL
Frame flipped horizontally.
Definition: Frame.h:21