summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-05-23 19:54:25 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-05-23 19:54:25 +0200
commit9e9140cdf95845c580ba084342033094e928c6e8 (patch)
treee0fd74aba5c1f1e7b17c702a25e6d08201933da3
parent9b9f94e2dcc8c850aaea4cfe0f2f7745669804ea (diff)
Moved BulletPattern1 and BulletPattern2.
-rw-r--r--engine/bulletpattern.cpp66
-rw-r--r--engine/bulletpattern.h12
-rw-r--r--engine/stage.cpp71
3 files changed, 78 insertions, 71 deletions
diff --git a/engine/bulletpattern.cpp b/engine/bulletpattern.cpp
index b9a0bbd..fa43f59 100644
--- a/engine/bulletpattern.cpp
+++ b/engine/bulletpattern.cpp
@@ -42,3 +42,69 @@ void BulletPattern::draw() {
glDisableClientState(GL_VERTEX_ARRAY);
}
+
+BulletPattern1::BulletPattern1() {
+ num_bullets = steps = 0;
+ color_r = 0;
+ color_g = 1;
+ color_b = 0;
+ stride = sizeof(float);
+ bullets = new float[8*32*5];
+
+ int k = 0;
+ for(int j = 0; j < 8; j++) {
+ for(float i = 0; i < M_PI; i += 0.1, k++) {
+ bullets[k*5] = 0.5 + sinf(j % 2 ? M_PI_2 + i : M_PI - i + M_PI_2) * 0.09;
+ bullets[k*5 + 1] = 0.8 + cosf(M_PI_2 + i) * 0.1;
+ bullets[k*5 + 2] = sinf(j % 2 ? M_PI_2 + i : M_PI - i + M_PI_2) / 1000;
+ bullets[k*5 + 3] = -0.002;
+ bullets[k*5 + 4] = j * 24 + i * 6;
+ }
+ }
+};
+
+void BulletPattern1::update() {
+ steps++;
+ while(num_bullets < 256 && (unsigned int)(bullets[num_bullets*5 + 4]) < steps) {
+ num_bullets++;
+ }
+ for(int i = 0; i < num_bullets; i++) {
+ bullets[i*5] += bullets[i*5 + 2];
+ bullets[i*5 + 1] += bullets[i*5 + 3];
+ }
+}
+
+BulletPattern2::BulletPattern2(float xpos, float ypos) {
+ num_bullets = 0;
+ color_r = 0.3;
+ color_g = 0.3;
+ color_b = 1.0;
+ stride = sizeof(float)*2;
+ bullets = new float[24*16*6];
+
+ int k = 0;
+ for(int j = 0; j < 24; j++) {
+ for(float i = 0; i < 2 * M_PI; i += 0.4, k++) {
+ bullets[k*6] = xpos;
+ bullets[k*6+1] = ypos;
+ bullets[k*6+2] = cosf(i) / 40;
+ bullets[k*6+3] = sinf(i) / 40;
+ bullets[k*6+4] = j * 10;
+ bullets[k*6+5] = i;
+ }
+ }
+};
+
+void BulletPattern2::update() {
+ steps++;
+ while(num_bullets < 384 && (unsigned int)(bullets[num_bullets*6 + 4]) < steps) {
+ num_bullets++;
+ }
+ for(int i = 0; i < num_bullets; i++) {
+ float l = bullets[i*6 + 5] - log1pf((steps - bullets[i*6+4]));
+ bullets[i*6+2] = cosf(l) / 500;
+ bullets[i*6+3] = sinf(l) / 500;
+ bullets[i*6] += bullets[i*6 + 2];
+ bullets[i*6+1] += bullets[i*6 + 3];
+ }
+} \ No newline at end of file
diff --git a/engine/bulletpattern.h b/engine/bulletpattern.h
index 9acda5f..e1dd3a2 100644
--- a/engine/bulletpattern.h
+++ b/engine/bulletpattern.h
@@ -15,4 +15,16 @@ class BulletPattern {
void draw();
};
+class BulletPattern1 : public BulletPattern {
+ public:
+ BulletPattern1();
+ void update();
+};
+
+class BulletPattern2 : public BulletPattern {
+ public:
+ BulletPattern2(float xpos, float ypos);
+ void update();
+};
+
#endif
diff --git a/engine/stage.cpp b/engine/stage.cpp
index cb306df..b9995ed 100644
--- a/engine/stage.cpp
+++ b/engine/stage.cpp
@@ -5,77 +5,6 @@
#include <SDL/SDL_opengl.h>
#include <cmath>
-class BulletPattern1 : public BulletPattern {
- public:
- BulletPattern1() {
- num_bullets = steps = 0;
- color_r = 0;
- color_g = 1;
- color_b = 0;
- stride = sizeof(float);
- bullets = new float[8*32*5];
-
- int k = 0;
- for(int j = 0; j < 8; j++) {
- for(float i = 0; i < M_PI; i += 0.1, k++) {
- bullets[k*5] = 0.5 + sinf(j % 2 ? M_PI_2 + i : M_PI - i + M_PI_2) * 0.09;
- bullets[k*5 + 1] = 0.8 + cosf(M_PI_2 + i) * 0.1;
- bullets[k*5 + 2] = sinf(j % 2 ? M_PI_2 + i : M_PI - i + M_PI_2) / 1000;
- bullets[k*5 + 3] = -0.002;
- bullets[k*5 + 4] = j * 24 + i * 6;
- }
- }
-
- };
- void update() {
- steps++;
- while(num_bullets < 256 && (unsigned int)(bullets[num_bullets*5 + 4]) < steps) {
- num_bullets++;
- }
- for(int i = 0; i < num_bullets; i++) {
- bullets[i*5] += bullets[i*5 + 2];
- bullets[i*5 + 1] += bullets[i*5 + 3];
- }
- }
-};
-
-class BulletPattern2 : public BulletPattern {
- public:
- BulletPattern2(float xpos, float ypos) {
- num_bullets = 0;
- color_r = 0.3;
- color_g = 0.3;
- color_b = 1.0;
- stride = sizeof(float)*2;
- bullets = new float[24*16*6];
-
- int k = 0;
- for(int j = 0; j < 24; j++) {
- for(float i = 0; i < 2 * M_PI; i += 0.4, k++) {
- bullets[k*6] = xpos;
- bullets[k*6+1] = ypos;
- bullets[k*6+2] = cosf(i) / 40;
- bullets[k*6+3] = sinf(i) / 40;
- bullets[k*6+4] = j * 10;
- bullets[k*6+5] = i;
- }
- }
- };
- void update() {
- steps++;
- while(num_bullets < 384 && (unsigned int)(bullets[num_bullets*6 + 4]) < steps) {
- num_bullets++;
- }
- for(int i = 0; i < num_bullets; i++) {
- float l = bullets[i*6 + 5] - log1pf((steps - bullets[i*6+4]));
- bullets[i*6+2] = cosf(l) / 500;
- bullets[i*6+3] = sinf(l) / 500;
- bullets[i*6] += bullets[i*6 + 2];
- bullets[i*6+1] += bullets[i*6 + 3];
- }
- }
-};
-
Stage::Stage() {
player = new Player();