/* 
	Flake.java

	[ more java @ mlab - 10-17.1.2000 - juhuu@katastro.fi ]
*/

public class Flake
{
	double dX_coord;
	double dX_coord_keep;

	double dY_coord;

	double dX_sine;
	double dY_sine;

	double dCounter;

	// Flake constructor :	x - x coordinate of the flake
	//						y - y coordinate of the flake
	public Flake(double x, double y)
	{
		dX_coord		= x;
		dY_coord		= y;

		// init sine multipliers & counter
		dX_sine			= Math.random();
		dY_sine			= Math.random();
		dCounter		= Math.random();
	
		// if this is anything else than -1, always set x to this coord
		dX_coord_keep	= -1;
	}

	public void updatecoords()
	{
		// add sine counter
		dCounter += dX_sine / 50;		// add sine counter
		dCounter += dY_sine / 50;		
		// add sine value to the x coordinate
		if(dX_coord_keep == -1)
			dX_coord += (0.5 + dX_sine) * Math.sin((dCounter + dX_sine * 4));					
		// increment y coordinate		dY_coord += 0.5 + dY_sine * 2.0;		// add sine value to the y coordinate
		dY_coord += (0.1 + dY_sine) * Math.sin((dCounter + dY_sine * 6) / 20);

	}
	
	public int getX()
	{
		return (int) dX_coord;
	}

	public int getY()
	{
		return (int) dY_coord;
	}

	public void setX_keep(int x)
	{
		dX_coord_keep = x;
		dX_coord = x;
	}
}
