blob: f550c2ca1c999974125a1bc2c23e3388ae981f38 (
plain)
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
|
#ifndef BULLETPATTERN_H
#define BULLETPATTERN_H
#include "vector.h"
#include "struct.h"
#include <SDL/SDL_opengl.h>
class BulletPattern {
public:
float color_r, color_g, color_b;
virtual void update() = 0;
virtual void draw() = 0;
};
template<class Data>
class BulletPatternImpl : public BulletPattern {
protected:
struct Bullet {
Vector2 pos;
Vector2 dir;
Data data;
};
Bullet* bullets;
unsigned int num_bullets;
unsigned int steps;
public:
void draw() {
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(4, GL_FLOAT, sizeof(*bullets), bullets);
glDrawArrays(GL_POINTS, 0, num_bullets);
glDisableClientState(GL_VERTEX_ARRAY);
}
};
class BulletPattern1 : public BulletPatternImpl<float> {
public:
BulletPattern1(const Vector2& initpos);
void update();
};
class BulletPattern2 : public BulletPatternImpl<Struct<float, float> > {
public:
BulletPattern2(const Vector2& initpos);
void update();
};
class BulletPattern3 : public BulletPatternImpl<Struct<> > {
public:
BulletPattern3(const Vector2& initpos);
void update();
};
#endif
|