diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-06-26 19:59:28 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-06-26 19:59:28 -0400 |
commit | 428c401f9c1053f7e13ffe641758dfb72791d8dc (patch) | |
tree | 3b7c74e0346db3d08319e309c37e975e19395d74 /src/components/animatable.cpp | |
parent | 55c8a14a7e2b2dadf0def3e09f970818164366f5 (diff) | |
download | therapy-428c401f9c1053f7e13ffe641758dfb72791d8dc.tar.gz therapy-428c401f9c1053f7e13ffe641758dfb72791d8dc.tar.bz2 therapy-428c401f9c1053f7e13ffe641758dfb72791d8dc.zip |
Player now moves
Diffstat (limited to 'src/components/animatable.cpp')
-rw-r--r-- | src/components/animatable.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/components/animatable.cpp b/src/components/animatable.cpp new file mode 100644 index 0000000..fcd277c --- /dev/null +++ b/src/components/animatable.cpp | |||
@@ -0,0 +1,27 @@ | |||
1 | #include "animatable.h" | ||
2 | |||
3 | AnimatableComponent::AnimatableComponent(const char* filename, int frame_width, int frame_height, int frames_across) | ||
4 | : texture(filename), frame_width(frame_width), frame_height(frame_height), frames_across(frames_across) | ||
5 | { | ||
6 | |||
7 | } | ||
8 | |||
9 | int AnimatableComponent::getFrame() const | ||
10 | { | ||
11 | return frame; | ||
12 | } | ||
13 | |||
14 | void AnimatableComponent::setFrame(int frame) | ||
15 | { | ||
16 | this->frame = frame; | ||
17 | } | ||
18 | |||
19 | const Texture& AnimatableComponent::getTexture() const | ||
20 | { | ||
21 | return texture; | ||
22 | } | ||
23 | |||
24 | Rectangle AnimatableComponent::getFrameRect() const | ||
25 | { | ||
26 | return {frame_width * (frame % frames_across), frame_height * (frame / frames_across), frame_width, frame_height}; | ||
27 | } | ||