package com.hexabeast.lasermonster;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;

public class Eye {
	float x;
	float y;
	
	float w;
	float h;
	
	Vector2 lookAt;
	Vector2 mouse;
	
	public Eye(float x, float y)
	{
		this.x = x;
		this.y = y;
		
		w = Main.texEye.getWidth();
		h = Main.texEye.getHeight();
	}

	public void draw(SpriteBatch batch)
	{
		mouse = GameScreen.getAbsolutePos();
	    lookAt = new Vector2(mouse.x-x, mouse.y-y);
		lookAt.clamp(0, 15);
		
		if(GameScreen.end)
		{
			w-=Main.delta*50;
			h-=Main.delta*50;
			if(w<0)w=0;
			if(h<0)h=0;
		}
		
		float w = this.w * (0.4f+(GameScreen.health/100)*0.7f);
		float h = this.h * (0.4f+(GameScreen.health/100)*0.7f);
		
		batch.draw(Main.texEye, x+lookAt.x- w/2, y+lookAt.y-h/2, w, h);
	}
	
}
