void menu() { int x, y; bool exit = false, high = false; if(!font.loadFromFile("ethnocentric rg.ttf")) { //error... }; window.clear(); sf::RectangleShape menuSquare(sf::Vector2f(550, 450)); menuSquare.setFillColor(sf::Color(75, 75, 75)); menuSquare.setOutlineThickness(4); menuSquare.setOutlineColor(sf::Color(50, 50, 50)); menuSquare.setPosition(25, 25); sf::RectangleShape play(sf::Vector2f(80, 40)); play.setFillColor(sf::Color(255, 0, 0)); play.setOutlineThickness(4); play.setOutlineColor(sf::Color(255, 50, 0)); play.setPosition(100, 350); playButton.setString("Play"); playButton.setFont(font); playButton.setCharacterSize(20); playButton.setColor(sf::Color(30, 30, 30)); playButton.setPosition(100, 357); sf::RectangleShape High(sf::Vector2f(90, 40)); High.setFillColor(sf::Color(255, 0, 0)); High.setOutlineThickness(4); High.setOutlineColor(sf::Color(255, 50, 0)); High.setPosition(300, 350); HighButton.setString("High\nScores"); HighButton.setFont(font); HighButton.setCharacterSize(15); HighButton.setColor(sf::Color(30, 30, 30)); HighButton.setPosition(300, 350); snake.setString("SNAKE 2.0"); snake.setFont(font); snake.setCharacterSize(50); snake.setColor(sf::Color(30, 30, 255)); snake.setPosition(80, 75); CreatedBy.setString("Created by\nBrandon Aderholdt\nJanuary 10th, 2014"); CreatedBy.setFont(font); CreatedBy.setCharacterSize(15); CreatedBy.setColor(sf::Color(30, 30, 70)); CreatedBy.setPosition(140, 200); window.clear(); while(true){ sf::Event event; while(window.pollEvent(event)) { if(event.type == sf::Event::Closed) window.close(); if (sf::Mouse::isButtonPressed(sf::Mouse::Left)){ sf::Vector2i localPosition = sf::Mouse::getPosition(window); x = localPosition.x; y = localPosition.y; if((x > 100) && (x < 180) && (y < 390) && (y > 350)) { exit = true; } if((x > 300) && (x < 390) && (y < 390) && (y > 350)) { high = true; } } } window.draw(menuSquare); window.draw(High); window.draw(HighButton); window.draw(play); window.draw(playButton); window.draw(snake); window.draw(CreatedBy); window.display(); if(high == true){ highScores(); window.clear(); high = false; HighButton.setString("High\nScores"); HighButton.setFont(font); HighButton.setCharacterSize(15); HighButton.setColor(sf::Color(30, 30, 30)); HighButton.setPosition(300, 350); snake.setString("SNAKE 2.0"); snake.setFont(font); snake.setCharacterSize(50); snake.setColor(sf::Color(30, 30, 255)); snake.setPosition(80, 75); playButton.setString("Play"); playButton.setFont(font); playButton.setCharacterSize(20); playButton.setColor(sf::Color(30, 30, 30)); playButton.setPosition(100, 357); CreatedBy.setString("Created by\nBrandon Aderholdt\nJanuary 10th, 2014"); CreatedBy.setFont(font); CreatedBy.setCharacterSize(15); CreatedBy.setColor(sf::Color(30, 30, 70)); CreatedBy.setPosition(140, 200); } if(exit == true){ for(int i = 4; i <= 0; i--){ play.setOutlineThickness(i); sf::sleep(sf::seconds(1)); window.draw(play); window.display(); } break; } } }
void Menu::on_btnHighScores_clicked() { emit highScores(); }