 /**
  *  GameSprite contains the Sprite class for the Epsilon game.
  *  Epsilon is a simple space-shooter-vertical-scroller game.
  *
  *  Epsilon is available for non-commercial use only!
  *  You can learn from this sources and you can modify them
  *  for learning purposes.
  * 
  *  @author      Ziga Hajdukovic
  *  @version     1.0
  *  
  *  
  *  CHANGES
  *  + frameId
  *  + frameIdMax
  *  + imageId replaced Image object
  *  + spriteImageFrameWidths[]
  *  
  */  

class GameSprite {

	public int x;
	public int y;
	
	public int w;
	public int h;

	public int vx;
	public int vy;
	
	public byte energy;
	public byte energyMax;
	
	public byte imageId;
	
	public byte frameId;
	public byte frameIdMax;
	
	//public byte spriteId;
	
	public static final byte[] spriteImageFrameWidths =
	{
		26,	// SPRITE_IMAGE_PLAYER
		 4, // SPRITE_IMAGE_FIRE
		45, // SPRITE_IMAGE_BOSS1
		20, // SPRITE_IMAGE_ENEMY1
		20, // SPRITE_IMAGE_ENEMY2
		20, // SPRITE_IMAGE_ENEMY3
		20, // SPRITE_IMAGE_EXPLOSION
	};

	GameSprite(byte image_id, byte energy_max)
	{
		imageId = image_id;
		w = spriteImageFrameWidths[image_id];
		h = GameCanvas.spriteImages[image_id].getHeight();
		frameId = 0;
		frameIdMax = (byte) (GameCanvas.spriteImages[image_id].getWidth() / w - 1);
		vx = 4;
		vy = 4;
		energyMax = energy_max;
		energy = energyMax;
	}

	public boolean collidesWith(GameSprite sprite)
	{
		return (x+w > sprite.x) && (x < sprite.x + sprite.w) &&
			   (y+h > sprite.y) && (y < sprite.y + sprite.h);
	}
}
