//	Snowflakes.h - Class which draws snowflakes if the game is played during
//				   December.
//  ----------------------------------------------------------------------------
//	This file is part of 'NiallsAVLib', base code for any kind of audiovisual
//	apps.
//	Copyright (C) 2012  Niall Moody
//	
//	This program is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program.  If not, see <http://www.gnu.org/licenses/>.
//	----------------------------------------------------------------------------

#ifndef SNOWFLAKES_H_
#define SNOWFLAKES_H_

#include "c0xHeaders.h"
#include "TwoFloats.h"

class Drawer;

///	Class which draws snowflakes if the game is played during December.
class Snowflakes
{
  public:
	///	Constructor.
	Snowflakes();
	///	Destructor.
	~Snowflakes();

	///	Moves the snowflakes.
	void update();
	///	Draws the snowflakes.
	void draw(shared_ptr<Drawer>& d);

	///	Sets the number of snowflakes to display (0->1; scaled internally to 0->2048).
	void setNumSnowflakes(float val);

	///	Returns true if it's December.
	bool getDecember() const {return december;};
  private:
	///	Struct representing a single snowflake.
	struct Snowflake
	{
		///	The snowflake's position.
		TwoFloats position;
		///	The snowflake's image.
		int image;
		///	The snowflake's rotation.
		float rotation;
		///	The index of the snowflake's sine motion.
		float sinIndex;
		///	The magnitude of the snowflake's sine motion.
		float sinMag;

		///	The speed at which the snowflake falls.
		float fallInc;
		///	The speed at which the snowflake rotates.
		float rotSpeed;
		///	The amount to increment sinIndex for each update().
		float sinInc;
	};

	///	The number of snowflakes to draw.
	enum
	{
		NumSnowflakes = 2048
	};

	///	The snowflakes on screen.
	Snowflake snowflakes[NumSnowflakes];
	///	The number of snowflakes we actually display.
	int numSnowflakes;
	///	True if we're in Decemember.
	bool december;

	///	The 3 snowflake images.
	std::wstring images[3];
	///	The pivots of the 3 snowflake images.
	TwoFloats imagePivots[3];
};

#endif
