PieInlaw

MENU

Apr 8th, 2017
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SFML/Audio.hpp>
  2. #include <SFML/Graphics.hpp>
  3. #include "ResourcePath.hpp"
  4. #include <stdio.h>
  5.  
  6. using namespace sf;
  7.  
  8. bool isMove,isSelect;
  9. int paint;
  10.  
  11. void menu(RenderWindow & window)
  12. {
  13.     Texture menuTexture1, menuTexture2, menuTexture3, aboutTexture, menuBackground;
  14.     menuTexture1.loadFromFile(resourcePath() + "icong.png");
  15.     menuTexture2.loadFromFile(resourcePath() + "222.png");
  16.     menuTexture3.loadFromFile(resourcePath() +"333.png");
  17.     aboutTexture.loadFromFile( resourcePath() +"about.png");
  18.     menuBackground.loadFromFile(resourcePath() +"Penguins.jpg");
  19.     Sprite menu1(menuTexture1), menu2(menuTexture2), menu3(menuTexture3), about(aboutTexture), menuBg(menuBackground);
  20.     bool isMenu = 1;
  21.     int menuNum = 0;
  22.     menu1.setPosition(100, 30);
  23.     menu2.setPosition(100, 90);
  24.     menu3.setPosition(100, 150);
  25.     menuBg.setPosition(345, 0);
  26.    
  27.     //////////////////////////////МЕНЮ///////////////////
  28.     while (isMenu)
  29.     {
  30.         menu1.setColor(Color::White);
  31.         menu2.setColor(Color::White);
  32.         menu3.setColor(Color::White);
  33.         menuNum = 0;
  34.         window.clear(Color(129, 181, 221));
  35.        
  36.         if (IntRect(100, 30, 300, 50).contains(Mouse::getPosition(window))) { menu1.setColor(Color::Blue); menuNum = 1; }
  37.         if (IntRect(100, 90, 300, 50).contains(Mouse::getPosition(window))) { menu2.setColor(Color::Blue); menuNum = 2; }
  38.         if (IntRect(100, 150, 300, 50).contains(Mouse::getPosition(window))) { menu3.setColor(Color::Blue); menuNum = 3; }
  39.        
  40.         if (Mouse::isButtonPressed(Mouse::Left))
  41.         {
  42.             if (menuNum == 1) isMenu = false;//если нажали первую кнопку, то выходим из меню
  43.             if (menuNum == 2) { window.draw(about); window.display(); while (!Keyboard::isKeyPressed(Keyboard::Escape)); }
  44.             if (menuNum == 3)  { window.close(); isMenu = false; }
  45.            
  46.         }
  47.        
  48.         window.draw(menuBg);
  49.         window.draw(menu1);
  50.         window.draw(menu2);
  51.         window.draw(menu3);
  52.        
  53.         window.display();
  54.     }
  55.     ////////////////////////////////////////////////////
  56. }
  57.  
  58.  
  59. ///// Main /////
  60. int main(int, char const**)
  61. {
  62.     int a;
  63.     paint = 0;
  64.     isMove = false;
  65.     float dX = 0;// корректировка движения по X
  66.     float dY = 0;// по Y
  67.    
  68.    
  69.     ///// Создание окна /////
  70.     RenderWindow window(VideoMode(1080, 720), "The chess game of Boris Gelfand");
  71.     menu(window);
RAW Paste Data