#include "stdafx.h"
#include "Object1.h"

using namespace std;

float test1(string str)
{
  cout << str << " = ";
  float value;
  cin >> value;
  return value;
}

int main()
{
  Image* p = new Image("image1.png", 32, 32);
  p->setXY(100, 100);

  float DAlpha = 0;
  float DAngle = 0; 

  sf::RenderWindow window(sf::VideoMode(640, 480), "kychka-pc.ru/legozaur");

  while (window.isOpen())
  {
	sf::Event event;
	while (window.pollEvent(event))
	{
	  if (event.type == sf::Event::Closed) window.close();
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) 
	  { 
		cout << "setXY(x, y): " << endl;
		float x = test1("x");
		float y = test1("y");
		p->setXY(x, y);
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
	  { 
		cout << "setX(x): " << endl;
		float x = test1("x");
		p->setX(x);
	  }	  
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::E))
	  { 
	    cout << "setY(y): " << endl;
		float y = test1("y");
		p->setY(y);
	  }	  
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
	  { 
		cout << "setDXY(dx,dy): " << endl;
		float dx = test1("dx");
		float dy = test1("dy");
		p->setDXY(dx,dy);
	  }	   
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
	  {
		cout << "setDX(dx): " << endl;
		float dx = test1("dx");
		p->setDX(dx);
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
	  {
		cout << "setDY(dy): " << endl;
		float dy = test1("dy");
		p->setDY(dy);
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num1)) cout << "p->getX() = "        << p->getX()        << endl;
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num2)) cout << "p->getY() = "        << p->getY()        << endl;
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num3)) cout << "p->getAlpha() = "    << p->getAlpha()    << endl;
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num4)) cout << "p->getRotation() = " << p->getRotation() << endl;
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num5)) cout << "p->getScale() = "    << p->getScale()    << endl; 
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num6)) cout << "p->getScaleX() = "   << p->getScaleX()   << endl; 
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num7)) cout << "p->getScaleY() = "   << p->getScaleY()   << endl;
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num8)) cout << "p->getWidhtCurrent() = "  << p->getWidthCurrent()  << endl;
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Num9)) cout << "p->getHeightCurrent() = " << p->getHeightCurrent() << endl;


	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
	  {
		cout << "setAlpha(alpha): " << endl;
		float alpha = test1("alpha");
		p->setAlpha(alpha);
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::X)) 
	  {
		DAlpha = test1("dalpha");
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::C)) 
	  {
		cout << "setY(" << DAlpha <<"), (alpha = " << p->getAlpha() << ")" << endl;
		p->setDAlpha(DAlpha);
	  }

	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::V))
	  {
		cout << "setRotation(angle): " << endl;
		float angle = test1("angle");
		p->setRotation(angle);
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::B))
	  {
		cout << "rotate(angle): " << endl;
		DAngle = test1("angle");
		p->rotate(DAngle);
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::N))
	  {
		p->rotate(DAngle);
		cout << "rotate("<< DAngle <<"), (angle = " << p->getRotation() << ")" << endl;		
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::R))
	  {
		cout << "setScale(scale): " << endl;
		float scale = test1("scale");
		p->setScale(scale);
	  }
	  if(sf::Keyboard::isKeyPressed(sf::Keyboard::T))
	  {
		cout << "setScale(scaleX, scaleY): " << endl;
		float scaleX = test1("scaleX");
		float scaleY = test1("scaleY");
	    p->setScale(scaleX, scaleY);
	  }
	}

	window.clear(sf::Color(255,255,255)); // очищаем окно (добела)
	
	
	p->draw(&window); // посылаем ссылку на окно
	

	window.display(); // рисуем в окне
  }

  delete(p);
  // ===== ===== ===== =====
  //std::cout << endl;
  //system("PAUSE");
  return 0;
}