#pragma once
#include "sprite.h"
#include <vector>
#include <string>
#include "parser.h"
#include "List.h"

struct SpriteTime
{
	Sprite* s;
	int time;
};

class AnimatedSprite : public Sprite
{
public:
	//AnimatedSprite(std::string filename);
	//AnimatedSprite(std::string filename, int width, int height);
	AnimatedSprite( std::string filename, List *spriteInfo );
	AnimatedSprite(AnimatedSprite *sprite);
	~AnimatedSprite();

	Sprite* instance();

	virtual void update();
	virtual void draw(int x, int y, bool origin = LEVEL);
	virtual void reset() {_index = 0; _time = 0;}
	virtual void clean();
	
protected:
	std::vector<Sprite*> _createdSprites;
	std::vector<SpriteTime> _sprites;
	int _index;
	int _time;
	int _totalTime;
	bool _loop;
};
