//	Debilitation.cpp - The wave of debilitation emitted by Capitalists.
//  ----------------------------------------------------------------------------
//	This file is part of 'The Future Will Only Be Dystopian if Capitalism
//	Remains Undefeated', a game.
//	Copyright (C) 2009  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 "Debilitation.h"
#include "Images.h"
#include "NiallsDrawingLib/Drawer.h"
#include "NiallsDrawingLib/ImageLoader.h"
#include "sound/Sounds.h"

//------------------------------------------------------------------------------
uint32_t Debilitation::image = 0;

//------------------------------------------------------------------------------
Debilitation::Debilitation(int x, int y, float val):
xPos(x),
yPos(y),
strength(val),
size(0.0f)
{
	Sounds::getInstance().playSound(Sounds::DebilitationWave);
}

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

//------------------------------------------------------------------------------
bool Debilitation::move()
{
	bool retval = false;

	size += 0.01f;
	if(size > 1.5f)
		retval = true;

	return retval;
}

//------------------------------------------------------------------------------
void Debilitation::draw(Drawer *d)
{
	float alpha = 1.0f;

	if(!image)
	{
		ImageLoader imLoad;
		ImageData data;

		data = imLoad.loadImage(Images::debilitation_png, Images::debilitation_pngSize);
		image = d->loadImage(data.data, data.width, data.height);
	}

	if(size > 1.0f)
		alpha = 1.0f-((size-1.0f)*2.0f);

	d->drawImage(image, xPos, yPos, size, size, 1.0f, 1.0f, 1.0f, alpha);
}
