예제 #1
0
파일: Menu.cpp 프로젝트: aquix/Tank-Wars
int Menu::run(RenderWindow &window, std::vector<MenuPoint> menuPoints)
{
    int alpha = 0;

    Event event;
    bool running = true;

    Texture texGUI;
    texGUI.loadFromFile("images/GUI.png");

    Texture background;
    background.loadFromFile(backgroundPath);

    Sprite sprite;
    sprite.setTexture(background);
    sprite.setColor(Color(255, 255, 255, alpha));
    Vector2f menuPos;
    menuPos.x = view.getCenter().x - view.getSize().x / 2;
    menuPos.y = view.getCenter().y - view.getSize().y / 2;
    sprite.setPosition(menuPos);

    Font font;
    font.loadFromFile(MAIN_FONT);
  
    int choise = MENU_NULL;

    MouseCursor mouse(Vector2f(0, 0), texGUI, IntRect(30, 0, 20, 20));

    Vector2u windowSize;
    windowSize = window.getSize();

    for (std::vector<MenuPoint>::iterator it = menuPoints.begin(); it != menuPoints.end(); it++)  {
        (*it).text.setFont(font);
        //(*it).text.setCharacterSize(MENU_POINT_SIZE);
        (*it).text.setPosition((*it).pos.x + menuPos.x, (*it).pos.y + menuPos.y);
        align(*it);
    }

    if (playing) {
        alpha = alpha_max;
    }
    bool wasPlayed = false;
    while (running) {
        while (window.pollEvent(event)) {
            if (event.type == Event::Closed) {
                return (-1);
            }
        }

        if (event.type == Event::MouseButtonPressed &&
            event.key.code == Mouse::Left) {
            if (choise != MENU_NULL) {
                
                sound.setBuffer(soundBufferMenuClick);
                sound.play();

                return choise;
            }
        }
        
        for (std::vector<MenuPoint>::iterator it = menuPoints.begin();
            it != menuPoints.end(); it++) {
            (*it).text.setColor(Color(255, 255, 255, 255));
            choise = MENU_NULL;
            if (mouse.getSprite().getGlobalBounds().intersects(
                (*it).text.getGlobalBounds()) && (*it).isActive)
            {
                choise = (*it).value;
                (*it).text.setColor(Color(159, 182, 205, 255));

                sound.setBuffer(soundBufferMenuArrow);
                if (wasPlayed == false){
                    sound.play();
                    wasPlayed = true;
                }

                break;
            }
        }
        if (choise == MENU_NULL) {
            wasPlayed = false;
        }
        // ѕостепенно уменьшаем прозрачность.
        if (alpha < alpha_max) {
            alpha = alpha + 5;
        }
        sprite.setColor(Color(255, 255, 255, alpha / alpha_div));
        
        window.clear();
        window.draw(sprite);

        //  огда прозрачность = 0, отображаем текст.
        for (std::vector<MenuPoint>::iterator it = menuPoints.begin();
            it != menuPoints.end(); it++)  {
            window.draw((*it).text);
        }

        Vector2i mousePos =
            getMouseCoords(Mouse::getPosition(window), windowSize);
        mouse.update((Vector2f)mousePos);
        mouse.draw(window);
        window.display();
    }

    return (-1);
}
예제 #2
0
void menu(RenderWindow &window){

    Texture menuTexture1, menuTexture2, menuTexture3, menuTexture1_2, menuTexture2_2, menuTexture3_2, menuBackground;

    menuTexture1.loadFromFile("new_game.png");// see names of files
	menuTexture2.loadFromFile("load_game.png");
	menuTexture3.loadFromFile("exit.png");

	menuTexture1_2.loadFromFile("new_game2.png");// with bigger letters
	menuTexture2_2.loadFromFile("load_game2.png");
	menuTexture3_2.loadFromFile("exit2.png");

	menuBackground.loadFromFile("menu_background.jpg");

	Sprite menu1(menuTexture1), menu2(menuTexture2), menu3(menuTexture3), menuBg(menuBackground);

	menu1.setPosition(100, 30); // sets the position of sprite
	menu2.setPosition(100, 90);
	menu3.setPosition(100, 150);
	menuBg.setPosition(0, 0);

	while (window.isOpen())
	{
	    window.clear(Color::White);
	    menu1.setTexture(menuTexture1);
	    menu2.setTexture(menuTexture2);
	    menu3.setTexture(menuTexture3);

	    sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }


		if (IntRect(135, 40, 220, 30).contains(Mouse::getPosition(window))){
            menu1.setTexture(menuTexture1_2);
            if (Mouse::isButtonPressed(Mouse::Left)){
                game_start(window);
            }
        }
		if (IntRect(130, 100, 150, 30).contains(Mouse::getPosition(window))){
            menu2.setTexture(menuTexture2_2);
            if (Mouse::isButtonPressed(Mouse::Left))
                window.close();
        }
		if (IntRect(130, 150, 45, 30).contains(Mouse::getPosition(window))){
            menu3.setTexture(menuTexture3_2);
            if (Mouse::isButtonPressed(Mouse::Left))
                window.close();
        }

		window.draw(menuBg);
		window.draw(menu1);
		window.draw(menu2);
		window.draw(menu3);

		window.display();
	}
}
예제 #3
0
파일: Game.cpp 프로젝트: LislaV208/snake
void Game::menu()
{
    VideoMode desktop = VideoMode::getDesktopMode();
    Vector2u windowSize = window.getSize();
    window.setPosition(Vector2i(desktop.width/2 - windowSize.x/2, 10));

    Text title;
    title.setFont(font);
    title.setString("SNAKE");
    title.setCharacterSize(200);
    title.setPosition(WIDTH/2 - title.getGlobalBounds().width/2, 20);
    title.setColor(Color::Green);
    title.setStyle(Text::Bold);

    const int optionsAmount = 2;
    Text options[optionsAmount];
    string str[optionsAmount] = {"Play", "Exit"};

    int currentOption = 0;

    for (int i = 0; i < optionsAmount; i++)
    {
        options[i].setFont(font);
        options[i].setString(str[i]);
        options[i].setCharacterSize(72);
        options[i].setPosition(WIDTH/2 - options[i].getGlobalBounds().width/2, 350 + i*100);
    }

    while (state == MENU)
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                state = END;
            if (event.type == Event::KeyPressed)
            {
                if (event.key.code == Keyboard::Escape)
                    state = END;
                if (event.key.code == Keyboard::Up)
                {
                    if (currentOption > 0){
                        currentOption--;
                    }
                }
                if (event.key.code == Keyboard::Down)
                {
                    if (currentOption < optionsAmount - 1){
                        currentOption++;
                    }
                }
                if (event.key.code == Keyboard::Return)
                {
                    switch (currentOption)
                    {
                        case 0: state = GAME; break;
                        case 1: state = END; break;
                    }
                }
            }
        }



        window.clear();

        window.draw(title);
        for (int i = 0; i < optionsAmount; i++)
        {
            if (i == currentOption){
                options[i].setColor(Color::Cyan);
            }
            else {
                options[i].setColor(Color::White);
            }
            window.draw(options[i]);
        }
        window.display();
    }
}
예제 #4
0
파일: Client.cpp 프로젝트: antgar/rtype_cpp
void	Client::Start()
{
  //Creating Everything

  RenderWindow *window = RenderWindow::getInstance();
  _network = new Network();
  _UDPnetwork = new Network();
  _sound = new Sound();

  //Connecting to server

  _network->init(window->getSettings()->getPort(), ANetwork::TCP_MODE);
  std::cout << "Connecting to : " << window->getSettings()->getIP() << ":" << window->getSettings()->getPort() << std::endl;
  try {
	  _network->connect(window->getSettings()->getIP());
  }
  catch (const std::exception &e)
  {
	  std::cerr << e.what() << std::endl;
  }
  //Sending Handshake

  ANetwork::t_frame sender = CreateRequest::create((unsigned char)C_HANDSHAKE, CRC::calcCRC("Bonjour 1.0"), 0, "Bonjour 1.0");
  _network->write(sender);

  //Creating SF::window

  window->setWindow(sf::VideoMode(1920, 1080, 32), "R-Pint");
  window->setFramerateLimit(60);
  window->clear();

  //Creating Textures for splash screen

  Texture	*splashScreenTexture = new Texture();
  Sprite	*splashScreen = new Sprite();

  splashScreenTexture->loadFromFile("../common/misc/splash_screen.png");
  splashScreen->setTexture(*splashScreenTexture);
  splashScreen->setPosition(0, 0);

  //Display Splash screen and loading Ressources

  window->draw(splashScreen->getSprite());
  window->display();
  window->_ressources = new Ressources();

  window->getPanels().push(static_cast<StartPanel*>(PanelFactory::createPanel(PanelFactory::PanelType::START_PANEL)));
  window->getPanels().top()->setUserInterface();

  //Adding & playing music for Menu

  _sound->registerSound("../common/misc/mouseHover.ogg", "hover");
  _sound->registerSound("../common/misc/accessDenied.ogg", "denied");
  _sound->registerSound("../common/misc/metalDoorOpen.ogg", "door");
  _sound->registerMusic("../common/misc/laserSound.ogg", "riffle");
  _sound->registerSound("../common/misc/rocketSound.ogg", "missile");
  _sound->registerSound("../common/misc/megaLaser1.ogg", "laser");
  _sound->registerMusic("../common/misc/menuMusic1.ogg", "mainMenu");
  _sound->registerSound("../common/misc/explosion1.ogg", "explosion1");
  _sound->registerSound("../common/misc/gameOver.ogg", "endGame");
  _sound->registerMusic("../common/misc/GameMusicIntro.ogg", "gameIntro");
  _sound->registerMusic("../common/misc/GameMusicLoop.ogg", "gameLoop");
  _sound->registerSound("../common/misc/BimBamBoum.ogg", "logoSound");
  _sound->playMusic("mainMenu");

  //Threading the Read

  std::unique_ptr<AThread> t(new Thread(1));
  char str1[] = "";
  (void) str1;
  t->attach(&readdisp, (void *)str1);
  t->run();

  //Main Loop

  while(window->isOpen())
    {
      window->getPanels().top()->update();
      window->getPanels().top()->render();
      window->display();
      sf::Event event;
      while (window->pollEvent(event))
      	{
      	  window->getPanels().top()->getInputManager().methodChecker(event);
      	}
    }

  //Closing Thread and Window

  t->cancel();
  _network->close();
}
예제 #5
0
void Input::getInput(RenderWindow &window)
{

    // Tant qu'il y a des évènements à traiter...
    while (window.pollEvent(event))
    {
        // on regarde le type de l'évènement...
        switch (event.type)
        {
        // On ferme la fenêtre
        case Event::Closed:
            window.close();
            break;

        // Touche pressée
        case Event::KeyPressed:
            switch (event.key.code) // La touche qui a été pressée
            {
            case Keyboard::Escape: // Echap
                window.close();
                break;

            case Keyboard::C:
                button.jump = true;
                break;

            case Keyboard::V:
                button.attack = true;
                break;

            case Keyboard::Left:
                button.left = true;
                break;

            case Keyboard::Right:
                button.right = true;
                break;

            case Keyboard::Down:
                button.down = true;
                break;

            case Keyboard::Up:
                button.up = true;
                break;


            case Keyboard::Return:
                button.enter = true;
                break;

            default:
                break;
            }
            break;

        // Touche relâchée
        case Event::KeyReleased:
            switch (event.key.code)
            {
            case Keyboard::C:
                button.jump = false;
                break;

            case Keyboard::Left:
                button.left = false;
                break;

            case Keyboard::Right:
                button.right = false;
                break;

            case Keyboard::Down:
                button.down = false;
                break;

            case Keyboard::Up:
                button.up = false;
                break;


            case Keyboard::Return:
                button.enter = false;
                break;

            default:
                break;
            }
            break;
        default:
            break;
        }
    }
}
예제 #6
0
std::string name_enter(RenderWindow &window){

    Font font;

    std::string str;
    String text;

    font.loadFromFile("arial.ttf");

    Text name, text_ent, too_many_letters;

    bool flag = false;
    float timer = 100;
    name.setFont(font);
    name.setCharacterSize(30);
    name.setColor(Color::Black);
    name.setPosition(500, 300);

    RectangleShape rect;
    rect.setFillColor(Color::Magenta);
    rect.setOutlineThickness(5);
    rect.setOutlineColor(Color::Black);
    rect.setSize(Vector2f(120, 40));
    rect.setPosition(500, 300);

    text_ent.setFont(font);
    text_ent.setString("Enter your name. Less then 8 letters please. When you will be ready, press \"spase\"");
    text_ent.setCharacterSize(30);
    text_ent.setColor(Color::Black);
    text_ent.setPosition(50, 200);

    too_many_letters.setFont(font);
    too_many_letters.setString("To many letters");
    too_many_letters.setCharacterSize(40);
    too_many_letters.setColor(Color::Red);
    too_many_letters.setPosition(730, 300);

    std::string s = "";

    while(window.isOpen()){

        sf::Event event;
        while (window.pollEvent(event)){
            if (event.type == sf::Event::Closed)
                window.close();
            if (event.type == sf::Event::TextEntered){
                if(Keyboard::isKeyPressed(Keyboard::BackSpace) && s.size()!=0){
                    if (!s.empty())
                        s.pop_back();
                }
                else if (s.size() >= 7) {
                    flag = true;
                    timer = 100;
                }
                else if (event.text.unicode < 128 && s.size() < 7 && !flag) {
                    s.push_back((char)event.text.unicode);
                }
                if(Keyboard::isKeyPressed(Keyboard::Space) && s.size()!=0){
                    return s;
                }
            }
        }
        if(Keyboard::isKeyPressed(Keyboard::Escape))
            return "escape_code";

        window.clear(Color::Green);
        name.setString(s);
        window.draw(rect);
        if(flag){
            window.draw(too_many_letters);
            timer = timer * 0.7;
            if(timer < 10)
                flag = false;
        }
        window.draw(name);
        window.draw(text_ent);
        window.display();
    }
}
예제 #7
0
파일: Game.cpp 프로젝트: pw1602/Kurs_SFML
void Game::menu()
{
    Text title("Mechanized Techno Explorer",font,80);
    title.setStyle(Text::Bold);

    title.setPosition(1280/2-title.getGlobalBounds().width/2,20);

    const int ile = 2;

    Text tekst[ile];

    string str[] = {"Play","Exit"};
    for(int i=0; i<ile; i++)
    {
        tekst[i].setFont(font);
        tekst[i].setCharacterSize(65);

        tekst[i].setString(str[i]);
        tekst[i].setPosition(1280/2-tekst[i].getGlobalBounds().width/2,250+i*120);
    }

    while(state == MENU)
    {
        Vector2f mouse(Mouse::getPosition(window));
        Event event;

        while(window.pollEvent(event))
        {
            //Wciœniêcie ESC lub przycisk X
            if(event.type == Event::Closed || event.type == Event::KeyPressed &&
                    event.key.code == Keyboard::Escape)
                state = END;

            //klikniêcie MENU
            else if(tekst[0].getGlobalBounds().contains(mouse) &&
                    event.type == Event::MouseButtonReleased && event.key.code == Mouse::Left)
            {
                state = GAME;
            }

            //klikniêcie EXIT
            else if(tekst[1].getGlobalBounds().contains(mouse) &&
                    event.type == Event::MouseButtonReleased && event.key.code == Mouse::Left)
            {
                state = END;
            }
        }
        for(int i=0; i<ile; i++)
            if(tekst[i].getGlobalBounds().contains(mouse))
                tekst[i].setColor(Color::Cyan);
            else tekst[i].setColor(Color::White);

        window.clear();

        window.draw(title);
        for(int i=0; i<ile; i++)
            window.draw(tekst[i]);

        window.display();
    }
}
예제 #8
0
파일: smoothmouse.cpp 프로젝트: jokoon/eio
function<void()> smoothmouse(RenderWindow&window, ui &UI){
    return
        [&window, &UI](){


//void smoothmouse(RenderWindow&window, ui &UI){

// tidy code organization, here we predeclare methods just like a header would, it's redundant but necessary
    function<void()> draw, loop, init, update;
    function<void(Vec2 pos)> mousemoved;
    function<void(sf::Mouse::Button button)> mouseclick, mouserelease;
    function<void(Event&e)> treatotherevent;
    function<void(Keyboard::Key k)> treatkeyevent;

    // we don't have a class/interface/struct with data, everything is local to this function, like a classic stack that all programs are anyway.
    Texture cursor_tx;
    Sprite cursor;
    configfile cfg;
    cfg.init("bedlab.cfg");
    if (!cursor_tx.loadFromFile(cfg.getstr("cursor")))
        cout << "did not load cursor" << endl;
    cursor.setTexture(cursor_tx);
    cursor.setOrigin(3, 3);
    window.setMouseCursorVisible(false);

    float lag;
    SET(lag);

    CircleShape cursorlag(10);
    //cursor.setFillColor(Color::White);
        
    cursorlag.setFillColor(Color(255,0,0,128));
    recenter(cursorlag);
    Vec2 mpos;

    //then we actually define the functions, note how all function captures the local context by reference

    draw = [&](){
        UI.draw(window); 
        window.draw(cursor); 
        window.draw(cursorlag); 
    };
    update = [&](){
        Vec2 trans = cursorlag.getPosition() - cursor.getPosition();
        auto dist = vectlen(trans);
        //cursorlag.move(-(trans)*lag); // equivalent of getposition()+-trans*.01f
        //cursorlag.move(-normalized(trans)*max(dist*dist, 100.f)*lag); // equivalent of getposition()+-trans*.01f
        Vec2 move = vectlen(trans) > 0 ?
            -normalized(trans)*dist*lag
            :Vec2{0,0};
        cursorlag.move(move); // equivalent of getposition()+-trans*.01f

        show(cursorlag.getPosition());
        show(dist);
        show(trans);
    };
    loop = [&](){
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                switch (event.type)
                {
                case sf::Event::KeyPressed:
                    if (event.key.code == sf::Keyboard::Escape)
                        window.close();
                    treatkeyevent(event.key.code);
                    break;
                case sf::Event::Closed:
                    window.close();
                    break;
                case sf::Event::MouseButtonPressed:
                    mouseclick(event.mouseButton.button);
                    break;
                case sf::Event::MouseButtonReleased:
                    mouserelease(event.mouseButton.button);
                    break;
                case sf::Event::MouseMoved:
                    mpos = Vec2(event.mouseMove.x, event.mouseMove.y);
                    mousemoved(mpos);
                    break;
                default:
                    treatotherevent(event);
                    break;
                }
            }

            window.clear();
            update();
            draw();

            //window.draw(shape);
            UI.draw(window);
            window.display();

        }
    };
    treatkeyevent = [&](Keyboard::Key k){
        switch (k) {
        case Keyboard::Space:
            cursorlag.setPosition(mpos);
            cursor.setPosition(mpos);
        
        }
    };
    mousemoved = [&](Vec2 pos){
        //msg(pos);
        cursor.setPosition(pos);
        //UI.put(mpos);
        show(mpos);
    };
    treatotherevent = [&](Event&e){

    };
    mouseclick = [&](sf::Mouse::Button button){

    };
    mouserelease = [&](sf::Mouse::Button button){

    };

    loop();
    };
}
예제 #9
0
파일: main.cpp 프로젝트: gigak/game
int main()
	{
		RenderWindow window (VideoMode (1200, 600), "SpiceCrip"); 


		Texture HeroShip;
		HeroShip.loadFromFile("ships.png"); 

		AnimationManager anim;
		//anim.create("fire", HeroShip, 195, 100, 71, 35, 1, 0.004, 35);

		anim.create("fly", HeroShip, 35, 42, 81, 80, 1, 0.004, 80);

		Texture Cosmos;
		Cosmos.loadFromFile("front.jpg");

		Texture CosmosTwo;
		CosmosTwo.loadFromFile("front.jpg");

		Texture Stars;
		Stars.loadFromFile("stars.png");

		

		PLAYER Ship(HeroShip);


		std::list<Bullet*> bullets; // список указателей пулей
		std::list<Bullet*>::iterator it;


		pBack fBack(Cosmos);
		//pBack sBack(Stars);
		pBack secondBack(CosmosTwo);
		fBack.pSprite.setPosition(0, 0);
		secondBack.pSprite.setPosition(0, -598);
		//sBack.pSprite.setRotation(20);
		//sBack.pSprite.setPosition(300,10);
		Clock clock;
		while (window.isOpen())
			{

				float time = clock.getElapsedTime().asMicroseconds();
				clock.restart();
				time = time/600;
				Event event;

				while (window.pollEvent(event))
					{ 
						if (event.type == Event::Closed)
						window.close();

						if(event.type == Event::KeyPressed)
							if (event.key.code==Keyboard::Space)
								   	bullets.push_back(new Bullet(Ship.sprite.getPosition().x - 73,Ship.sprite.getPosition().y - 30, 1,5) );	
				

					}

				
			
			

				if ((Keyboard::isKeyPressed(Keyboard::Left) || Keyboard::isKeyPressed(Keyboard::A)) & !(Ship.sprite.getPosition().x < 1)){
					Ship.sprite.move(-0.8*time,0);

				}

				if ((Keyboard::isKeyPressed(Keyboard::Right) || Keyboard::isKeyPressed(Keyboard::D)) & !(Ship.sprite.getPosition().x > 1070)){
					
					Ship.sprite.move(0.8*time,0);
					
				}

				if ((Keyboard::isKeyPressed(Keyboard::Down)  || Keyboard::isKeyPressed(Keyboard::S))  & !(Ship.sprite.getPosition().y > 540)){
					
					Ship.sprite.move(0,0.8*time);				
				}

				if ((Keyboard::isKeyPressed(Keyboard::Up)  || Keyboard::isKeyPressed(Keyboard::W))  & !(Ship.sprite.getPosition().y < 1) ){Ship.sprite.move(0,-0.8*time);}

					if ( fBack.pSprite.getPosition().y >= 598.f )
						fBack.pSprite.setPosition( 0.f, -598.f );
					if ( secondBack.pSprite.getPosition().y >= 598.f )
						secondBack.pSprite.setPosition( 0.f, -598.f );
				
	


			


				anim.tick(time);
				//Ship.update(time);
				window.clear();
				fBack.MoveBack();
				secondBack.MoveBack();

				//window.clear(Color::Black);
				window.draw(secondBack.pSprite);
				window.draw(fBack.pSprite);
			//	window.draw(sBack.pSprite);
				window.draw(Ship.sprite);


				for( it = bullets.begin(); it != bullets.end();  )
		        {
				   // ll whatsup = ( *it )->whatsup( enemys, score, time );
			        if( Ship.sprite.getPosition().y < 1 )
					{
						Bullet *deadBullet = *it;
						it = bullets.erase( it );
						delete deadBullet;
					}
			        else
			       {
				        ( *it )->draw( window, time );
				        ++it;
						
			        }
				}




				window.display();

			
   }

   return 0;
}
예제 #10
0
void settings(Keyboard::Key * keys, RenderWindow &window, Sprite background, Sprite button_background, Font font)
{
    Text button[7];
    int selected_button = -1;
    std::string str[7] = {"Green: ", "Red: ", "Yellow: ", "Blue: ", "Orange: ", "Rock power: ", "Back"};
    Color selected_button_color = Color(123, 4 ,2);
    Color unselected_button_color = Color(198, 138, 72);
    bool flag[6] = {false, false, false, false, false, false};
    for (int i = 0; i < 6; i++)
    {
        button[i].setColor(unselected_button_color);
        button[i].setString(str[i] + fromKeyboardToChar(keys[i]));
        button[i].setPosition(BUTTON_FIRST_POS_X - str[i].length() * 10, BUTTON_FIRST_POS_Y + i * BUTTON_DELTA_POS);
        button[i].setCharacterSize(30);
        button[i].setFont(font);
    }
    button[6].setColor(unselected_button_color);
    button[6].setString(str[6]);
    button[6].setPosition(BUTTON_FIRST_POS_X - str[6].length() * 10, BUTTON_FIRST_POS_Y + 6 * BUTTON_DELTA_POS);
    button[6].setCharacterSize(30);
    button[6].setFont(font);
    Vector2i mouse_pos;
    while (window.isOpen())
    {

        Event event;
        mouse_pos = Mouse::getPosition();
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();

            if (event.type == Event::MouseButtonPressed && event.mouseButton.button == Mouse::Left)
            {
                if (button[selected_button].getGlobalBounds().contains(mouse_pos.x, mouse_pos.y))
                {
                    switch (selected_button) {
                    case 0:
                        break;
                    case 1:
                        break;

                    case 2:

                        break;

                    case 3:

                        break;

                    case 4:
                        break;
                    case 5:

                        break;
                    case 6:
                        return;
                        break;
                    default:
                        break;
                    }
                    flag[selected_button] = true;
                }
                else
                {
                    for (int i = 0; i < 6; i++)
                        flag[i] = false;
                    selected_button = -1;

                }

            }
            if (event.type == Event::KeyPressed && selected_button != -1 && flag[selected_button])
            {
                bool flag1 = true;
                for (int i = 0; i < 6; i++)
                    if (keys[i] == event.key.code)
                    {
                        flag1 = false;
                        break;
                    }
                if (flag1)
                {
                    button[selected_button].setString(str[selected_button] + fromKeyboardToChar(event.key.code));
                    keys[selected_button] = event.key.code;
                }
            }



        }
        window.clear();
        window.draw(background);
        mouse_pos = Mouse::getPosition(window);
        for (int i = 0; i < 7; i++)
        {
            if (button[i].getGlobalBounds().contains(mouse_pos.x, mouse_pos.y))
            {
                selected_button = i;
            }
        }
        for (int i = 0; i < 7; i++)
        {
            if (i == selected_button)
            {
                button[i].setColor(selected_button_color);
                button_background.setScale(button[i].getGlobalBounds().width + 10, button[i].getGlobalBounds().height + 10);
                button_background.setPosition(button[i].getGlobalBounds().left - 5, button[i].getGlobalBounds().top - 5);
                window.draw(button_background);
            }
            else
            {
                button[i].setColor(unselected_button_color);
            }

            window.draw(button[i]);
        }
        window.display();
    }
}