#include "soundeffecter.hpp"

soundeffecter :: soundeffecter(){

	Effects[ 0 ] = Mix_LoadWAV( "soundeffecter/001.wav" );
	Effects[ 1 ] = Mix_LoadWAV( "soundeffecter/002.wav" );
	Effects[ 2 ] = Mix_LoadWAV( "soundeffecter/003.wav" );
	Effects[ 3 ] = Mix_LoadWAV( "soundeffecter/004.wav" );
	Effects[ 4 ] = Mix_LoadWAV( "soundeffecter/005.wav" );
	Effects[ 5 ] = Mix_LoadWAV( "soundeffecter/006.wav" );
	Effects[ 6 ] = Mix_LoadWAV( "soundeffecter/007.wav" );
	Effects[ 7 ] = Mix_LoadWAV( "soundeffecter/008.wav" );

	Timer.start();
	When = 60000;

}

soundeffecter :: ~soundeffecter(){

	for( int i = 0; i < 8; i++ )
		Mix_FreeChunk( Effects[ i ] );

}

void soundeffecter :: play(){

	if( Timer.get_ticks() >= When ){

		When = ( rand() % 30000 ) + 10000;
		Timer.start();

		Mix_PlayChannel( -1, Effects[ rand() % 8 ], 0 );

	}

}
