summaryrefslogtreecommitdiff
path: root/engine/bulletpattern.cpp
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 /engine/bulletpattern.cpp
parent8e92b0c5aa0cc57e8729069dad4cb635845f51d8 (diff)
Added BulletPattern4.
Diffstat (limited to 'engine/bulletpattern.cpp')
-rw-r--r--engine/bulletpattern.cpp33
1 files changed, 33 insertions, 0 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;
+ }
+}