-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainMenuState.cpp
More file actions
104 lines (88 loc) · 2.92 KB
/
MainMenuState.cpp
File metadata and controls
104 lines (88 loc) · 2.92 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "MainMenuState.h"
MainMenuState::MainMenuState():State()
{
std::cout << "Konstruktor MainMenuState!" << std::endl;
}
void MainMenuState::Init()
{
GameEngine::getInstance()->getCursor().setType(ARROW);
mapEditor = new Button(GameEngine::getInstance()->getSteering(),
sf::Vector2f((float)(GameEngine::SCREEN_WIDTH/2 -50.0),
(float)GameEngine::SCREEN_HEIGHT/2),
sf::Vector2f(100.0,50.0),
sf::Color(125,125,125),
"Edytor");
gameStart = new Button(GameEngine::getInstance()->getSteering(),
sf::Vector2f((float)(GameEngine::SCREEN_WIDTH/2 -50.0),
(float)(GameEngine::SCREEN_HEIGHT/2 - 100.0)),
sf::Vector2f(100.0,50.0),
sf::Color(125,125,125),
"Gra");
options = new Button(GameEngine::getInstance()->getSteering(),
sf::Vector2f((float)(GameEngine::SCREEN_WIDTH/2 -50.0),
(float)(GameEngine::SCREEN_HEIGHT/2 + 100)),
sf::Vector2f(100.0,50.0),
sf::Color(125,125,125),
"Opcje");
exit = new Button(GameEngine::getInstance()->getSteering(),
sf::Vector2f((float)(GameEngine::SCREEN_WIDTH/2 -50.0),
(float)(GameEngine::SCREEN_HEIGHT/2 + 200)),
sf::Vector2f(100.0,50.0),
sf::Color(125,125,125),
"Wyjscie");
title.SetImage(ImageManager::getInstance()->loadImage("Data/Textures/title.png"));
title.SetCenter(0, 0);
title.SetPosition(105,50);
info.SetText("alpha version");
info.SetScale(0.5, 0.5);
info.SetPosition(560, 140);
init = 1;
}
void MainMenuState::UpdateSystem()
{
}
void MainMenuState::Display()
{
GameEngine::getInstance()->SetDefaultView();
mapEditor->Display( &GameEngine::getInstance()->getWindow() );
gameStart->Display( &GameEngine::getInstance()->getWindow() );
options->Display( &GameEngine::getInstance()->getWindow() );
exit->Display( &GameEngine::getInstance()->getWindow() );
GameEngine::getInstance()->getWindow().Draw(title);
GameEngine::getInstance()->getWindow().Draw(info);
}
void MainMenuState::EventHandling()
{
GameEngine::getInstance()->SetDefaultView();
gameStart->GetEvent();
mapEditor->GetEvent();
options->GetEvent();
exit->GetEvent();
if ( exit->pressed )
{
GameEngine::getInstance()->getWindow().Close();
GameEngine::getInstance()->SwitchWindowIsOpen( false );
}
if ( options->pressed )
GameEngine::getInstance()->ChangeState( OPTIONSMENU );
if ( gameStart->pressed )
GameEngine::getInstance()->ChangeState(GAMEMENU);
if ( mapEditor->pressed )
GameEngine::getInstance()->ChangeState(EDITOR);
}
void MainMenuState::GetEvents()
{
sf::Event event = GameEngine::getInstance()->getEvent();
if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape))
{
GameEngine::getInstance()->getWindow().Close();
GameEngine::getInstance()->SwitchWindowIsOpen( false );
}
}
void MainMenuState::Cleanup()
{
delete mapEditor;
delete gameStart;
delete exit;
init = 0;
}