-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainMenu.cpp
65 lines (53 loc) · 1.29 KB
/
MainMenu.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
#include "../MainMenu.h"
#include <SFML/Audio.hpp>
Menu::Menu(float width, float height)
{
if (!font.loadFromFile("resources/mainmenufont.ttf"))
{
std::cout << "Loading Failed" << std::endl;
}
menu[0].setFont(font);
menu[0].setColor(sf::Color::Green);
menu[0].setString("START GAME");
menu[0].setScale(2,2);
menu[0].setPosition(sf::Vector2f(width / 8, height / 3));
menu[1].setFont(font);
menu[1].setColor(sf::Color::White);
menu[1].setString("HIGHSCORE");
menu[1].setScale(2,2);
menu[1].setPosition(sf::Vector2f(width / 8, height / 2));
menu[2].setFont(font);
menu[2].setColor(sf::Color::White);
menu[2].setString("EXIT");
menu[2].setScale(2,2);
menu[2].setPosition(sf::Vector2f(width / 8, height / 1.5));
selectedItemIndex = 0;
}
Menu::~Menu()
{
}
void Menu::draw(sf::RenderWindow &window)
{
for (int i = 0; i < MAX_NUMBER_OF_ITEMS; i++)
{
window.draw(menu[i]);
}
}
void Menu::MoveUp()
{
if (selectedItemIndex - 1 >= 0)
{
menu[selectedItemIndex].setColor(sf::Color::White);
selectedItemIndex--;
menu[selectedItemIndex].setColor(sf::Color::Green);
}
}
void Menu::MoveDown()
{
if (selectedItemIndex + 1 < MAX_NUMBER_OF_ITEMS)
{
menu[selectedItemIndex].setColor(sf::Color::White);
selectedItemIndex++;
menu[selectedItemIndex].setColor(sf::Color::Green);
}
}