//
//  Animation.h
//  PixelKit
//
//  Copyright (c) 2014 César Parent. All rights reserved.
//
#ifndef _ANIMATION_H
#define _ANIMATION_H

#include "includes.h"
#include <vector>

namespace PixelKit
{
	/*!
	 * @class PixelKit::Animation
	 * @brief PixelKit's animation class. Holds the frames, speed and repeat
	 * data needed to run a Spritesheet animation. An Animation instance needs
	 * to be updated every frame by calling `tick()`
	 */
	class Animation
	{
	public:
		/*!
		 * @brief Animation constructor. The object is created from a SDL_RWops
		 * structure pointing to a valid binary-formatted animation definition
		 *
		 * @param animBuffer RWops structure pointing to the animation file
		 */
		Animation(SDL_RWops *animBuffer);
		
		/*!
		 * @brief Animation destructor
		 */
		~Animation();
		
		/*!
		 * @brief update the Animation's current frame
		 * @param delay time elapsed since last frame in milliseconds
		 */
		void tick(int delay);
		
		/*!
		 * @brief get a pointer to the Animation's current frame
		 */
		SDL_Rect *getFrame();
		
	private:
		std::vector<SDL_Rect> _frames;
		int _countdown;
		int _interval;
		int _repeat;
        Uint32 _currentFrame;
	};
}

#endif