// Includes
#include "template.h"
#include <string>

// Namespace
using namespace AGK;
using namespace std;

int    iCount = 0;
bool   bLoaded = false;
int    iSwitch = 0;
string sFilename;

app App;

void app::Begin(void)
{
	agk::SetVirtualResolution (1024, 768);
	agk::SetClearColor( 151,170,204 ); // light blue
	agk::SetSyncRate(60,0);
	agk::SetScissor(0,0,0,0);
}

int app::Loop (void)
{	
	iCount++;
	agk::Print(iCount);

	iSwitch = 1 - iSwitch; // Toggle Switch between 1 and 0
	if (iSwitch == 0) sFilename = "1.ogg";
	if (iSwitch == 1) sFilename = "2.ogg";

	if (agk::GetFileExists(sFilename.c_str()))
	{
			if (bLoaded)
			{
				agk::StopMusicOGG(1);
				agk::DeleteMusicOGG(1); // Sometime causes the app to stop responding
			}

			agk::LoadMusicOGG(1, sFilename.c_str());
			agk::PlayMusicOGG(1, 1);
			bLoaded = true;
	}

	agk::Sync();

	return 0; // return 1 to close app
}


void app::End (void)
{

}
