-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplashScreenState.cpp
More file actions
53 lines (45 loc) · 1.63 KB
/
Copy pathSplashScreenState.cpp
File metadata and controls
53 lines (45 loc) · 1.63 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
#include <sstream>
#include "SplashScreenState.hpp"
#include "DEFINITIONS.hpp"
#include "MainMenuState.hpp"
#include <iostream>
SplashScreenState::SplashScreenState(GameDataRef data) : _data(data) {}
void SplashScreenState::Init() {
_data->assets.LoadTexture("Splash Screen State Background", SPLASH_SCREEN_BACKGROUND_FILEPATH);
_background.setTexture(this->_data->assets.GetTexture("Splash Screen State Background"));
//_background.setTextureRect(sf::IntRect(0, 0, 622, 324));
_background.setColor(sf::Color(0,255,128,255));
_background.setPosition( (SCREEN_WIDTH - _background.getGlobalBounds().width)/2 , (SCREEN_HEIGHT - _background.getGlobalBounds().height) /2);
}
void SplashScreenState::HandleInput() {
sf::Event event;
while( _data->window.pollEvent( event )) {
switch(event.type) {
case sf::Event::Closed:
_data->window.close();
break;
case sf::Event::KeyPressed:
switch(event.key.code) {
case 0:
_data->window.close();
break;
default:
break;
}
break;
default:
break;
}
}
}
void SplashScreenState::Update(float dt) {
if(_clock.getElapsedTime().asSeconds() > SPLASH_STATE_SHOW_TIME ) {
_data->machine.AddState( StateRef( new MainMenuState(_data ) ), true);
}
}
void SplashScreenState::Draw(float dt) {
_data->window.clear();
_data->window.draw( _background );
_data->window.display();
//std::cout << ++frame_processati << std::endl;
}