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 pathStage.cpp
136 lines (116 loc) · 2.4 KB
/
Stage.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "Stage.h"
#include "MainMenuScene.h"
#include "GameScene.h"
#include "Game1vs1Scene.h"
#include "LevelScene.h"
#include "HeroScene.h"
#include "EndGame.h"
#include "Path.h"
#include <memory>
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_primitives.h>
void Stage::memoryManage()
{
if (gameScene != NULL) {
delete gameScene;
gameScene = NULL;
}
if (game1vs1Scene != NULL) {
delete game1vs1Scene;
game1vs1Scene = NULL;
}
if (levelScene != NULL) {
delete levelScene;
levelScene = NULL;
}
if (heroScene != NULL) {
delete heroScene;
heroScene = NULL;
}
if (winScene != NULL) {
delete winScene;
winScene = NULL;
}
if (loseScene != NULL) {
delete loseScene;
loseScene = NULL;
}
}
Stage::Stage()
{
if (!al_init()) {
fprintf(stderr, "Failed to initialize allegro!\n");
exit(0);
}
al_init_image_addon();
al_install_keyboard();
al_install_mouse();
al_install_audio();
al_init_acodec_addon();
al_init_font_addon();
al_init_ttf_addon();
al_init_primitives_addon();
Path path;
menuScene = new MainMenuScene(this);
menuScene->setBackground(path.BACKGROUND_MAIN_MENU);
}
Stage::~Stage()
{
if(menuScene != NULL)
delete menuScene;
memoryManage();
al_uninstall_system();
std::cout << "Stage" << std::endl;
}
void Stage::showMenu()
{
memoryManage();
menuScene->showWindow();
}
void Stage::showGame()
{
Path path;
gameScene = new GameScene(this);
gameScene->setBackground(path.BACKGROUND_GAME_ADVENTURE);
gameScene->showWindow();
}
void Stage::showGame1vs1()
{
Path path;
game1vs1Scene = new Game1vs1Scene(this);
game1vs1Scene->setBackground(path.BACKGROUND_GAME);
game1vs1Scene->showWindow();
}
void Stage::showLevel()
{
Path path;
levelScene = new LevelScene(this);
levelScene->setBackground(path.BACKGROUND_MAIN_MENU);
levelScene->showWindow();
}
void Stage::showHero()
{
Path path;
heroScene = new HeroScene(this);
heroScene->setBackground(path.BACKGROUND_MAIN_MENU);
heroScene->showWindow();
}
void Stage::showWin()
{
Path path;
winScene = new EndGame(this);
winScene->setBackground(path.BACKGROUND_WIN);
winScene->showWindow();
}
void Stage::showLose()
{
Path path;
loseScene = new EndGame(this);
loseScene->setBackground(path.BACKGROUND_LOSE);
loseScene->showWindow();
}