-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDedState.cpp
More file actions
95 lines (88 loc) · 3.27 KB
/
Copy pathDedState.cpp
File metadata and controls
95 lines (88 loc) · 3.27 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
//
// Created by lapo on 10/06/22.
//
#include "DedState.h"
#include "ClassMenuState.h"
DedState::DedState(GameDataRef data) {
this->data=data;
}
DedState::~DedState() {}
void DedState::Update() {}
void DedState::Init() {
data->menu->setTextureRect(sf::IntRect(0,1080*2,1920,1080));
data->menu->setScale(((1*data->lenght)/1920),((1*data->width)/1080));
std::stringstream ciao1;
ciao1<<"New Game";
auto text1=new sf::Text;
text1->setFont(data->font);
text1->setString(ciao1.str());
text1->setCharacterSize(50);
text1->setScale(data->lenght/1920,data->width/1080);
text1->setPosition((320*data->lenght)/1920,(700*data->width)/1080);
text1->setFillColor(sf::Color::Black);
text1->setOutlineThickness(5);
text1->setOutlineColor(sf::Color::Red);
Vtext.push_back(text1);
/////////////////////////////////////////////////
std::stringstream ciao2;
ciao2<<"Exit to\ndesktop";
auto text2=new sf::Text;
text2->setFont(data->font);
text2->setString(ciao2.str());
text2->setCharacterSize(50);
text2->setScale(data->lenght/1920,data->width/1080);
text2->setPosition((1360*data->lenght)/1920,(680*data->width)/1080);
text2->setFillColor(sf::Color::Black);
text2->setOutlineThickness(5);
text2->setOutlineColor(sf::Color::Red);
Vtext.push_back(text2);
/////////////////////////////////////////////////
std::stringstream ciao3;
ciao3<<"Ya Ded\nRecord= "<<data->level;
auto text3=new sf::Text;
text3->setFont(data->font);
text3->setString(ciao3.str());
text3->setCharacterSize(100);
text3->setScale(data->lenght/1920,data->width/1080);
text3->setPosition((760*data->lenght)/1920,(200*data->width)/1080);
text3->setFillColor(sf::Color::Black);
text3->setOutlineThickness(5);
text3->setOutlineColor(sf::Color::Red);
Vtext.push_back(text3);
}
void DedState::HandleInput() {
sf::Event event;
while (this->data->window.pollEvent(event))
if (sf::Event::Closed == event.type) {
this->data->window.close();
}
if (event.type == sf::Event::MouseButtonPressed) {
if (event.mouseButton.button == sf::Mouse::Left) {
if (data->input.response((200 * data->lenght) / 1920, (600 * data->width) / 1080,
(500 * data->lenght) / 1920, (300 * data->width) / 1080)) {
delete data->heroptr;
delete data->enemyptr;
data->Va.clear();
data->level = 1;
this->data->machine.setNewState(StateRef(new ClassMenuState(data)));
this->data->machine.setReplace(true);
data->first=true;
data->music3.stop();
data->music3.play();
data->music1.stop();
data->music1.openFromFile("./music/elevator.wav");
data->music1.play();
}
if (data->input.response((1200 * data->lenght) / 1920, (600 * data->width) / 1080,
(500 * data->lenght) / 1920, (300 * data->width) / 1080)) {
this->data->window.close();
}
}
}
}
void DedState::Draw() {
data->window.draw(*data->menu);
for(int i=0;i<Vtext.size();i++) {
data->window.draw(*Vtext.at(i));
}
}