-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWinScene.cpp
More file actions
43 lines (41 loc) · 1.47 KB
/
WinScene.cpp
File metadata and controls
43 lines (41 loc) · 1.47 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
#include <functional>
#include <string>
#include "AudioHelper.hpp"
#include "GameEngine.hpp"
#include "Image.hpp"
#include "ImageButton.hpp"
#include "Label.hpp"
#include "PlayScene.hpp"
#include "Point.hpp"
#include "WinScene.hpp"
void WinScene::Initialize() {
ticks = 0;
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("win/benjamin-sad.png", halfW, halfH, 0, 0, 0.5, 0.5));
AddNewObject(new Engine::Label("You Win!", "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(&WinScene::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));
bgmId = AudioHelper::PlayAudio("win.wav");
}
void WinScene::Terminate() {
IScene::Terminate();
AudioHelper::StopBGM(bgmId);
}
void WinScene::Update(float deltaTime) {
ticks += deltaTime;
if (ticks > 4 && ticks < 100 &&
dynamic_cast<PlayScene*>(Engine::GameEngine::GetInstance().GetScene("play"))->MapId == 2) {
ticks = 100;
bgmId = AudioHelper::PlayBGM("happy.ogg");
}
}
void WinScene::BackOnClick(int stage) {
// Change to select scene.
Engine::GameEngine::GetInstance().ChangeScene("stage-select");
}