summaryrefslogtreecommitdiff
path: root/engine/bulletpattern.h
blob: 120b3d157996de9a7ee6527972b0fd6a06513c09 (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
59
60
61
62
63
64
#ifndef BULLETPATTERN_H
#define BULLETPATTERN_H

#include <wriggle/vector.h>
#include <wriggle/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();
};

class BulletPattern4 : public BulletPatternImpl<Struct<float, float> > {
	public:
		BulletPattern4(const Vector2& initpos);
		void update();
};

#endif