-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplashState.cpp
39 lines (33 loc) · 1.01 KB
/
SplashState.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
#include "SplashState.hpp"
#include "Definitions.hpp"
#include "MainMenuState.hpp"
#include <iostream>
#include <sstream>
namespace TicTacToe {
SplashState::SplashState(GameDataRef data) : _data(data) {}
void SplashState::Init() {
_data->assets.LoadTexture("Splash State Background",
SPLASH_SCENE_BACKGROUND_FILEPATH);
_background.setTexture(_data->assets.GetTexture("Splash State Background"));
}
void SplashState::HandleInput() {
sf::Event event;
while (_data->window.pollEvent(event)) {
if (sf::Event::Closed == event.type) {
_data->window.close();
}
}
}
void SplashState::Update(float dt) {
if (_clock.getElapsedTime().asSeconds() > SPLASH_STATE_SHOW_TIME) {
// go back to main menu
std::cout << "Go to main menu" << std::endl;
_data->machine.AddState(StateRef(new MainMenuState(_data)), true);
}
}
void SplashState::Draw(float dt) {
_data->window.clear(sf::Color::Red);
_data->window.draw(_background);
_data->window.display();
}
} // namespace TicTacToe