/*******************************************************
//
//	Name: CAnimation.h
//
//	Author: Dave Ratti
//
//	Date: 2-26-02
//
//	Modified: 2-26-02
//
//	Notes: Base animation class. 
//
//
//
*********************************************************/

#ifndef CANIMATION
#define CANIMATION

#include "CImage.h"
#include "STRINGC.h"
#include "CFrame.h"
#include <list>

using namespace std;

typedef list<CFrame> FrameList;
typedef FrameList::iterator FrameListIterator;

enum RepeatType	
{
	NoRepeat		= 0,	//No Repeat
	JumpRepeat		= 1,	//Jump from last frame to first
	BackwardsRepeat = 2		//Play backwards when at end. 

};

enum AnimationState
{
	Waiting			= 0,	//Waiting
	Updating		= 1,	//Just updated Frame
	Done			= 2		//Animation is done
};

class CAnimation
{

public:

	CAnimation();
	virtual ~CAnimation();

	virtual void Init(STRINGC line);	

	virtual CImage*			getCurrentImage();
	virtual POINT			getCurrentDisplacement();
	virtual AnimationState  Update();			//Call every frame this animation is active

	RepeatType	getRepeat(){ return m_Repeat;};
	void		setRepeat(RepeatType r){ m_Repeat = r; };

	

	void Reset();
	
protected:

	FrameList		  m_Frames;
	FrameListIterator m_currentFrame;
	RepeatType		  m_Repeat;
	int				  m_currentTick;
	bool			  m_movingForward;		//If true we are moving from start to end in our animation list. if False from end to start.

	void			  advanceFrame();		//moves to next frame in animation

};


#endif