diff options
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(); |