// Path: hermes/Hermes.java
// public class Hermes {
// 	
// 	private static PApplet _parentApplet = null; //Storage of sketch's PApplet. 
// 	private static float _timeScale = 1.0f; // the time scale used by Hermes motion and physics calculations
// 	
// 	/**
// 	 * Sets the time scale for calculating motion and physics. This is seconds/unit, so a value of 2 will mean
// 	 * 	each 2 seconds correspond to one time unit.
// 	 * @param scale
// 	 */
// 	public static void setTimeScale(float scale) {
// 		_timeScale = scale;
// 	}
// 	
// 	/**
// 	 * Returns the Hermes time scale.
// 	 * @return	the time scale
// 	 */
// 	public static float getTimeScale() {
// 		return _timeScale;
// 	}
// 	
// 	/**
// 	 * Returns the <code>PApplet</code> that Hermes is running in.
// 	 */
// 	public static PApplet getPApplet() {
// 		synchronized(_parentApplet) {
// 			return _parentApplet;
// 		}
// 	}
// 	
// 	/**
// 	 * Set the PApplet that all utilities use. Called <code>Hermes.setPApplet(this)</code> before doing anything else!
// 	 */
// 	public static void setPApplet(PApplet parentApplet) {
// 		_parentApplet = parentApplet;		
// 	}
// 	
// 	/**
// 	 * Causes the calling thread to sleep, catches InterruptedException.
// 	 * @param time	the time (in milliseconds) to sleep
// 	 */
// 	public static void unsafeSleep(long time) {
// 		try {
// 			Thread.sleep(time);
// 		} catch (InterruptedException e) {}
// 	}
// 	
// }


import hermes.Hermes;
import processing.core.PImage;
package hermes.animation;


public class Tileset {

	private PImage _tileImage; //a tile set aka a tile map aka a sprite sheet
	private int _tileWidth; //width of tiles in the sheet, in pixels
	private int _tileHeight;//height of tiles in the sheet, in pixels

	private PImage[][] _slicedTiles; //we preprocess the images by cutting them up and storing them in this grid

	/**
	 * 
	 * @param tileImage			PImage of tileset to cut up
	 * @param tileWidth			width of tiles in the set, in pixels
	 * @param tileHeight		height of tiles in the set, in pixels
	 */
	@SuppressWarnings("static-access")
	public Tileset(PImage tileImage, int tileWidth, int tileHeight) {
		_tileImage = tileImage;
		_tileWidth = tileWidth;
		_tileHeight = tileHeight;

		//initialize array, figure out how many rows and cols (note: _slicedTiles[y][x])
		_slicedTiles = new PImage[tileImage.height / _tileHeight][tileImage.width / _tileWidth];

		//cut the image into slices
		for (int row = 0; row < _tileImage.height / _tileHeight; row++) {
			for (int col = 0; col < _tileImage.width / _tileWidth; col++) { 
				//Create a new image slice that corresponds to the size of the tiles in this set
// Path: hermes/Hermes.java
// public class Hermes {
// 	
// 	private static PApplet _parentApplet = null; //Storage of sketch's PApplet. 
// 	private static float _timeScale = 1.0f; // the time scale used by Hermes motion and physics calculations
// 	
// 	/**
// 	 * Sets the time scale for calculating motion and physics. This is seconds/unit, so a value of 2 will mean
// 	 * 	each 2 seconds correspond to one time unit.
// 	 * @param scale
// 	 */
// 	public static void setTimeScale(float scale) {
// 		_timeScale = scale;
// 	}
// 	
// 	/**
// 	 * Returns the Hermes time scale.
// 	 * @return	the time scale
// 	 */
// 	public static float getTimeScale() {
// 		return _timeScale;
// 	}
// 	
// 	/**
// 	 * Returns the <code>PApplet</code> that Hermes is running in.
// 	 */
// 	public static PApplet getPApplet() {
// 		synchronized(_parentApplet) {
// 			return _parentApplet;
// 		}
// 	}
// 	
// 	/**
// 	 * Set the PApplet that all utilities use. Called <code>Hermes.setPApplet(this)</code> before doing anything else!
// 	 */
// 	public static void setPApplet(PApplet parentApplet) {
// 		_parentApplet = parentApplet;		
// 	}
// 	
// 	/**
// 	 * Causes the calling thread to sleep, catches InterruptedException.
// 	 * @param time	the time (in milliseconds) to sleep
// 	 */
// 	public static void unsafeSleep(long time) {
// 		try {
// 			Thread.sleep(time);
// 		} catch (InterruptedException e) {}
// 	}
// 	
// }


// Path: hermes/animation/Tileset.java
import hermes.Hermes;
import processing.core.PImage;

package hermes.animation;


public class Tileset {

	private PImage _tileImage; //a tile set aka a tile map aka a sprite sheet
	private int _tileWidth; //width of tiles in the sheet, in pixels
	private int _tileHeight;//height of tiles in the sheet, in pixels

	private PImage[][] _slicedTiles; //we preprocess the images by cutting them up and storing them in this grid

	/**
	 * 
	 * @param tileImage			PImage of tileset to cut up
	 * @param tileWidth			width of tiles in the set, in pixels
	 * @param tileHeight		height of tiles in the set, in pixels
	 */
	@SuppressWarnings("static-access")
	public Tileset(PImage tileImage, int tileWidth, int tileHeight) {
		_tileImage = tileImage;
		_tileWidth = tileWidth;
		_tileHeight = tileHeight;

		//initialize array, figure out how many rows and cols (note: _slicedTiles[y][x])
		_slicedTiles = new PImage[tileImage.height / _tileHeight][tileImage.width / _tileWidth];

		//cut the image into slices
		for (int row = 0; row < _tileImage.height / _tileHeight; row++) {
			for (int col = 0; col < _tileImage.width / _tileWidth; col++) { 
				//Create a new image slice that corresponds to the size of the tiles in this set
				PImage slice = Hermes.getPApplet().createImage(_tileWidth, _tileHeight, Hermes.getPApplet().ARGB);