/*====================ÉCOLE POLYTECHNIQUE DE MONTRÉAL============================

	NOM DU FICHIER :CAnimation.h

	DESCRIPTION :	Déclaration de la classe qui gère les animations

	AUTEUR : Martin Bisson, Anne-Marie Buki, Mylene Denis & Jean-Francois Pérusse

===============================================================================*/
#ifndef CANIMATION_H
#define CANIMATION_H

#include <vector>
using namespace std;

#include "CPngTexture.h"

class CAnimation
{
	vector<unsigned int> FramesMs;
	bool Loop;
	bool IsPlaying;
	unsigned long LastFrameTime;
	unsigned int CurrentFrame;
	unsigned int msPerFrame;
	vector<CPngTexture> Images;
	bool Visible;

	float PosX,  PosY;
	float Width, Height;
public:
	CAnimation(float PosX = 0, float PosY = 0, float Width = 100, float Height = 100, unsigned int msPerFrame = 50, bool Loop = true, bool Visible = true);
	void Setup(float PosX = 0, float PosY = 0, float Width = 100, float Height = 100, unsigned int msPerFrame = 50, bool Loop = true, bool Visible = true);	//Changes the different parameters of the animation
	void Play();					//Starts playing the animation
	void Stop();					//Stops the animation
	void Pause();					//Pauses the animation
	//If msPerFrame = 0, use animation default, else, use frame time
	bool AddFile(const char* FileName, int Mipmap = 0, int Transparency = -2, unsigned int msPerFrame = 0);	//Opens the file, creates the texture, and adds it to animation.
	void Draw();					//This function draws the current frame
	void DrawAt(float x, float y);
	void Update();					//This function updates the current frame (Done in IDLE function)
	void Clear();					//This function unloads all images
	void SetVisibility(bool Vis) { this->Visible = Vis; } //Animation visible or not?
	
	vector< CPngTexture >* GetPtrVector() { return &Images; }
};

#endif
