Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp>
- #include <vector>
- #include <string>
- std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();
- sf::VideoMode mode = modes[0];
- using namespace sf;
- class menu{
- private:
- //unsigned int ILOSC_ELEMENTOW;
- public:
- menu(unsigned int ILOSC_ELEMENTOW, String menu[], RenderWindow &okno, Font font)
- {
- for(unsigned int i = 0; i < ILOSC_ELEMENTOW; i++)
- {
- Text tekst;
- tekst.setFont(font);
- tekst.setString(menu[i]);
- if(i==0)tekst.setCharacterSize(mode.height*0.15);
- else tekst.setCharacterSize(mode.height*0.08);
- if(i==0)tekst.setColor(Color::Cyan);
- else tekst.setColor(Color::White);
- tekst.setStyle(Text::Bold);
- if(i==0)
- {
- FloatRect tekstRect = tekst.getLocalBounds();
- tekst.setOrigin(tekstRect.width/2,tekstRect.height/2);
- tekst.setPosition(Vector2f(mode.width/2.0f,mode.height*0.05));
- }
- else
- {
- FloatRect tekstRect = tekst.getLocalBounds();
- tekst.setOrigin(tekstRect.width/2,tekstRect.height/2);
- tekst.setPosition(Vector2f(mode.width/2.0f, (mode.height*0.15)+mode.height*0.05+mode.height*0.05+(mode.height*0.1)*i));
- }
- okno.draw(tekst);
- }
- }
- };
- int main()
- {
- RenderWindow window(VideoMode(mode.width, mode.height, mode.bitsPerPixel ), "Statki V1.0", Style::Fullscreen);
- Font font;
- if (!font.loadFromFile("4mini.ttf"))
- {
- perror("Blad ladowania czcionki!");
- return 0;
- }
- String teksty[5];
- teksty[0] = "Gra Statki";
- teksty[1] = "Graj";
- teksty[2] = "Opcje";
- teksty[3] = "Statystyki";
- teksty[4] = "Wyjście";
- while (window.isOpen())
- {
- sf::Event event;
- while (window.pollEvent(event))
- {
- if (event.type == Event::Closed)
- window.close();
- if(event.type == Event::KeyPressed && event.key.code == Keyboard::Escape)
- {
- window.close();
- }
- }
- window.clear();
- menu pierwsze(5,teksty,window, font);
- window.display();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement