#include "brokenScreenEffect.h"


void BrokenScreenEffect::render( Render & render )
{
	
	glDisable( GL_DEPTH_TEST );
	glEnable( GL_BLEND );
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );


	glColor4f( 1.0, 1.0, 1.0, this->alpha );

	JitteringEffect::render( render );

	glDisable( GL_BLEND );
	glEnable( GL_DEPTH_TEST );
}

void BrokenScreenEffect::simulate( float dt )
{
	JitteringEffect::simulate( dt );

	if ( this->alpha > this->maxAlpha )
	{
		this->alphaOffset *= -1;
	}
	
	if ( this->alpha < this->minAlpha )
	{
		// effect finised, turn it off
		this->setActive( false );
	}
	this->alpha += this->alphaOffset * dt;

}