This repository has been archived by the owner on Mar 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevelScene.cpp
66 lines (54 loc) · 1.85 KB
/
LevelScene.cpp
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
#include "LevelScene.h"
LevelScene::LevelScene(Stage* stage) :stage(stage)
{
Path path;
this->easyButton = new Button(path.BUTTON_EASY);
this->mediumButton = new Button(path.BUTTON_MEDIUM);
this->hardButton = new Button(path.BUTTON_HARD);
this->easyButton->setXposition((this->screen_width / 2) - (this->easyButton->getBitmapWidth() / 2));
this->easyButton->setYposition((this->screen_height / 2) - (this->easyButton->getBitmapHeight() / 2) - 150);
this->mediumButton->setXposition((this->screen_width / 2) - (this->mediumButton->getBitmapWidth() / 2));
this->mediumButton->setYposition((this->screen_height / 2) - (this->mediumButton->getBitmapHeight() / 2) + 0);
this->hardButton->setXposition((this->screen_width / 2) - (this->hardButton->getBitmapWidth() / 2));
this->hardButton->setYposition((this->screen_height / 2) - (this->hardButton->getBitmapHeight() / 2) + 150);
}
LevelScene::~LevelScene()
{
delete easyButton;
delete mediumButton;
delete hardButton;
cout << "DESKTRUKTOR Z LEVEL_SCENE" << endl;
}
void LevelScene::showWindow()
{
int x = 0, y = 0;
this->done = false;
while (!this->done) {
ALLEGRO_EVENT events;
al_wait_for_event(engine->event_queue, &events);
if (events.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN) {
if (events.mouse.button & 1) {
x = events.mouse.x;
y = events.mouse.y;
if (this->easyButton->buttonClick(x, y)) {
Engine::difficultyLevel = DifficultyLevel::EASY;
break;
}
if (this->mediumButton->buttonClick(x, y)) {
Engine::difficultyLevel = DifficultyLevel::MEDIUM;
break;
}
if (this->hardButton->buttonClick(x, y)) {
Engine::difficultyLevel = DifficultyLevel::HARD;
break;
}
}
}
al_draw_bitmap(this->background, 0, 0, 0);
this->easyButton->show();
this->mediumButton->show();
this->hardButton->show();
al_flip_display();
}
this->stage->showGame();
}