-
Notifications
You must be signed in to change notification settings - Fork 9
/
TitleScreen.cpp
50 lines (48 loc) · 1.07 KB
/
TitleScreen.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
#include "TitleScreen.h"
#include "Application.h"
TitleScreen::TitleScreen() :
AppState(TitleScreenState),
bg(Application::getTexture(TitleBg)),
mainMenu(Application::getFont(FreeSans),40)
{
mainMenu.add("Play",sf::Color::White);
mainMenu.add("Exit",sf::Color::White);
mainMenu.setSelectionBgColor(sf::Color(0,0,0,100));
mainMenu.create(constants::windowWidth,0);
mainMenu.setPosition(0,300);
}
TitleScreen::~TitleScreen()
{
//dtor
}
void TitleScreen::reset()
{}
void TitleScreen::draw(sf::RenderWindow &window)
{
window.draw(bg);
mainMenu.draw(window);
}
void TitleScreen::update(float dt)
{
mainMenu.step(dt);
int query = mainMenu.querySelecion();
if(query >= 0)
{
switch(query)
{
case 0://Play
Application::changeState(GameSetupState);
break;
case 1://Exit
Application::quit();
break;
default:
PRINT_VAR(query)
break;
}
}
}
void TitleScreen::passEvent(sf::Event event)
{
mainMenu.passEvent(event);
}