-
Notifications
You must be signed in to change notification settings - Fork 0
/
SceneTest.cpp
71 lines (60 loc) · 2.36 KB
/
SceneTest.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
#include "SceneTest.hpp"
#include "Resources.hpp"
#include "utils.hpp"
SceneTest::SceneTest(Game *g, sf::RenderWindow *w, std::string next, std::string text) : Scene(g, w, sceneTypes::testScene, "test") {
_view = _window->getDefaultView();
_next = next;
_text.setFont(Resources::pauseMenuFont);
_text.setString(text);
}
SceneTest::~SceneTest(){
}
void SceneTest::init(sf::Vector2f aux){
aux = aux;
timer = 0;
_texture = Resources::key;
_sprite.setTexture(_texture);
_sprite.setOrigin(_sprite.getLocalBounds().width/2, _sprite.getLocalBounds().height/2);
_sprite.setPosition(_window->getSize().x/2, _window->getSize().y/2);
_text.setOrigin(_text.getGlobalBounds().width/2, _text.getGlobalBounds().height/2);
_text.setPosition(_sprite.getPosition().x, _sprite.getPosition().y + _sprite.getGlobalBounds().height);
}
void SceneTest::update(float deltaTime){
timer += deltaTime;
_sprite.rotate(5*deltaTime);
float f = 1+(std::sin(timer)/4);
_text.setScale(sf::Vector2f(f,f));
}
void SceneTest::processInput(){
sf::Event event;
while(_window->pollEvent(event)){
if (event.type == sf::Event::Closed) {_window->close(); exit(0);}
if (event.type == sf::Event::KeyReleased) {
std::vector<std::string> languages = { " CAT ", " ENG ", " ESP "};
SoundManager::stopMusic("pressAnyKey");
SoundManager::playMusic("menuButtons");
int language = _selector.select(_window, languages);
extern std::string LANGUAGE;
languages = { "CAT", "ENG", "ESP"};
LANGUAGE = languages[language];
log(language, LANGUAGE);
std::string easy[3] = {" normal "," normal ", " normal "};
std::string hard[3] = {" dificil ", "hardcore", " dificil " };
std::vector<std::string> kinds = {easy[language], hard[language]};
extern int hardmode;
hardmode = _selector.select(_window, kinds);
SoundManager::stopMusic("menuButtons");
SoundManager::playMusic("pressAnyKey");
//log(hardmode, &hardmode);
changeScene(_next);//{_window->close(); exit(0);}
}
}
InputManager::update();
}
void SceneTest::render(sf::RenderTarget *target){
target->draw(_sprite);
target->draw(_text);
}
void SceneTest::resizing(){
//no tears
}