6 Pixel::Pixel(SDL_Surface* screen) {
7 this->x = (rand() / (float)RAND_MAX) * screen->w;
8 this->y = (rand() / (float)RAND_MAX) * screen->h;
9 this->vx = (rand() / (float)RAND_MAX) * 10.0 - 5.0;
10 this->vy = (rand() / (float)RAND_MAX) * 10.0 - 5.0;
11 this->lastupdate = SDL_GetTicks();
17 void Pixel::accel(float x, float y) {
21 else if (this->vx < -100.0)
26 else if (this->vy < -100.0)
30 void Pixel::update() {
31 Uint32 now = SDL_GetTicks();
32 float dt = (now - this->lastupdate) / 75.0;
33 if (dt < 1000) { // If we're running less than 1FPS, don't bother updating.
34 this->x += this->vx * dt;
35 this->y += this->vy * dt;
37 this->lastupdate = now;
40 void Pixel::draw(GLfloat *vertices) {
41 vertices[0] = this->x;
42 vertices[1] = this->y;
43 vertices[3] = this->x - this->vx / 4.0f;
44 vertices[4] = this->y - this->vy / 4.0f;