diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-17 17:12:02 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-17 17:12:02 +0200 |
commit | ad649cae2db89696341b55cc83c42c253fcdae77 (patch) | |
tree | 063f50ef7aa694fbe3e34169fda4118f4bdee704 | |
parent | 3506d3df9f2e929def5b1662e08481d28643358f (diff) |
Merged BulletPattern2 bullets into a single pattern instance.
-rw-r--r-- | main.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -55,26 +55,28 @@ class BulletPattern1 : public BulletPattern { class BulletPattern2 : public BulletPattern { public: - BulletPattern2(bool reverse, unsigned int base) { + BulletPattern2(unsigned int base) { num_bullets = 0; color_r = 0; color_g = 1; color_b = 0; stride = sizeof(float); - bullets = new float[32*5]; - - int j = 0; - for(float i = 0; i < M_PI; i += 0.1, j++) { - bullets[j*5] = 50.0 + sinf(!reverse ? M_PI_2 + i : M_PI - i + M_PI_2) * 9; - bullets[j*5 + 1] = 80 + cosf(M_PI_2 + i) * 10; - bullets[j*5 + 2] = sinf(!reverse ? M_PI_2 + i : M_PI - i + M_PI_2) / 150.0; - bullets[j*5 + 3] = -0.01; - bullets[j*5 + 4] = base + i * 100; + 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] = 50.0 + sinf(j % 2 ? M_PI_2 + i : M_PI - i + M_PI_2) * 9; + bullets[k*5 + 1] = 80 + cosf(M_PI_2 + i) * 10; + bullets[k*5 + 2] = sinf(j % 2 ? M_PI_2 + i : M_PI - i + M_PI_2) / 150.0; + bullets[k*5 + 3] = -0.01; + bullets[k*5 + 4] = base + j * 400 + i * 100; + } } }; void update(unsigned int time, unsigned int step) { - while(num_bullets < 32 && (unsigned int)(bullets[num_bullets*5 + 4]) < time) { + while(num_bullets < 256 && (unsigned int)(bullets[num_bullets*5 + 4]) < time) { num_bullets++; } for(int i = 0; i < num_bullets; i++) { @@ -131,9 +133,7 @@ int main(int, char**) { for(int i = 0; i < 8; i++) { patterns.push_back(new BulletPattern1(i % 2 == 1, 5000 + i * 400)); } - for(int i = 0; i < 8; i++) { - patterns.push_back(new BulletPattern2(i % 2 == 1, 9000 + i * 400)); - } + patterns.push_back(new BulletPattern2(9000)); TextureSDL texture1("foo.png"); TextureSDL texture2("foo4.png"); |