//	Crash.cpp - The explosion graphic.
//  ----------------------------------------------------------------------------
//	This file is part of 'GameTemplate', template code for a game.
//	Copyright (C) 2011  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/>.
//	----------------------------------------------------------------------------

#include "Crash.h"
#include "drawing/Drawer.h"

#include <cmath>

//------------------------------------------------------------------------------
Crash::Crash(float x, float y, const ThreeFloats& col):
position(x-8, y),
colour(col),
scale(1.0f)
{

}

//------------------------------------------------------------------------------
Crash::~Crash()
{
	
}

//------------------------------------------------------------------------------
bool Crash::draw(DrawerPtr& d, float timestepInterp, float globalSpeed)
{
	float tempf;
	bool retval = false;

	scale += 0.1f * globalSpeed;
	if(scale > 6.283185f)
	{
		retval = true;
		scale = 0.0f;
	}

	tempf = 1.0f - ((cosf(scale)+1.0f) * 0.5f);

	d->drawImage(L"crashBack",
				 position-(64*tempf),
				 TwoFloats(tempf));
	d->drawImage(L"crash",
				 position-(64*tempf),
				 TwoFloats(tempf),
				 colour);

	return retval;
}
