-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.cpp
87 lines (56 loc) · 1.75 KB
/
menu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "Menu.h"
using namespace sf;
Menu::Menu(float width, float height)
{
if (!font.loadFromFile("pacman.ttf"))
cout << "erorr" << endl;
menu[0].setFont(font);
menu[0].setCharacterSize(60);
menu[0].setFillColor(Color::Red);
menu[0].setString("Start Game");
menu[0].setPosition(Vector2f(width / 17, height / (Max_members_of_Items + 2) * 2));
menu[1].setFont(font);
menu[1].setFillColor(Color::White);
menu[1].setCharacterSize(60);
menu[1].setString("Controls ");
menu[1].setPosition(Vector2f(width / 17, height / (Max_members_of_Items + 2) * 3));
menu[2].setFont(font);
menu[2].setFillColor(Color::White);
menu[2].setCharacterSize(60);
menu[2].setString("Contain ");
menu[2].setPosition(Vector2f(width / 17, height / (Max_members_of_Items + 2) * 4));
menu[3].setFont(font);
menu[3].setFillColor(Color::White);
menu[3].setCharacterSize(60);
menu[3].setString("About");
menu[3].setPosition(Vector2f(width / 17, height / (Max_members_of_Items + 2) * 5));
menu[4].setFont(font);
menu[4].setFillColor(Color::White);
menu[4].setCharacterSize(60);
menu[4].setString("Quit ");
menu[4].setPosition(Vector2f(width / 17, height / (Max_members_of_Items + 2) * 6));
selecteditemindex = 0;
}
Menu::~Menu()
{
}
void Menu::draw(RenderWindow &window) {
for (int i = 0; i < Max_members_of_Items; i++) {
window.draw(menu[i]);
}
}
//motion arrows
void Menu::MoveUp() {
if (selecteditemindex - 1 >= 0) {
menu[selecteditemindex].setFillColor(Color::White);
selecteditemindex--;
menu[selecteditemindex].setFillColor(Color::Red);
}
}
void Menu::MoveDown() {
if (selecteditemindex + 1 < Max_members_of_Items) {
menu[selecteditemindex].setFillColor(Color::White);
selecteditemindex++;
menu[selecteditemindex].setFillColor(Color::Red);
}
}