Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Menu(RenderWindow& window, int& chose) {
- chose = 1;
- Cube menu_bg("menu_bg");
- Font font;
- font.loadFromFile("trajan.ttf");
- Text Play, Options, Exit, Score;
- Play.setString(" Play ");
- Options.setString(" Options");
- Exit.setString(" Exit ");
- Score.setString("Show scoreboard");
- Score.setFont(font); Score.setFillColor(Color(15, 141, 0)); Score.setPosition(80, 115 * 3);
- Play.setFont(font); Options.setFont(font); Exit.setFont(font);
- Play.setFillColor(Color(15, 141, 0)); Options.setFillColor(Color(15, 141, 0)); Exit.setFillColor(Color(15, 141, 0));
- Play.setPosition(180, 115 * 1); Options.setPosition(160, 115 * 2); Exit.setPosition(160, 115 * 4);
- Play.setOutlineThickness(2); Play.setOutlineColor(Color(0, 0, 0));
- Options.setOutlineThickness(2); Options.setOutlineColor(Color(0, 0, 0));
- Score.setOutlineThickness(2); Score.setOutlineColor(Color(0, 0, 0));
- Exit.setOutlineThickness(2); Exit.setOutlineColor(Color(0, 0, 0));
- while (window.isOpen()) {
- Event event;
- while (window.pollEvent(event)) {
- if (event.type == Event::Closed) {
- chose = 5;
- return;
- }
- if (event.type == Event::KeyPressed) {
- if (event.key.code == Keyboard::Escape) {
- chose = 5;
- return;
- }
- if (event.key.code == Keyboard::Up) {
- chose--;
- std::cout << "Up\n";
- if (chose < 1) {
- std::cout << "chose > 1\n";
- chose = 1;
- }
- }
- if (event.key.code == Keyboard::Down) {
- chose++;
- std::cout << "Down\n";
- if (chose > 4) {
- std::cout << "chose > 4\n";
- chose = 4;
- }
- }
- if (event.key.code == Keyboard::Enter) {
- return;
- }
- }
- }
- switch (chose) {
- case 1:
- Play.setStyle(Text::Bold); Options.setStyle(Text::Regular); Score.setStyle(Text::Regular); Exit.setStyle(Text::Regular);
- Play.setCharacterSize(46); Options.setCharacterSize(38); Score.setCharacterSize(38); Exit.setCharacterSize(38);
- break;
- case 2:
- Play.setStyle(Text::Regular); Options.setStyle(Text::Bold); Score.setStyle(Text::Regular); Exit.setStyle(Text::Regular);
- Play.setCharacterSize(38); Options.setCharacterSize(46); Score.setCharacterSize(38); Exit.setCharacterSize(38);
- break;
- case 3:
- Play.setStyle(Text::Regular); Options.setStyle(Text::Regular); Score.setStyle(Text::Bold); Exit.setStyle(Text::Regular);
- Play.setCharacterSize(38); Options.setCharacterSize(38); Score.setCharacterSize(46); Exit.setCharacterSize(38);
- break;
- case 4:
- Play.setStyle(Text::Regular); Options.setStyle(Text::Regular); Score.setStyle(Text::Regular); Exit.setStyle(Text::Bold);
- Play.setCharacterSize(38); Options.setCharacterSize(38); Score.setCharacterSize(38); Exit.setCharacterSize(46);
- //Play.setPosition(150, 100 * 1); Options.setPosition(160, 100 * 2); Exit.setPosition(160, 100 * 3); Exit.setPosition(160, 100 * 4);
- break;
- }
- std::cout << "Chose: " << chose << std::endl;
- window.clear();
- window.draw(menu_bg.sprite);
- window.draw(Play);
- window.draw(Options);
- window.draw(Exit);
- window.draw(Score);
- window.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement