-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSplashState.cpp
54 lines (42 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include <sstream>
#include "SplashState.hpp"
#include "DEFINITIONS.hpp"
#include "MainMenuState.hpp"
#include <iostream>
namespace Sonar
{
SplashState::SplashState(GameDataRef data) : _data(data)
{
}
void SplashState::Init()
{
this->_data->assets.LoadTexture("Splash State Background", SPLASH_SCENE_BACKGROUND_FILEPATH);
_background.setTexture(this->_data->assets.GetTexture("Splash State Background"));
}
void SplashState::HandleInput()
{
sf::Event event;
while (this->_data->window.pollEvent(event))
{
if (sf::Event::Closed == event.type)
{
this->_data->window.close();
}
}
}
void SplashState::Update(float dt)
{
if (this->_clock.getElapsedTime().asSeconds() > SPLASH_STATE_SHOW_TIME)
{
// Switch To Main Menu
this->_data->machine.AddState(StateRef(new MainMenuState(_data)), true);
}
}
void SplashState::Draw(float dt)
{
this->_data->window.clear(sf::Color::Red);
this->_data->window.draw(this->_background);
this->_data->window.display();
}
}