Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. #include <SFML/Graphics.hpp>
  2. #include <vector>
  3. #include <string>
  4.  
  5. std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();
  6. sf::VideoMode mode = modes[0];
  7. using namespace sf;
  8.  
  9. class menu{
  10. private:
  11. //unsigned int ILOSC_ELEMENTOW;
  12. public:
  13. menu(unsigned int ILOSC_ELEMENTOW, String menu[], RenderWindow &okno, Font font)
  14. {
  15. for(unsigned int i = 0; i < ILOSC_ELEMENTOW; i++)
  16. {
  17. Text tekst;
  18. tekst.setFont(font);
  19. tekst.setString(menu[i]);
  20. if(i==0)tekst.setCharacterSize(mode.height*0.15);
  21. else tekst.setCharacterSize(mode.height*0.08);
  22. if(i==0)tekst.setColor(Color::Cyan);
  23. else tekst.setColor(Color::White);
  24. tekst.setStyle(Text::Bold);
  25. if(i==0)
  26. {
  27. FloatRect tekstRect = tekst.getLocalBounds();
  28. tekst.setOrigin(tekstRect.width/2,tekstRect.height/2);
  29. tekst.setPosition(Vector2f(mode.width/2.0f,mode.height*0.05));
  30. }
  31. else
  32. {
  33. FloatRect tekstRect = tekst.getLocalBounds();
  34. tekst.setOrigin(tekstRect.width/2,tekstRect.height/2);
  35. tekst.setPosition(Vector2f(mode.width/2.0f, (mode.height*0.15)+mode.height*0.05+mode.height*0.05+(mode.height*0.1)*i));
  36. }
  37.  
  38. okno.draw(tekst);
  39. }
  40. }
  41. };
  42.  
  43.  
  44. int main()
  45. {
  46. RenderWindow window(VideoMode(mode.width, mode.height, mode.bitsPerPixel ), "Statki V1.0", Style::Fullscreen);
  47. Font font;
  48. if (!font.loadFromFile("4mini.ttf"))
  49. {
  50. perror("Blad ladowania czcionki!");
  51. return 0;
  52. }
  53. String teksty[5];
  54. teksty[0] = "Gra Statki";
  55. teksty[1] = "Graj";
  56. teksty[2] = "Opcje";
  57. teksty[3] = "Statystyki";
  58. teksty[4] = "Wyjście";
  59. while (window.isOpen())
  60. {
  61. sf::Event event;
  62. while (window.pollEvent(event))
  63. {
  64. if (event.type == Event::Closed)
  65. window.close();
  66. if(event.type == Event::KeyPressed && event.key.code == Keyboard::Escape)
  67. {
  68. window.close();
  69. }
  70. }
  71.  
  72. window.clear();
  73. menu pierwsze(5,teksty,window, font);
  74. window.display();
  75. }
  76.  
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement