summaryrefslogtreecommitdiff
path: root/enginecore.h
diff options
context:
space:
mode:
Diffstat (limited to 'enginecore.h')
-rw-r--r--enginecore.h190
1 files changed, 190 insertions, 0 deletions
diff --git a/enginecore.h b/enginecore.h
new file mode 100644
index 0000000..5ea49ae
--- /dev/null
+++ b/enginecore.h
@@ -0,0 +1,190 @@
1#ifndef ENGINECORE_H
2#define ENGINECORE_H
3
4#include "util.h"
5#include <SDL/SDL_rotozoom.h>
6#include <SDL/SDL_mixer.h>
7#include <fstream>
8#include <list>
9#include <algorithm>
10
11using namespace std;
12
13//a drawable object featering an image and a position
14class DObject
15{
16protected:
17 SDL_Surface* image;
18public:
19 double x;
20 double y;
21
22 DObject();
23 DObject(string filename, double newx, double newy);
24 DObject(SDL_Surface* newImage, double newx, double newy);
25 DObject(const DObject &o);
26 virtual ~DObject();
27 virtual void draw(SDL_Surface* screen);
28};
29
30bool ooB(const DObject* o, SDL_Surface* screen);
31
32double armorF(double damage, double armor);
33
34class Levelable
35{
36protected:
37 double exp;
38 int level;
39public:
40 double next;
41 double lin;
42 double quad;
43 double cube;
44
45 Levelable();
46
47 int addExp(double moreExp);
48 int getLevel();
49 double getExp();
50 double* getExpPointer();
51};
52
53class Projectile: public DObject
54{
55public:
56 Projectile(SDL_Surface* newimage, double newx, double newy, double newdamage, double newcollisionsize, double newxSpeed, double newySpeed);
57 Projectile(const Projectile& P);
58 Projectile(string filename,vector<Mix_Chunk*>& sounds);
59 virtual ~Projectile(){};
60 double damage;
61 double armorPiercing;
62 double collisionSize;
63 double xSpeed;
64 double ySpeed;
65
66 void frame(double time);
67 void rotateAccordingly();
68};
69
70class Item: public DObject
71{
72public:
73 double cost;
74 bool sellable;
75 Item(const Item& item);
76 Item(const DObject& dObject);
77 Item(){};
78 SDL_Surface* getImage();
79};
80
81class Weapon: public Item
82{
83protected:
84 vector<double> startTimer;
85 vector<Projectile*> prototypes;
86public:
87 bool playSound;
88 vector<vector<Mix_Chunk*> > sounds;
89 bool active;
90 string name;
91 double energyUsage;
92 vector<double> cooldown;
93 vector<double> currentTimer;
94 Weapon(const Weapon& w);
95 Weapon(string filename);
96 ~Weapon();
97 vector<Projectile*> frame(double time);
98 void mirror();
99 double getDPS() const;
100 double getDPE() const;
101};
102
103
104class Upgradeable
105{
106protected:
107 double value;
108public:
109 string name;
110 double cost;
111 int level;
112 int maxLevel;
113 void setValue(double nvalue);
114 double getValue() const;
115 Upgradeable();
116 Upgradeable(double d);
117 operator double() const;
118 Upgradeable& operator=(const double& d);
119 void upgrade();
120 void save(ofstream& o);
121 void load(ifstream& i);
122};
123
124ifstream& operator>>(ifstream& ins, Upgradeable& u);
125
126class Ship: public DObject
127{
128public:
129 Ship(string filename,int x, int y);
130 Ship(){};
131 Ship(const Ship& s);
132 virtual ~Ship();
133 string name;
134 double hp;
135 Upgradeable maxhp;
136 Upgradeable armor;
137 Upgradeable moveSpeed;
138 double collisionSize;
139 vector<Weapon*> weapons;
140 vector<pair<int, int> > slotPositions;
141 int hit(const Projectile& P);
142// void draw(SDL_Surface* screen);
143 virtual vector<Projectile*> frame(double time);
144};
145
146class EnemyShip: public Ship
147{
148public:
149 vector<pair<double, double> > path;
150 double gold;
151 double exp;
152 double score;
153 unsigned int current;
154 EnemyShip(const EnemyShip& s);
155 EnemyShip(string filename);
156 vector<Projectile*> frame(double time);
157 void assignValue();
158};
159
160class UserShip: public Ship
161{
162public:
163 SDL_Surface* getImage();
164 double cost;
165 double energy;
166 Upgradeable maxEnergy;
167 Upgradeable energyProduction;
168 Upgradeable handling;
169 double xSpeed;
170 double ySpeed;
171 int weaponSlots;
172 vector<double> maxSize;
173 int right;
174 int down;
175 int shooting;
176
177 UserShip(string filename);
178
179 void draw(SDL_Surface* screen);
180 vector<Upgradeable*> getUpgradeables();
181 void reset();
182
183 vector<Projectile*> frame(double time, SDL_Surface* screen);
184};
185
186double estimateValue(const Weapon& w);
187double estimateValue(const UserShip& s);
188
189
190#endif