-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoseScene.cpp
More file actions
35 lines (33 loc) · 1.35 KB
/
LoseScene.cpp
File metadata and controls
35 lines (33 loc) · 1.35 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
#include <functional>
#include <string>
#include "AudioHelper.hpp"
#include "GameEngine.hpp"
#include "Image.hpp"
#include "ImageButton.hpp"
#include "Label.hpp"
#include "LoseScene.hpp"
#include "PlayScene.hpp"
#include "Point.hpp"
void LoseScene::Initialize() {
int w = Engine::GameEngine::GetInstance().GetScreenSize().x;
int h = Engine::GameEngine::GetInstance().GetScreenSize().y;
int halfW = w / 2;
int halfH = h / 2;
AddNewObject(new Engine::Image("lose/benjamin-happy.png", halfW, halfH, 0, 0, 0.5, 0.5));
AddNewObject(new Engine::Label("You Lose :(", "pirulen.ttf", 48, halfW, halfH / 4 + 10, 255, 255, 255, 255, 0.5, 0.5));
Engine::ImageButton* btn;
btn = new Engine::ImageButton("win/dirt.png", "win/floor.png", halfW - 200, halfH * 7 / 4 - 50, 400, 100);
btn->SetOnClickCallback(std::bind(&LoseScene::BackOnClick, this, 2));
AddNewControlObject(btn);
AddNewObject(new Engine::Label("Back", "pirulen.ttf", 48, halfW, halfH * 7 / 4, 0, 0, 0, 255, 0.5, 0.5));
bgmInstance = AudioHelper::PlaySample("astronomia.ogg", false, AudioHelper::BGMVolume, PlayScene::DangerTime);
}
void LoseScene::Terminate() {
AudioHelper::StopSample(bgmInstance);
bgmInstance = std::shared_ptr<ALLEGRO_SAMPLE_INSTANCE>();
IScene::Terminate();
}
void LoseScene::BackOnClick(int stage) {
// Change to select scene.
Engine::GameEngine::GetInstance().ChangeScene("stage-select");
}