Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. void Menu(RenderWindow& window, int& chose) {
  2. chose = 1;
  3. Cube menu_bg("menu_bg");
  4. Font font;
  5. font.loadFromFile("trajan.ttf");
  6. Text Play, Options, Exit, Score;
  7. Play.setString(" Play ");
  8. Options.setString(" Options");
  9. Exit.setString(" Exit ");
  10. Score.setString("Show scoreboard");
  11. Score.setFont(font); Score.setFillColor(Color(15, 141, 0)); Score.setPosition(80, 115 * 3);
  12. Play.setFont(font); Options.setFont(font); Exit.setFont(font);
  13. Play.setFillColor(Color(15, 141, 0)); Options.setFillColor(Color(15, 141, 0)); Exit.setFillColor(Color(15, 141, 0));
  14. Play.setPosition(180, 115 * 1); Options.setPosition(160, 115 * 2); Exit.setPosition(160, 115 * 4);
  15.  
  16. Play.setOutlineThickness(2); Play.setOutlineColor(Color(0, 0, 0));
  17. Options.setOutlineThickness(2); Options.setOutlineColor(Color(0, 0, 0));
  18. Score.setOutlineThickness(2); Score.setOutlineColor(Color(0, 0, 0));
  19. Exit.setOutlineThickness(2); Exit.setOutlineColor(Color(0, 0, 0));
  20. while (window.isOpen()) {
  21. Event event;
  22. while (window.pollEvent(event)) {
  23. if (event.type == Event::Closed) {
  24. chose = 5;
  25. return;
  26. }
  27. if (event.type == Event::KeyPressed) {
  28. if (event.key.code == Keyboard::Escape) {
  29. chose = 5;
  30. return;
  31. }
  32. if (event.key.code == Keyboard::Up) {
  33. chose--;
  34. std::cout << "Up\n";
  35. if (chose < 1) {
  36. std::cout << "chose > 1\n";
  37. chose = 1;
  38. }
  39. }
  40. if (event.key.code == Keyboard::Down) {
  41. chose++;
  42. std::cout << "Down\n";
  43. if (chose > 4) {
  44. std::cout << "chose > 4\n";
  45. chose = 4;
  46. }
  47. }
  48. if (event.key.code == Keyboard::Enter) {
  49. return;
  50. }
  51. }
  52. }
  53. switch (chose) {
  54. case 1:
  55. Play.setStyle(Text::Bold); Options.setStyle(Text::Regular); Score.setStyle(Text::Regular); Exit.setStyle(Text::Regular);
  56. Play.setCharacterSize(46); Options.setCharacterSize(38); Score.setCharacterSize(38); Exit.setCharacterSize(38);
  57. break;
  58. case 2:
  59. Play.setStyle(Text::Regular); Options.setStyle(Text::Bold); Score.setStyle(Text::Regular); Exit.setStyle(Text::Regular);
  60. Play.setCharacterSize(38); Options.setCharacterSize(46); Score.setCharacterSize(38); Exit.setCharacterSize(38);
  61. break;
  62. case 3:
  63. Play.setStyle(Text::Regular); Options.setStyle(Text::Regular); Score.setStyle(Text::Bold); Exit.setStyle(Text::Regular);
  64. Play.setCharacterSize(38); Options.setCharacterSize(38); Score.setCharacterSize(46); Exit.setCharacterSize(38);
  65. break;
  66. case 4:
  67. Play.setStyle(Text::Regular); Options.setStyle(Text::Regular); Score.setStyle(Text::Regular); Exit.setStyle(Text::Bold);
  68. Play.setCharacterSize(38); Options.setCharacterSize(38); Score.setCharacterSize(38); Exit.setCharacterSize(46);
  69. //Play.setPosition(150, 100 * 1); Options.setPosition(160, 100 * 2); Exit.setPosition(160, 100 * 3); Exit.setPosition(160, 100 * 4);
  70. break;
  71. }
  72. std::cout << "Chose: " << chose << std::endl;
  73. window.clear();
  74. window.draw(menu_bg.sprite);
  75. window.draw(Play);
  76. window.draw(Options);
  77. window.draw(Exit);
  78. window.draw(Score);
  79. window.display();
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement