From 6952f8fa7e92d5ea0bf955d13c1bf0d95aa27b1a Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Mon, 24 May 2010 03:12:30 +0200 Subject: Added BulletPattern4. --- engine/bulletpattern.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'engine/bulletpattern.cpp') 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 #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; + } +} -- cgit v1.2.3