From 428c401f9c1053f7e13ffe641758dfb72791d8dc Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 26 Jun 2015 19:59:28 -0400 Subject: Player now moves --- src/components/animatable.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/components/animatable.cpp (limited to 'src/components/animatable.cpp') 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 @@ +#include "animatable.h" + +AnimatableComponent::AnimatableComponent(const char* filename, int frame_width, int frame_height, int frames_across) + : texture(filename), frame_width(frame_width), frame_height(frame_height), frames_across(frames_across) +{ + +} + +int AnimatableComponent::getFrame() const +{ + return frame; +} + +void AnimatableComponent::setFrame(int frame) +{ + this->frame = frame; +} + +const Texture& AnimatableComponent::getTexture() const +{ + return texture; +} + +Rectangle AnimatableComponent::getFrameRect() const +{ + return {frame_width * (frame % frames_across), frame_height * (frame / frames_across), frame_width, frame_height}; +} -- cgit 1.4.1