diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-05-23 22:10:50 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-05-23 22:10:50 +0200 |
commit | f2d3072643e4140ef3dd144b7509eda8d4a323d6 (patch) | |
tree | e85cb04d777fc0a6b6d3697ae1b8879cccd68d32 /engine/bulletpattern.h | |
parent | 9620ed1c2c0c40400b638743b19462dfdc6b0c55 (diff) |
Made bullet-lists configurable by template parameter.
Diffstat (limited to 'engine/bulletpattern.h')
-rw-r--r-- | engine/bulletpattern.h | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/engine/bulletpattern.h b/engine/bulletpattern.h index 8df7945..f550c2c 100644 --- a/engine/bulletpattern.h +++ b/engine/bulletpattern.h @@ -2,33 +2,54 @@ #define BULLETPATTERN_H #include "vector.h" +#include "struct.h" + +#include <SDL/SDL_opengl.h> class BulletPattern { - protected: - float* bullets; - unsigned int num_bullets; - unsigned int stride; - unsigned int steps; public: float color_r, color_g, color_b; virtual void update() = 0; - void draw(); + 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 BulletPattern { +class BulletPattern1 : public BulletPatternImpl<float> { public: BulletPattern1(const Vector2& initpos); void update(); }; -class BulletPattern2 : public BulletPattern { +class BulletPattern2 : public BulletPatternImpl<Struct<float, float> > { public: BulletPattern2(const Vector2& initpos); void update(); }; -class BulletPattern3 : public BulletPattern { +class BulletPattern3 : public BulletPatternImpl<Struct<> > { public: BulletPattern3(const Vector2& initpos); void update(); |