summary refs log tree commit diff stats
path: root/src/components/animatable.cpp
blob: fcd277c41ecaa7760b56260035ce6d5908f03bda (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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};
}