#include "Wumbo-Texture.h"
#include "Wumbo-Functions.h"
#include "Wumbo-Sprite.h"
#include "Wumbo-Renderer.h"
#include "Wumbo-Types.h"
#include "scTitle.h"
#include "scGame.h"
#include "Wumbo-InputManager.h"
#include "Wumbo-KeyboardInput.h"

Wumbo::Texture *texDisplay5;
Wumbo::Sprite *sprDisplay5;

Wumbo::Texture *texInstruct;
Wumbo::Sprite *sprInstruct;
	int disp;
scTitle::scTitle()
{
	program = NULL;
}
scTitle::scTitle(Wumbo::Program *prog)
{
	program = prog;
}
void scTitle::begin()
{
	disp = 0;
	texDisplay5 = new Wumbo::Texture();
	texDisplay5->load(Wumbo::BundleResource("titlescreen.png"));
	texInstruct = new Wumbo::Texture();
	texInstruct->load(Wumbo::BundleResource("instructions.png"));
	Wumbo::Renderer *rend = program->getRenderer();
	
	sprDisplay5 = new Wumbo::Sprite(rend);
	sprDisplay5->setTexture(texDisplay5);
	sprDisplay5->setSubrect(0,0,0,1,1);
	sprDisplay5->setSize(1024,768);

	sprInstruct = new Wumbo::Sprite(rend);
	sprInstruct->setTexture(texInstruct);
	sprInstruct->setSubrect(0,0,0,1,1);
	sprInstruct->setSize(1024,768);

}
void scTitle::update()
{
}
void scTitle::render()
{
	glClearColor(0.6f,0.6f,0.6f,1.f);
	glClear(GL_COLOR_BUFFER_BIT);
	if (disp == 0)
	{
		texDisplay5->bind();
		sprDisplay5->setPosition(0,0);
		sprDisplay5->draw();
	}
	else
	{
		texInstruct->bind();
		sprInstruct->setPosition(0,0);
		sprInstruct->draw();
	}
	if (program->getInputManager()->getKeyboardState()->isKeyPressed(sf::Keyboard::Return))
	{
		if (disp == 1)
		{
			program->setScene(new scGame(program));
			printf("WOOHOO???\n");
		}
		disp++;
	}
}
void scTitle::end()
{
	delete sprDisplay5;
	delete texDisplay5;
}
void scTitle::onClose()
{
}
