

function animController()
{
	this.frameProc 		= null;
	this.animTime		= 0;
	this.timePerFrame 	= 0;
	this.frameTime		= 0;
	this.totalTime		= 0;
	this.startFrame 	= 0;
	this.endFrame 		= 0;
	this.curFrame 		= 0;
	this.nextFrame		= 0;
	this.totalFrames	= 0;
	this.pause			= true;
	this.loop			= false;
}

animController.prototype.begin = function()
{
	this.curFrame = 0;
	this.nextFrame = 1;
	this.paused = false;
}

animController.prototype.stop = function()
{
	this.pause = true;
	this.curFrame = 0;
	this.nextFrame = 1;
}

animController.prototype.update = function(dt)
{
	// find the frame then send it to frame proc function to be applied
	if(!this.paused)
	{
	
		this.frameTime += dt;
		this.totalTime += dt;
		
		// if(this.totalTime >= this.animTime)
		// {
			// // if looping reset
			// this.curFrame = this.startFrame;
			// this.totalTime = 0;
			// this.frameTime = 0;
		// }
		
		if(this.frameTime > this.timePerFrame)
		{
			this.frameTime = 0;
			if(this.curFrame + 1 < this.totalFrames)
			{
				this.curFrame++;
				this.nextFrame++;
			}
			else if(this.curFrame + 1 == this.totalFrames)
			{
				if(this.loop)
				{
					this.curFrame = this.endFrame;
					this.nextFrame = this.startFrame;
				}
				else
				{
					this.curFrame = this.nextFrame = this.totalFrames - 1;
					this.paused = true;
				}
				
			}
			
		}
		
		this.frameProc.process(this.curFrame, this.nextFrame, this.frameTime/this.timePerFrame);
	
	}
	
}




