-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelMenu.cpp
More file actions
80 lines (65 loc) · 2.57 KB
/
LevelMenu.cpp
File metadata and controls
80 lines (65 loc) · 2.57 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
75
76
77
78
79
80
//
// Created by viviane on 27/11/2021.
//
#include "LevelMenu.h"
namespace menus{
LevelMenu::LevelMenu() : View(), p1(), p2(), loadLevels(){
}
LevelMenu::~LevelMenu(){
}
void LevelMenu::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_run_healthy_forest, 0);
loadLevels.initialize(p1, p2);
break;
case 2:
setMenuState(st_run_infected_forest, 0);
loadLevels.initialize(p1, p2);
break;
case 3:
setMenuState(st_player_menu, 0);
break;
}
menu_counter = 0;
}
}
menu_counter++;
}
void LevelMenu::initialize(Player* p1, Player* p2){
setBackground(assets->operator[]("menu"));
loadFont();
this->p1 = p1;
this->p2 = p2;
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("Level One");
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("Level Two");
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);
}
}