package avs.utils; 

import java.util.ArrayList;
import java.awt.image.*;
import java.awt.*;

import javax.swing.*;

public class Animator{
	private BufferedImage[] images;
	private BufferedImage current;
	private int speed;
	private int frames;
	private int index;
	private int count;

	public Animator(int speed, BufferedImage[] images){
		this.speed = speed;
		this.images = images;
		this.index = 0;
		this.count = 0;
		this.frames = images.length-1;
	}

	public void runAnimation(){
		index += 1;
		if(index > speed){
			index = 0;
			nextFrame();
		}
	}

	public void nextFrame(){
		current = images[count];
		count += 1;
		if(count > frames)	count = 0;
	}

	public void drawAnimation(Graphics g, double x, double y, int width, int height,int offset){
		g.drawImage(current,(int) x - offset, (int) y, width, height, null);
	}

	public void setSpeed(int speed){
		this.speed = speed;
	}

	public void setCount(int count){
		this.count = count;
	}

	public int getSpeed(){
		return this.speed;
	}

	public int getCount(){
		return this.count;
	}

	public void setImages(BufferedImage[] images){
		this.images = images;
	}
}

@@ -11,17 +11,16 @@
 s.utils;
- 
 %0D%0A%0D%0Aimpo
@@ -1175,15 +1175,55 @@
 mages;%0D%0A
+        this.frames = images.length-1;%0D%0A
 %09%7D%0D%0A%7D%0D%0A

Fix bug in Animator.