blob: 1e8da5e3b72ae647f49f8934a392afb9afd0672a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifndef __APPLE__
#include <GL/gl.h>
#else
#include <OpenGL/gl.h>
#endif
#include <cmath>
#include "bulletpattern.h"
BulletPattern::BulletPattern() {
num_bullets = 0;
bullets = new float[2048];
int k = 0;
for(float i = 0; i < M_PI * 16; i += 0.1) {
bullets[k++] = 50.0 + cosf(i) * 5;
bullets[k++] = 50.0 + sinf(i) * 5;
bullets[k++] = cosf(i) / 100.0;
bullets[k++] = sinf(i) / 100.0;
}
}
void BulletPattern::update(unsigned int time, unsigned int step) {
if(num_bullets < 503 && num_bullets * 4 < time) {
num_bullets += time / 4 - num_bullets;
}
for(int i = 0; i < num_bullets; i++) {
bullets[i*4] += bullets[i*4 + 2] * step;
bullets[i*4 + 1] += bullets[i*4 + 3] * step;
}
}
void BulletPattern::draw() {
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(4, GL_FLOAT, 4 * sizeof(float), bullets);
glDrawArrays(GL_POINTS, 0, num_bullets);
glDisableClientState(GL_VERTEX_ARRAY);
}
|