Dragonfly 4.20
A text-based game engine
|
Public Member Functions | |
~Sprite () | |
Sprite (int max_frames) | |
void | setWidth (int new_width) |
int | getWidth () const |
void | setHeight (int new_height) |
int | getHeight () const |
void | setColor (Color new_color) |
Color | getColor () const |
int | getFrameCount () const |
int | addFrame (Frame new_frame) |
Frame | getFrame (int frame_number) const |
void | setLabel (std::string new_label) |
std::string | getLabel () const |
void | setSlowdown (int new_sprite_slowdown) |
int | getSlowdown () const |
void | setTransparency (char new_transparency) |
char | getTransparency () const |
int | draw (int frame_number, Vector position, char transparency) const |
std::string | toString () const |
Private Member Functions | |
Sprite () | |
Private Attributes | |
int | m_width |
int | m_height |
int | m_max_frame_count |
int | m_frame_count |
Color | m_color |
int | m_slowdown |
char | m_transparency |
Frame * | m_frame |
std::string | m_label |
|
private |
Sprite always has one arg, the frame count.
df::Sprite::~Sprite | ( | ) |
Delete sprite, removing any allocated frames.
df::Sprite::Sprite | ( | int | max_frames | ) |
Create sprite with indicated maximum number of frames.
int df::Sprite::addFrame | ( | Frame | new_frame | ) |
Add frame to sprite.
Return -1 if frame array full, else 0.
int df::Sprite::draw | ( | int | frame_number, |
Vector | position, | ||
char | transparency | ||
) | const |
Draw indicated frame centered at position (x,y).
Don't draw transparent characters (0 means none). Return 0 if ok, else -1. Note: top-left coordinate is (0,0).
Color df::Sprite::getColor | ( | ) | const |
Get sprite color.
Frame df::Sprite::getFrame | ( | int | frame_number | ) | const |
Get next sprite frame indicated by number.
Return empty frame if out of range [0, m_frame_count-1].
int df::Sprite::getFrameCount | ( | ) | const |
Get total count of frames in sprite.
int df::Sprite::getHeight | ( | ) | const |
Get height of sprite.
std::string df::Sprite::getLabel | ( | ) | const |
Get label associated with sprite.
char df::Sprite::getTransparency | ( | ) | const |
Get Sprite transparency character (0 means none).
int df::Sprite::getWidth | ( | ) | const |
Get width of sprite.
void df::Sprite::setColor | ( | Color | new_color | ) |
Set sprite color.
void df::Sprite::setHeight | ( | int | new_height | ) |
Set height of sprite.
void df::Sprite::setLabel | ( | std::string | new_label | ) |
Set label associated with sprite.
void df::Sprite::setSlowdown | ( | int | new_sprite_slowdown | ) |
Set animation slowdown value.
Value in multiples of GameManager frame time.
void df::Sprite::setTransparency | ( | char | new_transparency | ) |
Set Sprite transparency character (0 means none).
void df::Sprite::setWidth | ( | int | new_width | ) |
Set width of sprite.
std::string df::Sprite::toString | ( | ) | const |
Return attributes as string.
|
private |
Optional color for entire sprite.
|
private |
Array of frames.
|
private |
Actual number of frames sprite has.
|
private |
Sprite height.
|
private |
Text label to identify sprite.
|
private |
Maximum number of frames sprite can have.
|
private |
Animation slowdown (1 = no slowdown, 0 = stop).
|
private |
Sprite transparent character (0 if none).
|
private |
Sprite width.