package com.hexabeast.lasermonster;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;

public class Flame {
	
	public float x;
	public float y;
	
	public int w = 64;
	public int h = 64;
	
	public Vector2 direction;
	
	public float time;
	public float maxTime = 1.2f;
	
	public float angle = 0;
	
	public boolean isDead = false;

	public Flame(float x, float y)
	{
		this.x = x;
		this.y = y;
		direction = new Vector2(Main.width/2-x, Main.height/2-y);
		direction.clamp(400, 400);
		direction.rotate((float) (Math.random()*40-20));
		angle = (float) (Math.random()*360);
	}
	
	
	public void draw()
	{
		time+=Main.delta;
		Color col = GameScreen.batch.getColor();
		
		if(time<maxTime)
		{
			x += direction.x*Main.delta*(1-(time/maxTime)/3);
			y += direction.y*Main.delta*(1-(time/maxTime)/3);
			
			GameScreen.batch.setColor(1,1,1,1-time/maxTime);
			
			GameScreen.batch.draw(Main.texFiree, x-w/2, y-h/2, w/2, h/2, w,h,0.2f+2*time/maxTime,0.2f+2*time/maxTime,angle);
			
			GameScreen.batch.setColor(col);
		}
		else
		{
			isDead = true;
		}
		
	}
}
