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
|
#ifndef ENGINE_H
#define ENGINE_H
#include "enginecore.h"
#include "GUI.h"
#define LEVEL_COMPLETED 2
#define LEVEL_FAILED 1
using namespace std;
class Account: public Levelable
{
public:
string name;
double gold;
long long highscore;
//owned ships
vector<UserShip*> ships;
//the ship currently used
int current;
//owned weapons that are not in ships
vector<Weapon*> weapons;
//list of succesfully played levels
vector<int> levels;
Account();
Account(string filename);
~Account();
void save();
void resetShips();
};
//game engine. deletes everything it gets besides account and screen
class ObjectHandler
{
protected:
list<Projectile*> friendlyProjectiles;
list<Projectile*> enemyProjectiles;
list<EnemyShip*> enemies;
public:
SlidingBackground* BG;
long long highscore;
double gold;
Account* user;
SDL_Surface* screen;
ObjectHandler(Account* newuser,SDL_Surface* newscreen, SDL_Surface *background);
~ObjectHandler();
int frame(double time);
void frameEnemy(EnemyShip* s, double time);
void spawnEnemy(EnemyShip* enemy,double nx, double ny);
};
class HUD
{
SDL_Surface* energyRaw;
SlidingBackground* energyBubbles;
SDL_Surface* energyMasc;
double Bubblesypos;
SDL_Surface* hpRaw;
SDL_Surface* hpMasc;
SDL_Surface *background;
TTF_Font *font;
public:
long long* highscore;
double* hp;
double hpmax;
double* energy;
double maxEnergy;
double *gold;
double *exp;
SDL_Color textColor;
HUD(long long *nhighscore, double *nhp, double nhpmax, double *nenergy, double nmaxEnergy, double* ngold, double* nexp);
~HUD();
void draw(SDL_Surface *screen);
};
class LevelEvent
{
};
LevelEvent* createEvent(ifstream& ins);
class LevelGenerator
{
Uint32 seed;
HUD *hud;
//collects the soundfiles that have been loaded and cleans them
vector<Mix_Chunk*> toDelete;
public:
//what ships will come in the Level -bosses
vector<EnemyShip*> prototypes;
vector<pair<double,LevelEvent*> > events;
//duration of the level -bosses
double duration;
//[(spawn%,(enemytype,path))] of each enemy
vector<pair<double,pair<int,vector<pair<double,double> > > > > spawnQueue;
int current;
//if there is currently an event happening
bool event;
//% of level completed
double completed;
ObjectHandler* OH;
string name;
SDL_Surface* screen;
LevelGenerator(string filename, Account* user, SDL_Surface* screen);
~LevelGenerator();
int frame(double time);
};
vector<pair<double,vector<pair<double,double> > > > generateWave(int number, int Nweapons,SDL_Surface* screen);
#endif
|