package rpgEngine.Data.Raw.Graphics;

import java.awt.image.BufferedImage;

public class CharacterSet {
	private BufferedImage[] images;
	private String name;
	
	public static final Integer IMAGES_UP_0 = 0;
	public static final Integer IMAGES_UP_1 = 1;
	public static final Integer IMAGES_UP_2 = 2;
	public static final Integer IMAGES_RIGHT_0 = 3;
	public static final Integer IMAGES_RIGHT_1 = 4;
	public static final Integer IMAGES_RIGHT_2 = 5;
	public static final Integer IMAGES_DOWN_0 = 6;
	public static final Integer IMAGES_DOWN_1 = 7;
	public static final Integer IMAGES_DOWN_2 = 8;
	public static final Integer IMAGES_LEFT_0 = 9;
	public static final Integer IMAGES_LEFT_1 = 10;
	public static final Integer IMAGES_LEFT_2 = 11;
	
	public CharacterSet() {
		this("",null);
	}
	
	
	public CharacterSet(String n, BufferedImage i) {
		name = n;
		images = new BufferedImage[12];
		
		SeperateImage(i);
	}
	
	
	public void SeperateImage(BufferedImage img) {
		if(img == null) {
			return;
		}
		
		if(images == null) {
			return;
		}
		
		images[IMAGES_UP_0] = img.getSubimage(0, 0, 24, 32);
		images[IMAGES_UP_1] = img.getSubimage(24, 0, 24, 32);
		images[IMAGES_UP_2] = img.getSubimage(48, 0, 24, 32);
		
		images[IMAGES_RIGHT_0] = img.getSubimage(0, 32, 24, 32);
		images[IMAGES_RIGHT_1] = img.getSubimage(24, 32, 24, 32);
		images[IMAGES_RIGHT_2] = img.getSubimage(48, 32, 24, 32);
		
		images[IMAGES_DOWN_0] = img.getSubimage(0, 64, 24, 32);
		images[IMAGES_DOWN_1] = img.getSubimage(24, 64, 24, 32);
		images[IMAGES_DOWN_2] = img.getSubimage(48, 64, 24, 32);
		
		images[IMAGES_LEFT_0] = img.getSubimage(0, 96, 24, 32);
		images[IMAGES_LEFT_1] = img.getSubimage(24, 96, 24, 32);
		images[IMAGES_LEFT_2] = img.getSubimage(48, 96, 24, 32);
	}


	public String getName() {
		return name;
	}


	public BufferedImage[] getImages() {
		return images;
	}
	
	
	public BufferedImage getImage(int i) {
		BufferedImage img = null;
		
		try {
			img = images[i];
		}
		catch(Exception e) {
			img = null;
		}
		
		return img;
	}
	
}
