-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameOver.h
55 lines (44 loc) · 1018 Bytes
/
GameOver.h
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
#pragma once
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "TextureManager.h"
class GameOver {
sf::Sprite title;
//for sfx
sf::Sound sound;
sf::SoundBuffer gameOverBuffer;
public:
sf::Sprite getTitle();
void update();
bool doesGameStart();
void allowMusic();
bool gameStart = false;
bool playGameOver = true;
GameOver(TextureManager* textureManagerInitialized) {
title.setTexture(textureManagerInitialized->getTexture("GameOver_Title"));
if (!gameOverBuffer.loadFromFile("./audio/game-over-sfx-and-voice.wav")) {
std::cout << "Couldn't load hurt sfx" << std::endl;
}
sound.setBuffer(gameOverBuffer);
}
};
void GameOver::allowMusic() {
playGameOver = true;
}
void GameOver::update() {
if (playGameOver) {
sound.play();
}
playGameOver = false;
}
bool GameOver::doesGameStart() {
if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) {
sound.stop();
return true;
}
return false;
}
sf::Sprite GameOver::getTitle() {
return title;
}