-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerMenu.cpp
More file actions
74 lines (61 loc) · 2.44 KB
/
PlayerMenu.cpp
File metadata and controls
74 lines (61 loc) · 2.44 KB
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
//
// Created by viviane on 26/11/2021.
//
#include "PlayerMenu.h"
namespace menus {
PlayerMenu::PlayerMenu(){ }
PlayerMenu::~PlayerMenu(){ }
void PlayerMenu::run(){
renderMenu(PLAYER_MENU_ITENS);
if (menu_counter > menu_speed) {
if (inputs->isKeyPressed(controls.up)) {
moveUp();
menu_counter = 0;
} else if (inputs->isKeyPressed(controls.down)) {
moveDown();
menu_counter = 0;
} else if (inputs->isKeyPressed(controls.enter)) {
switch (selectedItem) {
case 1:
setMenuState(st_level_menu, 0);
setMenuState(1, 1);
break;
case 2:
setMenuState(st_level_menu, 0);
setMenuState(2, 1);
break;
case 3:
setMenuState(st_global_menu, 0);
break;
}
menu_counter = 0;
}
}
menu_counter++;
}
void PlayerMenu::initialize(){
setBackground(assets->operator[]("menu"));
loadFont();
selectedItem = 1;
text[0].setFont(*assets->getFont("fontOne"));
text[0].setFillColor(sf::Color::White);
text[0].setString("Save Saps");
text[0].setCharacterSize(220);
text[0].setPosition((WINDOW_WIDTH/2 - text[0].getGlobalBounds().width/2 ), -20);
text[1].setFont(*assets->getFont("fontThree"));
text[1].setFillColor(sf::Color::Red);
text[1].setString("One player");
text[1].setCharacterSize(50);
text[1].setPosition((WINDOW_WIDTH/2 - text[1].getGlobalBounds().width/2 ), (WINDOW_HEIGHT / 2) - 30 - text[1].getGlobalBounds().height);
text[2].setFont(*assets->getFont("fontThree"));
text[2].setFillColor(sf::Color::White);
text[2].setString("Two players");
text[2].setCharacterSize(50);
text[2].setPosition((WINDOW_WIDTH/2 - text[2].getGlobalBounds().width/2 ), WINDOW_HEIGHT/2);
text[3].setFont(*assets->getFont("fontThree"));
text[3].setFillColor(sf::Color::White);
text[3].setString("Return");
text[3].setCharacterSize(50);
text[3].setPosition((WINDOW_WIDTH/2 - text[3].getGlobalBounds().width/2 ), (WINDOW_HEIGHT / 2) + 30 + text[3].getGlobalBounds().height);
}
}