package de.siphalor.was.visual.canvas.render;

import java.awt.*;

public class AnimatedTextureObject extends TextureObject {
	private final int frameTime;
	private final Image[] frames;

	private int time = 0;

	public AnimatedTextureObject(int x, int y, int width, int height, int frameTime, Image... frames) {
		super(x, y, width, height);
		this.frameTime = frameTime;
		this.frames = frames;
	}

	@Override
	public void tick(int delta) {
		super.tick(delta);

		time += delta;
		if (time >= frames.length * frameTime) {
			time = 0;
		}
	}

	@Override
	public Image getTexture() {
		return frames[time / frameTime];
	}
}
