//Sprite ciz

#include "mostemp.h"

bool byeni=false;
bool bskor=false;
bool bkapa=false;

void MenuYaz()
{
	CHAR menuy[200];


	sprintf(menuy,"<-Yeni Oyun->");
	font.YazRenk(240,220,menuy,1,240,220,255,255);
	
	sprintf(menuy,"<-Yuksek Skorlar->");
	font.YazRenk(220,265,menuy,1,240,220,255,255);
	
	sprintf(menuy,"<-Kapat->");
	font.YazRenk(250,310,menuy,1,240,220,255,255);	
}
void YeniButton()
{
	//Yeni
	if(button.Bas(220,210,sopa.GetWidth()+20,sopa.GetHeight(),mx,my)==TRUE)
	{
		sopa.SetRenk(1,1,1);
		lava2.SetRenk(1,1,1);
		byeni=true;
		
		if (Input.GetKeyState(CDXKEY_MOUSELEFT)==CDXKEY_PRESS)
	{
		sopa.SetRenk(0,0,1);
		lava2.SetRenk(0,1,0);
		
	}
	if (Input.GetKeyState(CDXKEY_MOUSELEFT)==CDXKEY_RELEASE)
	{
		
		Ps = PS_RESETGAME;
		
	}
	
	}else
	{

        sopa.SetRenk(0.7,0.7,1);
		lava2.SetRenk(0.3,0.3,3);
		byeni=false;
	}


}
void SkorButton()
{
	//Yeni
	if(button.Bas(210,255,sopa.GetWidth()+20,sopa.GetHeight(),mx,my)==TRUE)
	{
	/*	sopa.SetRenk(1,1,1);
		lava2.SetRenk(1,1,1);*/
			sopa.SetRenk(1,0.6,1);
	lava2.SetRenk(0.4,0.4,1);
	bskor=true;
	
	}else
	{

        sopa.SetRenk(0.7,0.7,1);
		lava2.SetRenk(0.3,0.3,3);
		bskor=false;
	}


}

void KapaButton()
{
	/*
	#define CDXKEY_NONE				0
#define CDXKEY_RELEASE			1
#define CDXKEY_PRESS			2
#define CDXKEY_REPEAT			3
	*/
	//Yeni
	if(button.Bas(220,300,sopa.GetWidth()+20,sopa.GetHeight(),mx,my)==TRUE)
	{
		sopa.SetRenk(1,1,1);
		lava2.SetRenk(1,1,1);
		bkapa=true;

		if (Input.GetKeyState(CDXKEY_MOUSELEFT)==CDXKEY_PRESS)
	{
		sopa.SetRenk(0,0,1);
		lava2.SetRenk(0,1,0);
		
	}
	if (Input.GetKeyState(CDXKEY_MOUSELEFT)==CDXKEY_RELEASE)
	{
		
		SendMessage(g_hWnd, WM_CLOSE, 0, 0);
	
		return;
		
	}
	
	
	}else
	{

        sopa.SetRenk(0.7,0.7,1);
		lava2.SetRenk(0.3,0.3,3);
		bkapa=false;
	}


}

void MenuCiz()
{

	sopa.en = 148;
	sopa.boy = 32;

	YeniButton();
	
	lava2.en = 148;
	lava2.boy = 16;
	lava2.SetPos(230,220);
	if(byeni==FALSE)
	{
   // lava2.Draw(GL_SPRITE_NORMAL,true,false);
	}else
	{
	lava2.Draw(GL_SPRITE_TRANS_UV_DOWN,true);
	}
	//Yeni Oyun
	sopa.SetPos(230,210);
	sopa.Draw(GL_SPRITE_TRANS_UV_RIGHT,true,false);
		



	SkorButton();

	lava2.en = 148;
	lava2.boy = 16;
	lava2.SetPos(230,265);
	if(bskor==FALSE)
	{
	//lava2.Draw(GL_SPRITE_NORMAL,true,false);
	}else
	{
	lava2.Draw(GL_SPRITE_TRANS_UV_DOWN,true);
	}
	
	//Skorlar
	sopa.SetPos(230,255);
	sopa.Draw(GL_SPRITE_TRANS_UV_RIGHT,true,false);
		


	KapaButton();
	//Kapat
	lava2.en = 148;
	lava2.boy = 16;
	lava2.SetPos(230,310);
	if(bkapa==FALSE)
	{
//lava2.Draw(GL_SPRITE_NORMAL,true,false);
	}else
	{
	lava2.Draw(GL_SPRITE_TRANS_UV_DOWN,true);
	}

	sopa.SetPos(230,300);
	sopa.Draw(GL_SPRITE_TRANS_UV_RIGHT,true,false);
		



	MenuYaz();
	
}
void TopDraw()
{	
		
	top.SetPosX(top.GetPosX() + top.GetVelX()*(pencere.g_ZamanSayaci*40));
		top.SetPosY(top.GetPosY() + top.GetVelY()*(pencere.g_ZamanSayaci*40));

		if(top.GetPosX() < 0)
		{
			top.SetVelX(top.GetVelX() - (2 * top.GetVelX()));
            top.SetPosX(1);
		}
		if(top.GetPosX() > (640 - top.en))
		{
			top.SetVelX(top.GetVelX() - (2 * top.GetVelX()));
			top.SetPosX(639 - top.en);
		}
		if(top.GetPosY() < 0)
		{
			top.SetVelY(top.GetVelY() - (2 * top.GetVelY()));
			top.SetPosY(1);
		}
		if(top.GetPosY() > (480 - top.boy))
		{
			//pencere.g_ZamanSayaci
			top.SetVelY(top.GetVelY() - (2 * top.GetVelY()));
			top.SetPosY(479 - top.boy);
		}

	
	top.Draw(GL_SPRITE_TRANS,true,true);

}
void sinirla()
{

	sopa.en = 640;
	sopa.boy = 50;
	sopa.SetRenk(1,1,1);
	sopa.SetPos(0,160);
	sopa.Draw(GL_SPRITE_TRANS_UV_LEFT,true,false);

	sopa.en = 640;
	sopa.boy = 50;
	sopa.SetRenk(1,1,1);
	sopa.SetPos(0,340);
	sopa.Draw(GL_SPRITE_TRANS_UV_LEFT,true,false);

	//DENIZ
    sopa.en = 640;
	sopa.boy = 25;
	sopa.SetRenk(1,1,1);
	sopa.SetPos(0,180);
	sopa.Draw(GL_SPRITE_TRANS_UV_RIGHT,true,false);
		
	lava2.en = 640;
	lava2.boy = 10;
	lava2.SetPos(0,185);
	lava2.SetRenk(1,1,1);
	lava2.Draw(GL_SPRITE_TRANS_UV_DOWN,true); 
	
	sopa.en = 640;
	sopa.boy = 25;
	sopa.SetRenk(1,1,1);
	sopa.SetPos(0,360);
	sopa.Draw(GL_SPRITE_TRANS_UV_RIGHT,true,false);
		
	lava2.en = 640;
	lava2.boy = 10;
	lava2.SetPos(0,363);
	lava2.SetRenk(1,0,1);
	lava2.Draw(GL_SPRITE_TRANS_UV_DOWN,true);
     //---------------



}
void logociz()
{
	//TurkOp logo
	logo.en=200;
	logo.boy=100;
	logo.SetPos(430,10);
	logo.Draw(GL_SPRITE_NORMAL,true);

	lava.en = 200;
	lava.boy = 100;
	lava.SetPos(430,10);
	lava.Draw(GL_SPRITE_TRANS_UV_UP,true);
	
	lava2.en = 200;
	lava2.boy = 100;
	lava2.SetPos(430,10);
	lava2.SetRenk(1,1,1);
	lava2.Draw(GL_SPRITE_TRANS_UV_DOWN,true);
}
void Spritelariciz()
{
	//pencere.g_ZamanSayaci
	static float r,g,b=0;

	arka.SetPos(0,0);
	arka.Draw(GL_SPRITE_NORMAL_TILE,true);
	arka.SetRenk(1.3,1,1);

	
	logociz();
 	sinirla();
	MenuCiz();


	 r +=0.001;
	 g += 0.001;
	 b += 0.002;
	 if(r > 1)
	 {
		 r = 0;
	 }
 if(b > 1)
	 {
		 b = 0;
	 } if(g > 1)
	 {
		 g = 0;
	 }
	 

	// TopDraw();
	
	mouse.SetPos((float)mx,(float)my);
	mouse.SetRenk(r,g,b);
	mouse.Draw(GL_SPRITE_TRANS,true);

	

}