-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.cpp
158 lines (147 loc) · 4.28 KB
/
main.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "bakoom.h"
#include "shop.h"
#include "menu.h"
#include "global.h"
#include <QDesktopWidget>
#include <QApplication>
#include <ctime>
#include <iostream>
using namespace std;
int windowWidth = 480;
int windowHeight = 640;
int largeWindowWidth = 640;
int largeWindowHeight = 640;
int lowerUIHeight = 80;
int credits = 200;
int score;
int level;
int shield = 100;
int maxShield = 100;
int maxPower = 100;
int areaOfEffectRadius = 100;
bool hasItem[20];
bool restarting;
int islandQuality = 6;
int menu(int argc, char *argv[]);
int shop(int argc, char *argv[]);
int playLevel(int argc, char *argv[], vector<Enemy *> wave);
void initializeHasItem();
void centerRoom(QWidget &widget, int roomWidth, int roomHeight);
void initializeEnemies(vector<vector<Enemy *> > &vectorOfWaves);
void initializeHasItem()
{
hasItem[0] = true;
for(int i = 1; i < 20; i ++)
hasItem[i] = false;
}
void centerRoom(QWidget &widget, int roomWidth, int roomHeight)
{
int x, y;
int screenWidth;
int screenHeight;
QDesktopWidget *desktop = QApplication::desktop();
screenWidth = desktop->width();
screenHeight = desktop->height();
x = (screenWidth - roomWidth)/2;
y = (screenHeight - roomHeight)/2;
widget.setGeometry(x, y, roomWidth, roomHeight);
widget.setFixedSize(roomWidth, roomHeight);
}
int menu(int argc, char *argv[])
{
QApplication app(argc, argv);
Menu room;
room.setWindowTitle("Thunderbird");
room.setStyleSheet("background-color: rgb(0,0,40)");//(29,51,130)");
room.show();
centerRoom(room, largeWindowWidth, largeWindowHeight);
return app.exec();
}
int shop(int argc, char *argv[])
{
QApplication app(argc, argv);
Shop room;
room.setWindowTitle("Thundershop");
room.setStyleSheet("background-color: rgb(9,21,74)");
room.show();
centerRoom(room, largeWindowWidth, largeWindowHeight);
return app.exec();
}
int playLevel(int argc, char *argv[], vector<Enemy*> wave)
{
QApplication app(argc, argv);
Bakoom room(wave);
room.setWindowTitle("Thunderbird");
room.setStyleSheet("background-color: rgb(9,21,74)");
room.show();
centerRoom(room, windowWidth, windowHeight);
return app.exec();
}
void initializeEnemies(vector<vector<Enemy*> > &vectorOfWaves)
{
vectorOfWaves.clear();
vector<Enemy*> wave;
// level 1
for(int j = 25; j < 425; j += 50)
for(int k = 50; k < 300; k += 50)
wave.push_back(new Scout(j, k));
vectorOfWaves.push_back(wave);
wave.clear();
// level 2
for(int j = 25; j < 425; j += 50)
for(int k = 50; k < 300; k += 50)
wave.push_back(new Fighter(j, k));
vectorOfWaves.push_back(wave);
wave.clear();
// level 3
for(int j = 25; j < 425; j += 50)
for(int k = 50; k < 300; k += 50)
wave.push_back(new Jackal(j, k));
vectorOfWaves.push_back(wave);
wave.clear();
// level 4
for(int j = 25; j < 425; j += 100)
for(int k = 50; k < 350; k += 100)
wave.push_back(new Dragoon(j, k));
vectorOfWaves.push_back(wave);
wave.clear();
// level 5
for(int j = 25; j < 425; j += 50)
for(int k = 50; k < 300; k += 50)
wave.push_back(new Predator(j, k));
vectorOfWaves.push_back(wave);
wave.clear();
// level 6
wave.push_back(new Carrier(windowWidth/4,50));
wave.push_back(new Carrier(windowWidth/2,50));
vectorOfWaves.push_back(wave);
wave.clear();
// level 7
wave.push_back(new Eagle(windowWidth/2,80));
vectorOfWaves.push_back(wave);
wave.clear();
}
int main(int argc, char *argv[])
{
srand(time(NULL));
vector<vector<Enemy*> > vectorOfWaves;
initializeHasItem();
while(true)
{
score = 0;
shield = maxShield;
maxPower = 100;
areaOfEffectRadius = 100;
initializeEnemies(vectorOfWaves);
restarting = false;
menu(argc, argv);
for(level = 1; level <= vectorOfWaves.size(); level++)
{
if(restarting) break;
playLevel(argc, argv, vectorOfWaves.at(level-1));
if(restarting) break;
shop(argc, argv);
}
}
return 0;
}