summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-05-24 03:12:30 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-05-24 03:12:30 +0200
commit6952f8fa7e92d5ea0bf955d13c1bf0d95aa27b1a (patch)
treef749fe151ecf04bae3a1e8ad62f9a3678413feac
parent8e92b0c5aa0cc57e8729069dad4cb635845f51d8 (diff)
Added BulletPattern4.
-rw-r--r--engine/bulletpattern.cpp33
-rw-r--r--engine/bulletpattern.h6
-rw-r--r--engine/stage.cpp5
3 files changed, 42 insertions, 2 deletions
diff --git a/engine/bulletpattern.cpp b/engine/bulletpattern.cpp
index 195caf9..6ed4322 100644
--- a/engine/bulletpattern.cpp
+++ b/engine/bulletpattern.cpp
@@ -1,5 +1,6 @@
#include <cmath>
#include "bulletpattern.h"
+#include "matrix.h"
BulletPattern1::BulletPattern1(const Vector2& initpos) {
num_bullets = steps = 0;
@@ -86,3 +87,35 @@ void BulletPattern3::update() {
bullets[i].pos += bullets[i].dir;
}
}
+
+BulletPattern4::BulletPattern4(const Vector2& initpos) {
+ num_bullets = steps = 0;
+ color_r = 1.0;
+ color_g = 1.0;
+ color_b = 0.0;
+ bullets = new Bullet[24*16];
+
+ int k = 0;
+ for(int j = 0; j < 24; j++) {
+ for(float i = 0; i < 2 * M_PI; i += 0.4, k++) {
+ bullets[k].pos = initpos;
+ bullets[k].dir.x = cosf(i) / 40;
+ bullets[k].dir.y = sinf(i) / 40;
+ bullets[k].data.a = j * 10;
+ bullets[k].data.b = i;
+ }
+ }
+};
+
+void BulletPattern4::update() {
+ steps++;
+ while(num_bullets < 384 && (unsigned int)(bullets[num_bullets].data.a) < steps) {
+ num_bullets++;
+ }
+ for(int i = 0; i < num_bullets; i++) {
+ float l = log1pf((steps - bullets[i].data.a));
+ Matrix2 m = rotation_matrix(l);
+ bullets[i].dir = m * bullets[i].dir;
+ bullets[i].pos += bullets[i].dir;
+ }
+}
diff --git a/engine/bulletpattern.h b/engine/bulletpattern.h
index f550c2c..ab87635 100644
--- a/engine/bulletpattern.h
+++ b/engine/bulletpattern.h
@@ -55,4 +55,10 @@ class BulletPattern3 : public BulletPatternImpl<Struct<> > {
void update();
};
+class BulletPattern4 : public BulletPatternImpl<Struct<float, float> > {
+ public:
+ BulletPattern4(const Vector2& initpos);
+ void update();
+};
+
#endif
diff --git a/engine/stage.cpp b/engine/stage.cpp
index 53d7f59..e2ab46f 100644
--- a/engine/stage.cpp
+++ b/engine/stage.cpp
@@ -16,9 +16,10 @@ Stage::Stage() {
patterns.push_back(new BulletPattern3(Vector2(0.5, 0.5)));
patterns.push_back(new BulletPattern1(Vector2(0.5, 0.8)));
- patterns.push_back(new BulletPattern2(Vector2(0.2, 0.5)));
+ //patterns.push_back(new BulletPattern2(Vector2(0.2, 0.5)));
patterns.push_back(new BulletPattern2(Vector2(0.5, 0.5)));
- patterns.push_back(new BulletPattern2(Vector2(0.8, 0.5)));
+ //patterns.push_back(new BulletPattern2(Vector2(0.8, 0.5)));
+ patterns.push_back(new BulletPattern4(Vector2(0.5, 0.8)));
GLFragmentShader shader1("shaders/bullet_fragment.glsl");
GLVertexShader shader2("shaders/bullet_vertex.glsl");