-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoseScene.cpp
More file actions
45 lines (36 loc) · 1010 Bytes
/
LoseScene.cpp
File metadata and controls
45 lines (36 loc) · 1010 Bytes
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
#include "LoseScene.h"
#include"SceneManager.h"
LoseScene::LoseScene(sf::RenderWindow * window) {
event = new sf::Event;
SceneManager::clean();
this->window = window;
this->label = "Lose Scene";
/* set background */
txr_background.loadFromFile("Images/game-over.jpeg");
background.setTexture(&txr_background);
background.setSize({ 800,600 });
}
void LoseScene::draw() {
window->clear();
window->setView(sf::View(sf::Vector2f(400, 300), sf::Vector2f(800, 600)));
events();
window->draw(background);
}
void LoseScene::events() {
while (window->pollEvent(*event))
{
switch (event->type)
{
case sf::Event::Closed:
window->close();
break;
case sf::Event::KeyPressed:
if (sf::Keyboard::isKeyPressed(sf::Keyboard::R)) {
SceneManager::push(SceneManager::createMenuScene(window));
}
else {
exit(1);
}
}
}
}