forked from bamster/bamster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathobjects.h
199 lines (152 loc) · 3.52 KB
/
objects.h
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#ifndef objects_h
#define objects_h objects_h
#include <X11/Xlib.h>
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <iostream>
#include "imageloader.h"
using namespace std;
struct boundingBox
{
double xmin;
double xmax;
double ymin;
double ymax;
};
//const double gravity = 1.0;
const char fromLeft = 1;
const char fromRight = 2;
const char fromUp = 3;
const char fromDown = 4;
const static double colors[5][3] = {
{1.,0.,0.},
{0.,1.,0.},
{0.,0.,1.},
{1.,0.,1.},
{0.,1.,1.}
} ;
char otherSide (char side);
enum enum_objectInfo { _player_ , _explosion_, _block_, _bullet_, _addon_, _undefined_};
typedef enum_objectInfo objectInfo;
class game;
class object {
protected:
public:
//! Pointer to the running game, allowing objects to spawnobjects or change the score.
static game * activGame;
double xpos, ypos;
double xvel, yvel;
virtual ~object() {}
boundingBox b;
virtual void stopMeFalling(double height);
int hitpoints;
object (double x, double y);
virtual objectInfo getObjectInfo();
virtual void updateBoundingBox();
GLuint loadTexture(Image *image);
char collidesWith (object &o);
virtual void plot();
virtual bool timerCallback(double dt);
virtual void collision(object *with, char fromWhere);
};
class fallingObject : public object
{
private:
public:
double gravity;
fallingObject (double x, double y);
virtual void stopMeFalling (double height);
virtual void collision (object *with, char fromWhere);
virtual objectInfo getObjectInfo();
virtual bool timerCallback(double dt);
};
class vwall : public object
{
private:
double length;
public:
virtual void plot();
void updateBoundingBox ();
vwall (double x, double y, double length);
};
class hwall : public object
{
private:
double length;
public:
virtual void plot();
void updateBoundingBox ();
hwall (double x, double y, double length);
};
class block: public fallingObject
{
private:
int color;
double size;
double red;
double green;
double blue;
public:
virtual void plot();
void updateBoundingBox ();
block (double x, double y, double length, int color);
virtual objectInfo getObjectInfo() { return _block_;}
virtual ~block();
virtual void collision (object *with, char fromWhere);
virtual bool timerCallback(double dt);
};
class explodingBlock : public block
{
public:
virtual ~explodingBlock();
};
class coloredExplosion : public object
{
private:
double size;
public:
int color;
virtual void plot ();
coloredExplosion(double x, double y, double s, int color);
void updateBoundingBox();
virtual objectInfo getObjectInfo() { return _explosion_; }
bool timerCallback (double dt);
};
class bullet : public object
{
private:
bool hitSomething;
double speed;
public:
bullet (double s, double x, double y);
void plot ();
virtual objectInfo getObjectInfo();
void updateBoundingBox ();
virtual void collision (object *with, char fromWhere);
bool timerCallback (double dt);
};
class addon : public fallingObject
{
private:
double size;
bool gotCollected;
GLuint animation;
public:
unsigned int addonType;
addon (double x, double y, double length, int t);
virtual void plot() ;
void updateBoundingBox();
virtual objectInfo getObjectInfo() { return _addon_; }
virtual void collision (object *with, char fromWhere) ;
bool timerCallback (double dt);
};
class erdnuss : public addon
{
public:
erdnuss (double x, double y, double length) : addon (x,y,length,0) {}
};
#endif