-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView.cpp
More file actions
71 lines (51 loc) · 1.47 KB
/
View.cpp
File metadata and controls
71 lines (51 loc) · 1.47 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
//
// Created by viviane on 25/11/2021.
//
#include "View.h"
namespace menus {
View::View() : Being() , text(), background(), backPosition(), inputs(nullptr), controls(){
selectedItem = 1;
menu_counter = 0;
inputs = new InputManager();
}
View::~View(){
}
void View::setBackground(sf::Sprite* background){
this->background = background;
this->background->setScale(GLOBAL_SCALE, GLOBAL_SCALE);
setPosition(0,0);
}
void View::setPosition(float x, float y){
backPosition.x = x;
backPosition.y = y;
}
sf::Vector2f View::getPosition(){
return backPosition;
}
void View::renderMenu(int items){
window->draw(background);
for (int i = 0; i < items; i++){
window->draw(text[i]);
}
}
void View::loadFont() {
assets->loadFont(FONT_1, "fontOne");
assets->loadFont(FONT_3, "fontThree");
}
void View::moveUp(){
if (selectedItem - 1 >= 1){
text[selectedItem].setFillColor(sf::Color::White);
selectedItem--;
text[selectedItem].setFillColor(sf::Color::Red);
}
}
void View::moveDown(){
if (selectedItem + 1 < MENU_ITENS){
text[selectedItem].setFillColor(sf::Color::White);
selectedItem++;
text[selectedItem].setFillColor(sf::Color::Red);
}
}
int View::menu_speed = 18;
int View::finalScore = 0;
}