summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-05-17 12:57:09 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-05-17 12:57:09 +0200
commitc40b10c9b1f216e75a153b37c7987268a1a66b1e (patch)
tree8a7335516ad068840a5e63f5fa1f05bcd6ab4667 /main.cpp
parent33c2afafa0c6b936dace4b2b6203f03a89823049 (diff)
Created BulletPattern-class.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/main.cpp b/main.cpp
index 65a3b9e..7cba083 100644
--- a/main.cpp
+++ b/main.cpp
@@ -18,6 +18,7 @@
#include "shader.h"
#include "vector.h"
#include "bullet.h"
+#include "bulletpattern.h"
class BulletAdder {
public:
@@ -57,14 +58,7 @@ void create_pattern1(unsigned int base) {
}
void create_pattern2(unsigned int base) {
- for(float i = 0; i < M_PI * 16; i += 0.1) {
- bullets_queue.push(BulletAdder(base + (unsigned int)(i*40),
- Bullet(
- Vector3(50.0 + cosf(i) * 5,
- 50.0 + sinf(i) * 5, 0),
- Vector3(cosf(i) / 100.0, sinf(i) / 100.0, 0),
- 5)));
- }
+
}
void create_pattern2_2(unsigned int base) {
@@ -131,6 +125,8 @@ int main(int, char**) {
glShadeModel(GL_SMOOTH);
create_bullets();
+
+ BulletPattern* pattern = new BulletPattern();
TextureSDL texture1("foo.png");
TextureSDL texture2("foo4.png");
@@ -195,7 +191,9 @@ int main(int, char**) {
bullets_queue.pop();
bullets.push_back(bullet);
}
+ pattern->update(elapsed, step);
}
+
gluLookAt(
5 * sinf(f), 1, 5 * cosf(f),
0, 0, 0,
@@ -228,6 +226,13 @@ int main(int, char**) {
glPointSize(16.0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture2.tex());
+
+ glColor4f(1, 0, 0, 1);
+
+ pattern->draw();
+
+ glColor4f(0, 1, 0, 1);
+
glBegin(GL_POINTS);
for(it = bullets.begin(); it != bullets.end();) {
Bullet& b = (*it);
@@ -238,9 +243,8 @@ int main(int, char**) {
b.pos.z += b.direction.z * step;
}
- glColor4f(0, 1, 0, 1);
-
glVertex4f(b.pos.x, b.pos.y, b.direction.x, b.direction.y);
+
//glColor3f(b.color.r, b.color.g, b.color.b);
/*glTexCoord2f(0, 0);
glVertex3f(b.pos.x-1, b.pos.y-1, b.pos.z);