This causes an emitter to explode in a circular bloom of dust particles */
| 181 | This causes an emitter to explode in a circular bloom of dust particles |
| 182 | */ |
| 183 | void |
| 184 | explodeEmitter(struct particle *emitter) |
| 185 | { |
| 186 | /* first off, we're done with this particle, so turn active off */ |
| 187 | emitter->isActive = 0; |
| 188 | int i; |
| 189 | for (i = 0; i < 200; i++) { |
| 190 | |
| 191 | if (num_active_particles >= MAX_PARTICLES) |
| 192 | return; |
| 193 | |
| 194 | /* come up with a random angle and speed for new particle */ |
| 195 | float theta = randomFloat(0, 2.0f * 3.141592); |
| 196 | float exponent = 3.0f; |
| 197 | float speed = randomFloat(0.00, powf(0.17, exponent)); |
| 198 | speed = powf(speed, 1.0f / exponent); |
| 199 | |
| 200 | /* select the particle at the end of our array */ |
| 201 | struct particle *p = &particles[num_active_particles]; |
| 202 | |
| 203 | /* set the particles properties */ |
| 204 | p->xvel = speed * cos(theta); |
| 205 | p->yvel = speed * sin(theta); |
| 206 | p->x = emitter->x + emitter->xvel; |
| 207 | p->y = emitter->y + emitter->yvel; |
| 208 | p->isActive = 1; |
| 209 | p->type = dust; |
| 210 | p->size = 15 * pointSizeScale; |
| 211 | /* inherit emitter's color */ |
| 212 | p->color[0] = emitter->color[0]; |
| 213 | p->color[1] = emitter->color[1]; |
| 214 | p->color[2] = emitter->color[2]; |
| 215 | p->color[3] = 255; |
| 216 | /* our array has expanded at the end */ |
| 217 | num_active_particles++; |
| 218 | } |
| 219 | |
| 220 | } |
| 221 | |
| 222 | /* |
| 223 | This spawns a trail particle from an emitter |
no test coverage detected