//	World4.cpp - One of the worlds.
//  ----------------------------------------------------------------------------
//	This file is part of 'NiallsAVLib', base code for any kind of audiovisual
//	apps.
//	Copyright (C) 2012  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 "World4.h"

//------------------------------------------------------------------------------
World4::World4():
World(ThreeFloats(184.0f/255.0f, 113.0f/255.0f, 180.0f/255.0f),
	  ThreeFloats(27.0f/255.0f, 71.0f/255.0f, 161.0f/255.0f),
	  ThreeFloats(204.0f/255.0f, 49.0f/255.0f, 45.0f/255.0f),
	  ThreeFloats(0.0f/255.0f, 195.0f/255.0f, 202.0f/255.0f),
	  ThreeFloats(1.0f, 0.45f, 0.15f),
	  TwoFloats(4560.0f, -80.0f)),
mousePos(0.0f, 0.0f),
worldPos(0.0f, 0.0f),
centrePos(640.0f, 360.0f),
done(false)
{

}

//------------------------------------------------------------------------------
World4::~World4()
{

}

//------------------------------------------------------------------------------
void World4::mouseMove(const TwoFloats& pos)
{
	mousePos.x = 1280.0f-pos.x;
	mousePos.y = 720.0f-pos.y;
}

//------------------------------------------------------------------------------
void World4::subclassTick()
{
	float tempf;
	if(worldPos != mousePos)
	{
		worldPos += (mousePos-worldPos) * 0.05f;
		if(worldPos.getDistance(mousePos) < 1.0f)
			worldPos = mousePos;
		setPosition(TwoFloats(4560.0f-640.0f, -80.0f-360.0f) + worldPos);
	}

	tempf = (0.1f + ((1.0f-(worldPos.getDistance(centrePos)/640.0f)) * 0.9f)) * 0.66f;
	setOverallScale(tempf);

	if(worldPos.getDistance(centrePos) < 32.0f)
	{
		worldPos = centrePos;
		setPosition(TwoFloats(4560.0f-640.0f, -80.0f-360.0f) + worldPos);

		done = true;
	}
}
