MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / spawnEmitterParticle

Function spawnEmitterParticle

deps/SDL2/Xcode-iOS/Demos/src/fireworks.c:261–307  ·  view source on GitHub ↗

spawns a new emitter particle at the bottom of the screen destined for the point (x,y). */

Source from the content-addressed store, hash-verified

259 destined for the point (x,y).
260*/
261void
262spawnEmitterParticle(GLfloat x, GLfloat y)
263{
264
265 if (num_active_particles >= MAX_PARTICLES)
266 return;
267
268 /* find particle at endpoint of array */
269 struct particle *p = &particles[num_active_particles];
270
271 /* set the color randomly */
272 switch (rand() % 4) {
273 case 0:
274 p->color[0] = 255;
275 p->color[1] = 100;
276 p->color[2] = 100;
277 break;
278 case 1:
279 p->color[0] = 100;
280 p->color[1] = 255;
281 p->color[2] = 100;
282 break;
283 case 2:
284 p->color[0] = 100;
285 p->color[1] = 100;
286 p->color[2] = 255;
287 break;
288 case 3:
289 p->color[0] = 255;
290 p->color[1] = 150;
291 p->color[2] = 50;
292 break;
293 }
294 p->color[3] = 255;
295 /* set position to (x, screen_h) */
296 p->x = x;
297 p->y = screen_h;
298 /* set velocity so that terminal point is (x,y) */
299 p->xvel = 0;
300 p->yvel = -sqrt(2 * ACCEL * (screen_h - y));
301 /* set other attributes */
302 p->size = 10 * pointSizeScale;
303 p->type = emitter;
304 p->isActive = 1;
305 /* our array has expanded at the end */
306 num_active_particles++;
307}
308
309/* just sets the endpoint of the particle array to element zero */
310void

Callers 1

mainFunction · 0.85

Calls 2

randFunction · 0.50
sqrtFunction · 0.50

Tested by

no test coverage detected